Closed
Description
Env
- Python 3.7.2
- MyPy 0.700
Problem Details
Following code
import dis
def f(a: int) -> int:
return a + 2
dis.dis(f)
MyPy will report
x.py:8: error: Argument 1 to "dis" has incompatible type "Callable[[int], int]"; expected "Union[MethodType, FunctionType, CodeType, type, str, bytes]"
It seems MyPy does not parse it as types.FunctionType
, I'm not sure it's a bug of MyPy or typeshed. I check the code of dis.dis
(https://github.com/python/cpython/blob/9a3ffc0492d1310ead9ce8f5ee678c26b20a338d/Lib/dis.py#L34-L77), I think implementing a Protocol
is a workaround.
Metadata
Metadata
Assignees
Labels
No labels