Open
Description
Bug Report
Classmethods bound with an additional name trigger stubtest
errors.
To Reproduce
Consider the following trivial module and companion typing stub file
# mod.py
class T:
def a(self): pass
b = a
@classmethod
def c(cls): pass
d = c
# mod.pyi
class T:
def a(self) -> None: pass
b = a
@classmethod
def c(cls) -> None: pass
d = c
then run stubtest
the following way:
PYTHONPATH=$PWD stubtest mod
Expected Behavior
stubtest
succeeds with no output printed
Actual Behavior
error: mod.T.d variable differs from runtime type def () -> Any
Stub: in file /home/dalcinl/tmp/pkg/mod.pyi:6
def (cls: Type[mod.T])
Runtime: in file /tmp/mod.py:4
<bound method T.c of <class 'mod.T'>>
Found 1 error (checked 1 module)
Please note that the issue comes from a @classmethod
, a regular method does not trigger the error.
Your Environment
- Mypy version used: 1.4.1
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.11.4