bpo-32380 Fix singledispatch interaction with methods#4987
Conversation
Singledispatch used the first argument to dispatch on. This made it incomatible with methods. This change adds support for methods by dispatching on the second argument if the passed function is a method.
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thanks! I think this should be implemented more carefully, see comments.
Sorry, something went wrong.
|
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 |
Sorry, something went wrong.
ncoghlan
left a comment
There was a problem hiding this comment.
Thanks for the PR, but unfortunately, I don't believe this particular class-definition-time-only approach is ever going to work right given the semantics of the descriptor protocol.
Instead, something more like the functools.partialmethod will be needed, which defers some key tasks to its __get__ method implementation.
Sorry, something went wrong.
|
I'm afraid I don't have the bandwidth for this at the moment. @ianhoffman if you want to take over be my guest. I'll come back to it another time if not. |
Sorry, something went wrong.
|
It is sad to see this closed, I think it would be a useful addition, please keep me posted if you will resume your work. |
Sorry, something went wrong.
|
I want to focus on PEP 561 and a personal project, but I might get back to this after a month or two. |
Sorry, something went wrong.
Singledispatch dispatches on the first argument, making it incompatible with classes. This change fixes that.
https://bugs.python.org/issue32380