Open Renegatto opened 4 years ago
If any part of this is wrong, it is that part 1 doesn't result in an error. The type of foo
there gets refined to def (x: Any) -> Any
, which seems wrong to me, since we mostly don't do that with other types?
Our exact behaviors regarding Any
and type refinement are sort of unclear and pretty heuristic
@JukkaL thoughts?
The way type refinement works is inconsistent. Deciding what's the best fix is non-trivial however, since we don't want generate too many new false positives or negatives.
A bugreport, mypy version is 0.761, python version is 3.7.3
This is a case where expected incapatible types, because i declared that foo's input type is float, and attempting to call it with str, but typechecking passed successful.
mypy this_file.py
Mypy's output:A case with type annotation written with assignment wont give false positive result:
mypy this_file.py
Mypy's output:I wasnt found other cases excluding cases with Callable type.
For example with Tuples type anntoation written apart of assignment all working fine:
mypy this_file.py
Mypy's output: