Debian Codegraph @

test-data/unit/pep561.test

raw
1 [case testTypedPkgNoSitePkgsIgnoredImports]
2 # pkgs: typedpkg
3 # flags: --no-site-packages
4 from typedpkg.sample import ex
5 from typedpkg import dne
6 a = ex([''])
7 reveal_type(a)
8 [file mypy.ini]
9 \[mypy]
10 ignore_missing_imports = True
11 [out]
12 testTypedPkgNoSitePkgsIgnoredImports.py:6: note: Revealed type is "Any"
13
14 [case testTypedPkgSimple]
15 # pkgs: typedpkg
16 from typedpkg.sample import ex
17 from typedpkg import dne
18 a = ex([''])
19 reveal_type(a)
20 [out]
21 testTypedPkgSimple.py:5: note: Revealed type is "tuple[str, ...]"
22
23 [case testTypedPkgSimplePackageSearchPath]
24 # pkgs: typedpkg
25 # flags: -p typedpkg.pkg
26 [out]
27
28 [case testTypedPkg_config_nositepackages]
29 # pkgs: typedpkg
30 from typedpkg.sample import ex
31 from typedpkg import dne
32 a = ex([''])
33 reveal_type(a)
34 [file mypy.ini]
35 \[mypy]
36 no_site_packages=True
37 [out]
38 testTypedPkg_config_nositepackages.py:2: error: Cannot find implementation or library stub for module named "typedpkg.sample"
39 testTypedPkg_config_nositepackages.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
40 testTypedPkg_config_nositepackages.py:3: error: Cannot find implementation or library stub for module named "typedpkg"
41 testTypedPkg_config_nositepackages.py:5: note: Revealed type is "Any"
42
43 [case testTypedPkg_args_nositepackages]
44 # pkgs: typedpkg
45 # flags: --no-site-packages
46 from typedpkg.sample import ex
47 from typedpkg import dne
48 a = ex([''])
49 reveal_type(a)
50 [out]
51 testTypedPkg_args_nositepackages.py:3: error: Cannot find implementation or library stub for module named "typedpkg.sample"
52 testTypedPkg_args_nositepackages.py:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
53 testTypedPkg_args_nositepackages.py:4: error: Cannot find implementation or library stub for module named "typedpkg"
54 testTypedPkg_args_nositepackages.py:6: note: Revealed type is "Any"
55
56 [case testTypedPkgStubs]
57 # pkgs: typedpkg-stubs
58 from typedpkg.sample import ex
59 from typedpkg import dne
60 a = ex([''])
61 reveal_type(a)
62 [out]
63 testTypedPkgStubs.py:3: error: Module "typedpkg" has no attribute "dne"
64 testTypedPkgStubs.py:5: note: Revealed type is "list[str]"
65
66 [case testStubPrecedence]
67 # pkgs: typedpkg, typedpkg-stubs
68 from typedpkg.sample import ex
69 from typedpkg import dne
70 a = ex([''])
71 reveal_type(a)
72 [out]
73 testStubPrecedence.py:5: note: Revealed type is "list[str]"
74
75 [case testTypedPkgSimpleEditable]
76 # pkgs: typedpkg; editable
77 from typedpkg.sample import ex
78 from typedpkg import dne
79 a = ex([''])
80 reveal_type(a)
81 [out]
82 testTypedPkgSimpleEditable.py:5: note: Revealed type is "tuple[str, ...]"
83
84 [case testTypedPkgNamespaceImportFrom]
85 # pkgs: typedpkg, typedpkg_ns_a
86 from typedpkg.pkg.aaa import af
87 from typedpkg_ns.a.bbb import bf
88 from typedpkg_ns.a.dne import dne
89
90 af("abc")
91 bf(False)
92 dne(123)
93
94 af(False)
95 bf(2)
96 dne("abc")
97 [out]
98 testTypedPkgNamespaceImportFrom.py:4: error: Cannot find implementation or library stub for module named "typedpkg_ns.a.dne"
99 testTypedPkgNamespaceImportFrom.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
100 testTypedPkgNamespaceImportFrom.py:10: error: Argument 1 to "af" has incompatible type "bool"; expected "str"
101 testTypedPkgNamespaceImportFrom.py:11: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"
102
103 [case testTypedPkgNamespaceImportAs]
104 # pkgs: typedpkg, typedpkg_ns_a
105 import typedpkg.pkg.aaa as nm; af = nm.af
106 import typedpkg_ns.a.bbb as am; bf = am.bf
107 from typedpkg_ns.a.dne import dne
108
109 af("abc")
110 bf(False)
111 dne(123)
112
113 af(False)
114 bf(2)
115 dne("abc")
116 [out]
117 testTypedPkgNamespaceImportAs.py:4: error: Cannot find implementation or library stub for module named "typedpkg_ns.a.dne"
118 testTypedPkgNamespaceImportAs.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
119 testTypedPkgNamespaceImportAs.py:10: error: Argument 1 has incompatible type "bool"; expected "str"
120 testTypedPkgNamespaceImportAs.py:11: error: Argument 1 has incompatible type "int"; expected "bool"
121
122 [case testTypedPkgNamespaceRegImport]
123 # pkgs: typedpkg, typedpkg_ns_a
124 import typedpkg.pkg.aaa; af = typedpkg.pkg.aaa.af
125 import typedpkg_ns.a.bbb; bf = typedpkg_ns.a.bbb.bf
126 from typedpkg_ns.a.dne import dne
127
128 af("abc")
129 bf(False)
130 dne(123)
131
132 af(False)
133 bf(2)
134 dne("abc")
135
136 [out]
137 testTypedPkgNamespaceRegImport.py:4: error: Cannot find implementation or library stub for module named "typedpkg_ns.a.dne"
138 testTypedPkgNamespaceRegImport.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
139 testTypedPkgNamespaceRegImport.py:10: error: Argument 1 has incompatible type "bool"; expected "str"
140 testTypedPkgNamespaceRegImport.py:11: error: Argument 1 has incompatible type "int"; expected "bool"
141
142 -- This is really testing the test framework to make sure incremental works
143 [case testPep561TestIncremental]
144 # pkgs: typedpkg
145 import a
146 [file a.py]
147 [file a.py.2]
148 1 + 'no'
149 [out]
150 [out2]
151 a.py:1: error: Unsupported operand types for + ("int" and "str")
152
153 [case testTypedPkgNamespaceRegFromImportTwice]
154 # pkgs: typedpkg_ns_a
155 from typedpkg_ns import a
156 -- dummy should trigger a second iteration
157 [file dummy.py.2]
158 [out]
159 [out2]
160
161 [case testNamespacePkgWStubs]
162 # pkgs: typedpkg_ns_a, typedpkg_ns_b, typedpkg_ns_b-stubs
163 # flags: --no-namespace-packages
164 import typedpkg_ns.a.bbb as a
165 import typedpkg_ns.b.bbb as b
166 a.bf(False)
167 b.bf(False)
168 a.bf(1)
169 b.bf(1)
170 import typedpkg_ns.whatever as c # type: ignore[import-untyped]
171 [out]
172 testNamespacePkgWStubs.py:4: error: Skipping analyzing "typedpkg_ns.b.bbb": module is installed, but missing library stubs or py.typed marker
173 testNamespacePkgWStubs.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
174 testNamespacePkgWStubs.py:4: error: Skipping analyzing "typedpkg_ns.b": module is installed, but missing library stubs or py.typed marker
175 testNamespacePkgWStubs.py:7: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"
176
177 [case testNamespacePkgWStubsWithNamespacePackagesFlag]
178 # pkgs: typedpkg_ns_a, typedpkg_ns_b, typedpkg_ns_b-stubs
179 # flags: --namespace-packages
180 import typedpkg_ns.a.bbb as a
181 import typedpkg_ns.b.bbb as b
182 a.bf(False)
183 b.bf(False)
184 a.bf(1)
185 b.bf(1)
186 [out]
187 testNamespacePkgWStubsWithNamespacePackagesFlag.py:7: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"
188 testNamespacePkgWStubsWithNamespacePackagesFlag.py:8: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"
189
190 [case testMissingPytypedFlag]
191 # pkgs: typedpkg_ns_b
192 # flags: --namespace-packages --follow-untyped-imports
193 import typedpkg_ns.b.bbb as b
194 b.bf("foo", "bar")
195 [out]
196 testMissingPytypedFlag.py:4: error: Too many arguments for "bf"
197
198 [case testTypedPkgNamespaceRegFromImportTwiceMissing]
199 # pkgs: typedpkg_ns_a
200 from typedpkg_ns import does_not_exist # type: ignore
201 from typedpkg_ns import a
202 -- dummy should trigger a second iteration
203 [file dummy.py.2]
204 [out]
205 [out2]
206
207
208 [case testTypedPkgNamespaceRegFromImportTwiceMissing2]
209 # pkgs: typedpkg_ns_a
210 from typedpkg_ns import does_not_exist # type: ignore
211 from typedpkg_ns.a.bbb import bf
212 -- dummy should trigger a second iteration
213 [file dummy.py.2]
214 [out]
215 [out2]
216
217 [case testTypedNamespaceSubpackage]
218 # pkgs: typedpkg_ns_nested
219 import our
220 [file our/__init__.py]
221 import our.bar
222 import our.foo
223 [file our/bar.py]
224 from typedpkg_ns.b import Something
225 [file our/foo.py]
226 import typedpkg_ns.a
227
228 [file dummy.py.2]
229
230 [out]
231 our/bar.py:1: error: Skipping analyzing "typedpkg_ns.b": module is installed, but missing library stubs or py.typed marker
232 our/bar.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
233 [out2]
234 our/bar.py:1: error: Skipping analyzing "typedpkg_ns.b": module is installed, but missing library stubs or py.typed marker
235 our/bar.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
236
237 [case testPartiallyTypedNamespacePackageNoCrash]
238 # pkgs: typedpkg_ns_nested
239 import a
240 [file a.py]
241 import m1
242 import m2
243 [file a.py.2]
244 import m1
245 [file m1.py]
246 import typedpkg_ns.b # type: ignore
247 [file m2.py]
248 import typedpkg_ns.a
249 [out]
250 [out2]