-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve test coverage and documentation
- Loading branch information
1 parent
55eb815
commit 3e128fa
Showing
5 changed files
with
173 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
-- Type checker test cases dealing with module lookup edge cases | ||
-- to ensure that --fast-module-lookup matches regular lookup behavior | ||
|
||
[case testModuleLookup] | ||
import m | ||
reveal_type(m.a) # N: Revealed type is "m.A" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
|
||
[case testModuleLookupStub] | ||
import m | ||
reveal_type(m.a) # N: Revealed type is "m.A" | ||
|
||
[file m.pyi] | ||
class A: pass | ||
a = A() | ||
|
||
[case testModuleLookupFromImport] | ||
from m import a | ||
reveal_type(a) # N: Revealed type is "m.A" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
|
||
[case testModuleLookupStubFromImport] | ||
from m import a | ||
reveal_type(a) # N: Revealed type is "m.A" | ||
|
||
[file m.pyi] | ||
class A: pass | ||
a = A() | ||
|
||
|
||
[case testModuleLookupWeird] | ||
from m import a | ||
reveal_type(a) # N: Revealed type is "builtins.object" | ||
reveal_type(a.b) # N: Revealed type is "m.a.B" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
|
||
[file m/__init__.py] | ||
[file m/a.py] | ||
class B: pass | ||
b = B() | ||
|
||
|
||
[case testModuleLookupWeird2] | ||
from m.a import b | ||
reveal_type(b) # N: Revealed type is "m.a.B" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
|
||
[file m/__init__.py] | ||
[file m/a.py] | ||
class B: pass | ||
b = B() | ||
|
||
|
||
[case testModuleLookupWeird3] | ||
from m.a import b | ||
reveal_type(b) # N: Revealed type is "m.a.B" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
[file m/__init__.py] | ||
class B: pass | ||
a = B() | ||
[file m/a.py] | ||
class B: pass | ||
b = B() | ||
|
||
|
||
[case testModuleLookupWeird4] | ||
import m.a | ||
m.a.b # E: "str" has no attribute "b" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
[file m/__init__.py] | ||
class B: pass | ||
a = 'foo' | ||
b = B() | ||
[file m/a.py] | ||
class C: pass | ||
b = C() | ||
|
||
|
||
[case testModuleLookupWeird5] | ||
import m.a as ma | ||
reveal_type(ma.b) # N: Revealed type is "m.a.C" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
[file m/__init__.py] | ||
class B: pass | ||
a = 'foo' | ||
b = B() | ||
[file m/a.py] | ||
class C: pass | ||
b = C() | ||
|
||
|
||
[case testModuleLookupWeird6] | ||
from m.a import b | ||
reveal_type(b) # N: Revealed type is "m.a.C" | ||
|
||
[file m.py] | ||
class A: pass | ||
a = A() | ||
[file m/__init__.py] | ||
class B: pass | ||
a = 'foo' | ||
b = B() | ||
[file m/a.py] | ||
class C: pass | ||
b = C() |