Skip to content
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

Classmethod fails on the uninitialized class object #92

Closed
u-tung opened this issue Aug 2, 2023 · 2 comments
Closed

Classmethod fails on the uninitialized class object #92

u-tung opened this issue Aug 2, 2023 · 2 comments

Comments

@u-tung
Copy link

u-tung commented Aug 2, 2023

version: dev
python: 3.10.12

class Foo:
     @multimethod
     def bar(cls, x: str):
         print(cls, str)

     @classmethod # <- only put this @classmethod here on the final definition
     @bar.register
     def _(cls, x: int):
         print(cls, int)

Foo().bar(10) # ok
Foo.bar(10) # DispatchError: ('bar: 0 methods found', (<class 'int'>,), [])
coady added a commit that referenced this issue Aug 3, 2023
@coady
Copy link
Owner

coady commented Aug 3, 2023

classmethod can not be used with register because register returns the original function, not the multimethod. The example has been updated to demonstrate explicitly calling classmethod.

@u-tung
Copy link
Author

u-tung commented Aug 3, 2023

@coady Thank you for your answer.

@u-tung u-tung closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants