-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Check For @singledispatch Decorator in classes without @staticmethod
#6917
Comments
Thanks for the clear report. This could be added to the |
@staticmethod
Hey @jacobtylerwalls - landing here from the |
@ramonsaraiva That should indeed be relatively similar. In fact, I think we can build upon some of the code that is already there. You can probably also look at https://github.com/PyCQA/pylint/blob/main/tests/functional/m/method_cache_max_size_none.py for some inspiration for functional tests. |
Awesome, I'll be reading more about how everything works and attempt to come up with a draft patch for this. A few review interactions will most likely be needed. Thanks! |
Created that draft PR and added in its description a bit of my thought process and things that I believe can be improved and simplified. I just want to have a better sense if I'm going in the right direction. I'll be digging more on utilities and built-in functionality that I can use to simplify all of that but I thought it'd be helpful to have a draft available for you to take a look. |
I think 4d95d21 and cc64ded bring a much cleaner version that 3dc3616 had - still open to suggestions. I added a new util function for |
Manually closing since MR is merged. |
Current problem
The representative code implements single dispatching with the
@singledispatch
and@staticmethod
decorators in a class.Pylint reports nothing unusual about using
@singledispatch
inside a class.Desired solution
Pylint should check for the
@singledispatch
decorator inside a class. According to the documentation, the@singledispatchmethod
decorator is for class methods.Additional context
The code works with the
@singledispatch
decorator as long as the single dispatch methods have the@staticmethod
decorator (i.e., stateless methods). If the@staticmethod
decorators were removed or replaced with the@classmethod
decorator, the code stops working and the resulting error messages will indirectly point out the wrong decorator. A pylint check would prevent that from happening.The text was updated successfully, but these errors were encountered: