Closed
Description
To Reproduce
Run mypy on this code and then run the code
import functools
@functools.cache
def factorial(n: int) -> int:
return n * factorial(n-1) if n else 1
def identity(n: int) -> int:
return n
if __name__ == '__main__':
print(factorial.__name__, factorial.__annotations__)
print(identity.__name__, identity.__annotations__)
factorial("")
identity("")
The output of the program is:
factorial {'n': <class 'int'>, 'return': <class 'int'>}
identity {'n': <class 'int'>, 'return': <class 'int'>}
so type information is available.
Expected Behavior
The lines
factorial("")
and
identity("")
should be both flagged as wrong because the function is called with an incompatible type
Actual Behavior
An error is issued for
identity("")
but not for
factorial("")
As a side note, mypy issues an error
_lru_cache_wrapper[int]" has no attribute "name" for _print(factorial.name, ...)
but this is another issue.
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): none - Python version used: 3.9.5
- Operating system and version: Windows 10