Skip to content

Fix imports being unsilenced when checking stale SCCs #2037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Michael0x2a
Copy link
Collaborator

This pull request fixes an edge case where previously silenced imports were being un-silenced when using silent imports with incremental mode.

Unfortunately, I wasn't able to provide a test case because this problem seems to manifest mainly in larger code bases (with import cycles?) that are hard to simplify and after running incremental mode at least 3 times -- our test suite can currently handle only three. See #2036 for more details about the bug.

The problem ended up being with the order in which the parse_file(...) and load_graph(...) functions are called -- the former function will mark imports with the # type: ignore directives as suppressed and the latter function corrects the dependencies computed by parse_file and will mark silenced modules as suppressed.

The problem is that when running mypy with a cold cache, the parse_file function will be executed at the start of the load_graph function, but when checking a stale SCC, the logic will end up making parse_file be executed after the load_graph function.

This is problematic since parse_file will potentially clobber over the (often correct) information regarding suppressed and unsuppressed dependencies that was loaded from the old cache files.

This fix adds an extra pass over the dependencies after calling parse_file when checking stale SCCs to correct the clobbering.

This commit fixes a bug where silenced imports were being unsilenced
after incremental mode + silent_imports was run several times after
forcing an SCC to be rechecked.
@gvanrossum gvanrossum merged commit c3fa852 into python:master Aug 18, 2016
@gvanrossum
Copy link
Member

Whee! Don't worry about writing that test for now.

@Michael0x2a Michael0x2a deleted the fix-silent-imports-ignored-on-stale-recheck branch August 18, 2016 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants