Skip to content

Mypy does not recheck files when follow_imports changes for dependencies #7777

Description

@nickgaya

Steps to reproduce

  1. Create module test.py with import from nonexistent module:
from foo import bar
  1. Create mypy.ini file:
[mypy]

[mypy-foo]
ignore_missing_imports = True 
  1. Run mypy
$ mypy test.py 
Success: no issues found in 1 source file
  1. Comment out [mypy-foo] section in mypy.ini
[mypy]

# [mypy-foo]
# ignore_missing_imports = True 
  1. Run mypy
$ mypy test.py 
Success: no issues found in 1 source file

Expected result

After step 4, mypy should detect config change and (partially?) invalidate cache, leading to a type error.

$ mypy test.py 
test.py:1: error: Cannot find module named 'foo'
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

Notes

  • Deleting .mypy_cache/ and re-running mypy fixes the issue.
  • Adding/removing ignore_missing_imports in the main [mypy] section does seem to invalidate the cache as expected. So this issue only seems to apply to [mypy-PATTERN] sections.

Versions

$ python --version
Python 3.7.3
$ mypy --version
mypy 0.740

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions