Incompatible Assignment of None to DataFrame in Function not Caught #18492
Labels
bug
mypy got something wrong
good-second-issue
topic-type-narrowing
Conditional type narrowing / binder
Bug Report
In a function,
mypy
fails to detect an incompatible assignment in a function, if that is after a__get_item__
access inside a branch. Weirdly,mypy
correctly deduces the types, as shown withreveal_type
but does not complain about the incorrect assignment anyways.To Reproduce
I would have liked to give a playground link, but the MWE involves a
pandas.DataFrame
which seems not to work on the playground.Expected Behavior
Each block and function should contain a
mypy
error regarding an incompatible assignment.Actual Behavior
For the last function, no such error is produced:
Your Environment
pyproject.toml
:The text was updated successfully, but these errors were encountered: