@@ -20,38 +20,38 @@ def g(arg): ...
20
20
def f(a, b=2): ...
21
21
def g(b=-1, c=0): ...
22
22
[out]
23
- def f(a, b=2 ): ...
24
- def g(b=-1 , c=0 ): ...
23
+ def f(a, b: int = ... ): ...
24
+ def g(b: int = ... , c: int = ... ): ...
25
25
26
26
[case testDefaultArgNone]
27
27
def f(x=None): ...
28
28
[out]
29
- def f(x=None ): ...
29
+ def f(x: Optional[Any] = ... ): ...
30
30
31
31
[case testDefaultArgBool]
32
32
def f(x=True, y=False): ...
33
33
[out]
34
- def f(x=True , y=False ): ...
34
+ def f(x: bool = ... , y: bool = ... ): ...
35
35
36
36
[case testDefaultArgStr]
37
37
def f(x='foo'): ...
38
38
[out]
39
- def f(x='' ): ...
39
+ def f(x: str = ... ): ...
40
40
41
41
[case testDefaultArgBytes]
42
42
def f(x=b'foo'): ...
43
43
[out]
44
- def f(x=b'' ): ...
44
+ def f(x: bytes = ... ): ...
45
45
46
46
[case testDefaultArgFloat]
47
47
def f(x=1.2): ...
48
48
[out]
49
- def f(x=0.0 ): ...
49
+ def f(x: float = ... ): ...
50
50
51
51
[case testDefaultArgOther]
52
52
def f(x=ord): ...
53
53
[out]
54
- def f(x= ...): ...
54
+ def f(x: Any = ...): ...
55
55
56
56
[case testVarArgs]
57
57
def f(x, *y): ...
@@ -77,38 +77,30 @@ def g(): ...
77
77
[case testVariable]
78
78
x = 1
79
79
[out]
80
- from typing import Any
81
-
82
- x = ... # type: Any
80
+ x = ... # type: int
83
81
84
82
[case testMultipleVariable]
85
83
x = y = 1
86
84
[out]
87
- from typing import Any
88
-
89
- x = ... # type: Any
90
- y = ... # type: Any
85
+ x = ... # type: int
86
+ y = ... # type: int
91
87
92
88
[case testClassVariable]
93
89
class C:
94
90
x = 1
95
91
[out]
96
- from typing import Any
97
-
98
92
class C:
99
- x = ... # type: Any
93
+ x = ... # type: int
100
94
101
95
[case testSelfAssignment]
102
96
class C:
103
97
def __init__(self):
104
98
self.x = 1
105
99
x.y = 2
106
100
[out]
107
- from typing import Any
108
-
109
101
class C:
110
- x = ... # type: Any
111
- def __init__(self): ...
102
+ x = ... # type: int
103
+ def __init__(self) -> None : ...
112
104
113
105
[case testSelfAndClassBodyAssignment]
114
106
x = 1
@@ -118,13 +110,11 @@ class C:
118
110
self.x = 1
119
111
self.x = 1
120
112
[out]
121
- from typing import Any
122
-
123
- x = ... # type: Any
113
+ x = ... # type: int
124
114
125
115
class C:
126
- x = ... # type: Any
127
- def __init__(self): ...
116
+ x = ... # type: int
117
+ def __init__(self) -> None : ...
128
118
129
119
[case testEmptyClass]
130
120
class A: ...
@@ -172,25 +162,21 @@ def foo(x): ...
172
162
[case testMultipleAssignment]
173
163
x, y = 1, 2
174
164
[out]
175
- from typing import Any
176
-
177
- x = ... # type: Any
178
- y = ... # type: Any
165
+ x = ... # type: int
166
+ y = ... # type: int
179
167
180
168
[case testMultipleAssignment2]
181
169
[x, y] = 1, 2
182
170
[out]
183
- from typing import Any
184
-
185
- x = ... # type: Any
186
- y = ... # type: Any
171
+ x = ... # type: int
172
+ y = ... # type: int
187
173
188
174
[case testKeywordOnlyArg]
189
175
def f(x, *, y=1): ...
190
176
def g(x, *, y=1, z=2): ...
191
177
[out]
192
- def f(x, *, y=1 ): ...
193
- def g(x, *, y=1 , z=2 ): ...
178
+ def f(x, *, y: int = ... ): ...
179
+ def g(x, *, y: int = ... , z: int = ... ): ...
194
180
195
181
[case testProperty]
196
182
class A:
@@ -311,10 +297,8 @@ class A:
311
297
x = 1
312
298
def f(self): ...
313
299
[out]
314
- from typing import Any
315
-
316
300
class A:
317
- x = ... # type: Any
301
+ x = ... # type: int
318
302
def f(self): ...
319
303
320
304
[case testMultiplePrivateDefs]
@@ -332,32 +316,29 @@ from re import match, search, sub
332
316
__all__ = ['match', 'sub', 'x']
333
317
x = 1
334
318
[out]
335
- from typing import Any
336
319
from re import match as match, sub as sub
337
320
338
- x = ... # type: Any
321
+ x = ... # type: int
339
322
340
323
[case testExportModule_import]
341
324
import re
342
325
__all__ = ['re', 'x']
343
326
x = 1
344
327
y = 2
345
328
[out]
346
- from typing import Any
347
329
import re as re
348
330
349
- x = ... # type: Any
331
+ x = ... # type: int
350
332
351
333
[case testExportModuleAs_import]
352
334
import re as rex
353
335
__all__ = ['rex', 'x']
354
336
x = 1
355
337
y = 2
356
338
[out]
357
- from typing import Any
358
339
import re as rex
359
340
360
- x = ... # type: Any
341
+ x = ... # type: int
361
342
362
343
[case testExportModuleInPackage_import]
363
344
import urllib.parse as p
@@ -384,11 +365,9 @@ x = 1
384
365
class C:
385
366
def g(self): ...
386
367
[out]
387
- from typing import Any
388
-
389
368
def f(): ...
390
369
391
- x = ... # type: Any
370
+ x = ... # type: int
392
371
393
372
class C:
394
373
def g(self): ...
@@ -521,11 +500,9 @@ class A:
521
500
def f(self): ...
522
501
def g(self): ...
523
502
[out]
524
- from typing import Any
525
-
526
503
class A:
527
504
class B:
528
- x = ... # type: Any
505
+ x = ... # type: int
529
506
def f(self): ...
530
507
def g(self): ...
531
508
0 commit comments