File: pep561.test

package info (click to toggle)
mypy 1.19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,412 kB
  • sloc: python: 114,754; ansic: 13,343; cpp: 11,380; makefile: 257; sh: 28
file content (235 lines) | stat: -rw-r--r-- 7,821 bytes parent folder | download
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
[case testTypedPkgNoSitePkgsIgnoredImports]
# pkgs: typedpkg
# flags: --no-site-packages
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[file mypy.ini]
\[mypy]
ignore_missing_imports = True
[out]
testTypedPkgNoSitePkgsIgnoredImports.py:6: note: Revealed type is "Any"

[case testTypedPkgSimple]
# pkgs: typedpkg
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[out]
testTypedPkgSimple.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]"

[case testTypedPkgSimplePackageSearchPath]
# pkgs: typedpkg
# flags: -p typedpkg.pkg
[out]

[case testTypedPkg_config_nositepackages]
# pkgs: typedpkg
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[file mypy.ini]
\[mypy]
no_site_packages=True
[out]
testTypedPkg_config_nositepackages.py:2: error: Cannot find implementation or library stub for module named "typedpkg.sample"
testTypedPkg_config_nositepackages.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
testTypedPkg_config_nositepackages.py:3: error: Cannot find implementation or library stub for module named "typedpkg"
testTypedPkg_config_nositepackages.py:5: note: Revealed type is "Any"

[case testTypedPkg_args_nositepackages]
# pkgs: typedpkg
# flags: --no-site-packages
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[out]
testTypedPkg_args_nositepackages.py:3: error: Cannot find implementation or library stub for module named "typedpkg.sample"
testTypedPkg_args_nositepackages.py:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
testTypedPkg_args_nositepackages.py:4: error: Cannot find implementation or library stub for module named "typedpkg"
testTypedPkg_args_nositepackages.py:6: note: Revealed type is "Any"

[case testTypedPkgStubs]
# pkgs: typedpkg-stubs
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[out]
testTypedPkgStubs.py:3: error: Module "typedpkg" has no attribute "dne"
testTypedPkgStubs.py:5: note: Revealed type is "builtins.list[builtins.str]"

[case testStubPrecedence]
# pkgs: typedpkg, typedpkg-stubs
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[out]
testStubPrecedence.py:5: note: Revealed type is "builtins.list[builtins.str]"

[case testTypedPkgSimpleEditable]
# pkgs: typedpkg; editable
from typedpkg.sample import ex
from typedpkg import dne
a = ex([''])
reveal_type(a)
[out]
testTypedPkgSimpleEditable.py:5: note: Revealed type is "builtins.tuple[builtins.str, ...]"

[case testTypedPkgNamespaceImportFrom]
# pkgs: typedpkg, typedpkg_ns_a
from typedpkg.pkg.aaa import af
from typedpkg_ns.a.bbb import bf
from typedpkg_ns.a.dne import dne

af("abc")
bf(False)
dne(123)

af(False)
bf(2)
dne("abc")
[out]
testTypedPkgNamespaceImportFrom.py:4: error: Cannot find implementation or library stub for module named "typedpkg_ns.a.dne"
testTypedPkgNamespaceImportFrom.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
testTypedPkgNamespaceImportFrom.py:10: error: Argument 1 to "af" has incompatible type "bool"; expected "str"
testTypedPkgNamespaceImportFrom.py:11: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"

[case testTypedPkgNamespaceImportAs]
# pkgs: typedpkg, typedpkg_ns_a
import typedpkg.pkg.aaa as nm; af = nm.af
import typedpkg_ns.a.bbb as am; bf = am.bf
from typedpkg_ns.a.dne import dne

af("abc")
bf(False)
dne(123)

af(False)
bf(2)
dne("abc")
[out]
testTypedPkgNamespaceImportAs.py:4: error: Cannot find implementation or library stub for module named "typedpkg_ns.a.dne"
testTypedPkgNamespaceImportAs.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
testTypedPkgNamespaceImportAs.py:10: error: Argument 1 has incompatible type "bool"; expected "str"
testTypedPkgNamespaceImportAs.py:11: error: Argument 1 has incompatible type "int"; expected "bool"

[case testTypedPkgNamespaceRegImport]
# pkgs: typedpkg, typedpkg_ns_a
import typedpkg.pkg.aaa; af = typedpkg.pkg.aaa.af
import typedpkg_ns.a.bbb; bf = typedpkg_ns.a.bbb.bf
from typedpkg_ns.a.dne import dne

af("abc")
bf(False)
dne(123)

af(False)
bf(2)
dne("abc")

[out]
testTypedPkgNamespaceRegImport.py:4: error: Cannot find implementation or library stub for module named "typedpkg_ns.a.dne"
testTypedPkgNamespaceRegImport.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
testTypedPkgNamespaceRegImport.py:10: error: Argument 1 has incompatible type "bool"; expected "str"
testTypedPkgNamespaceRegImport.py:11: error: Argument 1 has incompatible type "int"; expected "bool"

-- This is really testing the test framework to make sure incremental works
[case testPep561TestIncremental]
# pkgs: typedpkg
import a
[file a.py]
[file a.py.2]
1 + 'no'
[out]
[out2]
a.py:1: error: Unsupported operand types for + ("int" and "str")

[case testTypedPkgNamespaceRegFromImportTwice]
# pkgs: typedpkg_ns_a
from typedpkg_ns import a
-- dummy should trigger a second iteration
[file dummy.py.2]
[out]
[out2]

[case testNamespacePkgWStubs]
# pkgs: typedpkg_ns_a, typedpkg_ns_b, typedpkg_ns_b-stubs
# flags: --no-namespace-packages
import typedpkg_ns.a.bbb as a
import typedpkg_ns.b.bbb as b
a.bf(False)
b.bf(False)
a.bf(1)
b.bf(1)
import typedpkg_ns.whatever as c  # type: ignore[import-untyped]
[out]
testNamespacePkgWStubs.py:4: error: Skipping analyzing "typedpkg_ns.b.bbb": module is installed, but missing library stubs or py.typed marker
testNamespacePkgWStubs.py:4: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
testNamespacePkgWStubs.py:4: error: Skipping analyzing "typedpkg_ns.b": module is installed, but missing library stubs or py.typed marker
testNamespacePkgWStubs.py:7: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"

[case testNamespacePkgWStubsWithNamespacePackagesFlag]
# pkgs: typedpkg_ns_a, typedpkg_ns_b, typedpkg_ns_b-stubs
# flags: --namespace-packages
import typedpkg_ns.a.bbb as a
import typedpkg_ns.b.bbb as b
a.bf(False)
b.bf(False)
a.bf(1)
b.bf(1)
[out]
testNamespacePkgWStubsWithNamespacePackagesFlag.py:7: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"
testNamespacePkgWStubsWithNamespacePackagesFlag.py:8: error: Argument 1 to "bf" has incompatible type "int"; expected "bool"

[case testMissingPytypedFlag]
# pkgs: typedpkg_ns_b
# flags: --namespace-packages --follow-untyped-imports
import typedpkg_ns.b.bbb as b
b.bf("foo", "bar")
[out]
testMissingPytypedFlag.py:4: error: Too many arguments for "bf"

[case testTypedPkgNamespaceRegFromImportTwiceMissing]
# pkgs: typedpkg_ns_a
from typedpkg_ns import does_not_exist  # type: ignore
from typedpkg_ns import a
-- dummy should trigger a second iteration
[file dummy.py.2]
[out]
[out2]


[case testTypedPkgNamespaceRegFromImportTwiceMissing2]
# pkgs: typedpkg_ns_a
from typedpkg_ns import does_not_exist  # type: ignore
from typedpkg_ns.a.bbb import bf
-- dummy should trigger a second iteration
[file dummy.py.2]
[out]
[out2]

[case testTypedNamespaceSubpackage]
# pkgs: typedpkg_ns_nested
import our
[file our/__init__.py]
import our.bar
import our.foo
[file our/bar.py]
from typedpkg_ns.b import Something
[file our/foo.py]
import typedpkg_ns.a

[file dummy.py.2]

[out]
our/bar.py:1: error: Skipping analyzing "typedpkg_ns.b": module is installed, but missing library stubs or py.typed marker
our/bar.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
[out2]
our/bar.py:1: error: Skipping analyzing "typedpkg_ns.b": module is installed, but missing library stubs or py.typed marker
our/bar.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports