NotFoundLookupError when using dispatch.multi in class method
See original GitHub issuemaster 7e9b8657
from plum import dispatch
@dispatch.multi((int, str), (int, int))
def f(x: int, y: {int, str}):
print(f'{x}, {y}')
class C():
@dispatch
def g(self, x: int, y: int):
print(f'{x}, {y}')
@dispatch
def g(self, x: int, y: str):
print(f'{x}, {y}')
@dispatch.multi((int, str), (int, int))
def h(self, x: int, y: {int, str}):
print(f'{x}, {y}')
f(3, 4) # OK
c = C()
c.g(3, 4) # OK
c.g(3, 'cat') # OK
c.h(3, 4) # NotFoundLookupError
c.h(3, 'cat') # NotFoundLookupError
I did not yet try this on the latest released branch.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
plum-dispatch - PyPI
Multiple dispatch allows you to implement multiple methods for the same function, where the methods specify the types of their arguments:
Read more >Where to dispatch multiple actions in redux? - Stack Overflow
The recommended way as per the documentation is in the action creator, like so: function actionCreator(payload) { return dispatch ...
Read more >Using @singledispatchmethod for Multiple Class Constructors
Starting with Python 3.8, you can use this @singledispatch or @singledispatchmethod decorator to turn a function or method, respectively, into a single-dispatch ......
Read more >Open Multi-Methods for C++ - Bjarne Stroustrup's Homepage
multi -methods generalize multiple dispatch towards open-class ex- ... care was taken to integrate open multi-methods with existing C++.
Read more >object oriented - Multiple Dispatch and CLOS
In CLOS methods are not in a class namespace. Thus to have shorter access to variables and accessors, CLOS uses macros WITH-SLOTS and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks. Your last example has solved my problem.
Ah, sorry, I should have said that this should also be used when classes are used, even if you don’t make use of inheritance. The problem is that vanilla functions and methods of classes behave slightly differently.
Plum should play nicely with ABC. Here’s an example: