Skip to content

Fix crash in --quick mode when aliases are re-exported #3740

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

Merged
merged 1 commit into from
Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypy/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def visit_symbol_table(self, symtab: SymbolTable) -> None:
if stnode is not None:
value.node = stnode.node
value.type_override = stnode.type_override
if (self.quick_and_dirty and value.kind == TYPE_ALIAS and
stnode.type_override is None):
value.type_override = Instance(stale_info(), [])
value.alias_tvars = stnode.alias_tvars or []
elif not self.quick_and_dirty:
assert stnode is not None, "Could not find cross-ref %s" % (cross_ref,)
Expand Down
23 changes: 23 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,29 @@ b.x.y
tmp/c.py:2: error: Revealed type is '<stale cache: consider running mypy without --quick>'
tmp/c.py:5: error: "<stale cache: consider running mypy without --quick>" has no attribute "y"

[case testNoCrashOnDoubleImportAliasQuick]
# cmd: mypy -m e
# cmd2: mypy -m c
# cmd3: mypy -m e
# flags: --quick
[file c.py]
from typing import List
Alias = List[int]
[file c.py.2]
from typing import List
Alias = int

[file d.py]
from c import Alias

[file e.py]
from d import Alias
[file e.py.3]
from d import Alias
x: Alias
[out3]
[builtins fixtures/list.pyi]

[case testSerializeAbstractPropertyIncremental]
from abc import abstractmethod
import typing
Expand Down