Description
Bug Report
mypy produces a set of var-annotated
errors when running with --cache-fine-grained
that it does not when run plainly. As far as I can tell, mypy's documentation doesn't indicate that there should be any difference in the set of errors returned between the two caching modes.
I came across this because I noticed that despite mypy .
returning no errors when run at the command line, VSCode was highlighting these var-annotated
errors, which seem real enough. Eventually, I figured out that VSCode is using dmypy
in the background, which uses the fine-grained cache and I was able to reproduce the errors by using --cache-fine-grained
at the command line.
To Reproduce
- Create a file
main.py
:
foo = None
- Run
mypy main.py
- Run
mypy --cache-fine-grained main.py
Expected Behavior
The output of steps 2 and 3 are the same.
Actual Behavior
Step 2 output:
% mypy main.py
Success: no issues found in 1 source file
Step 3 output:
% mypy --cache-fine-grained main.py
main.py:1: error: Need type annotation for "foo" (hint: "foo: <type> | None = ...") [var-annotated]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.991, 1.0.0, 1.0.1
- Mypy command-line flags: See above
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.9, 3.10