1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
-- Type checker test cases dealing with module lookup edge cases
-- to ensure that --fast-module-lookup matches regular lookup behavior
[case testModuleLookup]
# flags: --fast-module-lookup
import m
reveal_type(m.a) # N: Revealed type is "m.A"
[file m.py]
class A: pass
a = A()
[case testModuleLookupStub]
# flags: --fast-module-lookup
import m
reveal_type(m.a) # N: Revealed type is "m.A"
[file m.pyi]
class A: pass
a = A()
[case testModuleLookupFromImport]
# flags: --fast-module-lookup
from m import a
reveal_type(a) # N: Revealed type is "m.A"
[file m.py]
class A: pass
a = A()
[case testModuleLookupStubFromImport]
# flags: --fast-module-lookup
from m import a
reveal_type(a) # N: Revealed type is "m.A"
[file m.pyi]
class A: pass
a = A()
[case testModuleLookupWeird]
# flags: --fast-module-lookup
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]
# flags: --fast-module-lookup
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]
# flags: --fast-module-lookup
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]
# flags: --fast-module-lookup
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]
# flags: --fast-module-lookup
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]
# flags: --fast-module-lookup
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()
|