Skip to content

Fix qualified_name for methods #2453

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
Nov 15, 2016
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
6 changes: 5 additions & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,11 @@ def lookup_fully_qualified_or_none(self, name: str) -> Optional[SymbolTableNode]
return n.names.get(parts[-1])

def qualified_name(self, n: str) -> str:
return self.cur_mod_id + '.' + n
if self.type is not None:
base = self.type._fullname
else:
base = self.cur_mod_id
return base + '.' + n

def enter(self) -> None:
self.locals.append(SymbolTable())
Expand Down
33 changes: 25 additions & 8 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ a = produce()
accept_int(a.foo())

[file mod2/__init__.py]
from mod2.mod3 import CustomType
from mod2.mod3 import CustomType

[file mod2/mod3/__init__.py]
from mod2.mod3.mod4 import CustomType
Expand Down Expand Up @@ -407,13 +407,13 @@ tmp/mod1.py:6: error: Argument 1 to "accept_int" has incompatible type "str"; ex
import mod1, mod2.mod3.mod5

[file mod1.py]
from mod2 import produce
from mod2 import produce
def accept_int(x: int) -> None: pass
a = produce()
accept_int(a.foo())

[file mod2/__init__.py]
from mod2.mod3 import produce
from mod2.mod3 import produce

[file mod2/mod3/__init__.py]
from mod2.mod3.mod4 import CustomType
Expand Down Expand Up @@ -548,7 +548,7 @@ def func2() -> str:
[out2]

[case testIncrementalWithComplexDictExpression]
import mod1
import mod1

[file mod1.py]
import mod1_private
Expand All @@ -570,7 +570,7 @@ my_dict = {
[builtins fixtures/dict.pyi]

[case testIncrementalWithComplexConstantExpressionNoAnnotation]
import mod1
import mod1

[file mod1.py]
import mod1_private
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def foo(a: str) -> None: pass

[file client.py]
import good
import bad
import bad
from good import foo
foo(3)

Expand Down Expand Up @@ -1537,12 +1537,12 @@ tmp/foo.py:3: error: Argument 1 to "accept_int" has incompatible type "str"; exp
import foo

[file foo.py]
from mid import Outer
from mid import Outer
def accept_int(x: int) -> None: pass
accept_int(Outer.MyTuple(1, "b", "c").a)

[file mid.py]
from bar import Outer
from bar import Outer

[file bar.py]
from typing import NamedTuple
Expand Down Expand Up @@ -1634,3 +1634,20 @@ a = None # type: R
from . import m
R = m.R
a = None # type: R

[case testIncrementalBaseClassAttributeConflict]
class A: pass
class B: pass

class X:
attr = None # type: A
class Y:
attr = None # type: B
class Z(X, Y): pass
[stale]
[out]
main: note: In class "Z":
main:8: error: Definition of "attr" in base class "X" is incompatible with definition in base class "Y"
[out2]
main: note: In class "Z":
main:8: error: Definition of "attr" in base class "X" is incompatible with definition in base class "Y"