Skip to content

--follow-imports=skip is broken in incremental mode when modules are not in root sources #20800

@ilevkivskyi

Description

@ilevkivskyi

These two (very basic) test cases fail (these test that --follow-imports=skip does not imply --ignore-missing-imports):

[case testAddedMissingModuleSkip]
# flags: --follow-imports=skip
import mod
[file mod.py.2]
[out]
main:2: error: Cannot find implementation or library stub for module named "mod"
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
[out2]

[case testDeletedModuleSkip]
# flags: --follow-imports=skip
import mod
[file mod.py]
[delete mod.py.2]
[out]
[out2]
main:2: error: Cannot find implementation or library stub for module named "mod"
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

In general, we have very few test cases for --follow-imports=skip when modules are not on command line. In this case the problem is that in both cases main is considered fresh, because mod is still suppressed, and the import options for mod are unchanged. But suppression reason is different (intentionally skipped vs actually missing). I think this may be fixed by adding suppression reason to suppressed_deps_opts() hash.

Btw we may want to micro-optimize that one as well for large code bases that use --follow-imports=skip, LOL. I can do this while fixing this issue cc @JukkaL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions