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

init fails, incorrect number of arguments #191

Open
Wouter1 opened this issue Nov 6, 2024 · 0 comments
Open

init fails, incorrect number of arguments #191

Wouter1 opened this issue Nov 6, 2024 · 0 comments

Comments

@Wouter1
Copy link

Wouter1 commented Nov 6, 2024

Try this code

from plum import dispatch

class A:
  @dispatch
  def __init__(self):
    self.__init__(1)
  @dispatch
  def __init__(self, x:int):
    print(str(x))

class B(A):
  def __init__(self):
    super().__init__()

B()

Expected: B is constructed with default value 1

Actual:

TypeError: __init__() takes 1 positional argument but 2 were given

I'm not sure what is going on as constructing A() works fine.

Note the print is just for clarity, normally some field initialization would happen there.

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

1 participant