Closed
Description
Current problem
The representative code implements single dispatching with the @singledispatch
and @staticmethod
decorators in a class.
Class Board():
@singledispatch
@staticmethod
def convert_position(position):
[...]
@convert_position.register(str)
@staticmethod
def _(position: str) -> tuple:
[...]
@convert_position.register(tuple)
@staticmethod
def _(position: tuple) -> str:
[...]
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.