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

feature request: warning on duplicate signatures #155

Closed
Wouter1 opened this issue Jun 6, 2024 · 4 comments · Fixed by #161
Closed

feature request: warning on duplicate signatures #155

Wouter1 opened this issue Jun 6, 2024 · 4 comments · Fixed by #161

Comments

@Wouter1
Copy link

Wouter1 commented Jun 6, 2024

I would like to have a feature or way to get warnings or errors if a method with same signature is defined twice

eg

class A:
 @dispatch
 def f(self, x:int):
  return 1
 @dispatch
 def f(self, x:int):
  return 2

Of course it may be not so obvious as in this example.
The variables may have different names, or types that look different may turn out to be the same after some evaluation (eg Optional[int] versus Union[int, None])
As it is, the second definition just overrides the first.

Maybe @dispatch could have an option eg (override=error) or something to that effect, so that you get an error message at the duplicate function

@wesselb
Copy link
Member

wesselb commented Jun 13, 2024

@Wouter1 I've added a warning that's displayed every time a method is overwritten! I think that's a great addition. :)

@Wouter1
Copy link
Author

Wouter1 commented Jun 17, 2024

@wesselb great, thanks!
Can I already use this using the latest pip install plum (which version?) or is this fix not yet released?

@PhilipVinc
Copy link
Collaborator

I just tagged v2.4.2, so yes.

@Wouter1
Copy link
Author

Wouter1 commented Jun 17, 2024

@PhilipVinc top, thanks!

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

Successfully merging a pull request may close this issue.

3 participants