Skip to content

Commit

Permalink
Fix a fixup bug for nested class references.
Browse files Browse the repository at this point in the history
This has plagued me for weeks, but I could not repro it until now.
  • Loading branch information
Guido van Rossum committed Sep 28, 2016
1 parent 5f0d02c commit bec9454
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def lookup_qualified_stnode(modules: Dict[str, MypyFile], name: str) -> SymbolTa
while True:
assert '.' in head, "Cannot find %s" % (name,)
head, tail = head.rsplit('.', 1)
rest.append(tail)
mod = modules.get(head)
if mod is not None:
rest.append(tail)
break
names = mod.names
while True:
Expand Down
25 changes: 25 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -1590,3 +1590,28 @@ pass
[rechecked a, a.c]
[stale a, a.c]
[out]

[case testIncrementalNestedClassRef]
import top

[file top.py]
from funcs import callee
from classes import Outer
def caller(a: Outer.Inner) -> None:
callee(a)

[file funcs.py]
from classes import Outer
def callee(a: Outer.Inner) -> None:
pass

[file classes.py]
class Outer:
class Inner:
pass

[file top.py.next]
from funcs import callee
from classes import Outer
def caller(a: Outer.Inner) -> int:
callee(a)

0 comments on commit bec9454

Please sign in to comment.