-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143535: Document dispatch behavior of singledispatchmethod #143592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-143535: Document dispatch behavior of singledispatchmethod #143592
Conversation
Doc/library/functools.rst
Outdated
| @neg.register | ||
| def _(self, arg: bool): | ||
| return not arg | ||
| .. note:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Don't use a note.
- Put the paragraph after we mention the behavior of classmethod/staticmethod
- Don't write
x.f(a) != C.f(x,a)it's confusing and ca be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification, I will remove the note and describe the behaviour in paragraph format, in text. I will update the PR shortly.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
The PR clarifies the behavior of
singledispatchmethodin the documentation. It always dispatches the first argument during call, regardless of whether the method is bound or unbound, as a resultxf(a)!=c.f(x,a). The behavior is intentional and required to support correct dispatch forstaticmethodandclassmethod.singledispatchmethoddispatches on theselfargument when invoked from class level #143535📚 Documentation preview 📚: https://cpython-previews--143592.org.readthedocs.build/