Skip to content

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