mypy confuses dataclass field name with imported function name #10640
Labels
bug
mypy got something wrong
topic-dataclasses
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
topic-variable-scope
Bug Report
This standalone file produces the mistaken error
models/mypy_bug.py:8: error: "str" not callable
:This is because mypy confuses the field "field" and the imported function "field()". Renaming the field removes the error message.
Expected Behavior
This should not be an error.
It's not obvious to me what's correct here, but this code executes as intended in Python 3.8.
So either mypy or Python 3.8 is wrong about this. I choose to file the bug with mypy.
Actual Behavior
mypy gives this error:
models/mypy_bug.py:8: error: "str" not callable
Your Environment
--ignore-missing-imports [paths]
mypy.ini
:strict_optional = False
The text was updated successfully, but these errors were encountered: