-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
featuretopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributes
Description
Bug Report
The @staticmethod decorator only appears to work with MyPy when used as a decorator.
For example, the following code works:
class MyClass:
@staticmethod
def my_method():
...However, the following code does not work:
from typing import Callable
def make_staticmethod(func: Callable, /) -> staticmethod:
return staticmethod(func)
class MyClass:
@make_staticmethod
def my_method():
...The above code produces the following error:
error: Method must have at least one argumentTo Reproduce
- Run MyPy against the non-working example shown above
Expected Behavior
MyPy sees that the decorator returns a staticmethod and proceeds to treat MyClass.my_method as a staticmethod
Actual Behavior
MyPy produces the following error:
error: Method must have at least one argumentThe above error implies that MyPy is not treating the method as a staticmethod.
Your Environment
- Mypy version used: 0.971
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.8.10
- Operating system and version: Linux Mint 20.3 x86_64
dvmcconnell, BrianPugh, daler-sz, asvarga, starskin and 1 more
Metadata
Metadata
Assignees
Labels
featuretopic-descriptorsProperties, class vs. instance attributesProperties, class vs. instance attributes