|
1 | 1 | - case: attr_s_with_type_argument
|
2 | 2 | parametrized:
|
3 |
| - - val: 'a = attr.ib(type=int)' |
4 |
| - - val: 'a: int = attr.ib()' |
| 3 | + - val: "a = attr.ib(type=int)" |
| 4 | + - val: "a: int = attr.ib()" |
5 | 5 | main: |
|
6 | 6 | import attr
|
7 | 7 | @attr.s
|
|
12 | 12 | C(a=1)
|
13 | 13 | C(a="hi") # E: Argument "a" to "C" has incompatible type "str"; expected "int"
|
14 | 14 | - case: attr_s_with_type_annotations
|
15 |
| - main : | |
| 15 | + main: | |
16 | 16 | import attr
|
17 | 17 | @attr.s
|
18 | 18 | class C:
|
|
97 | 97 |
|
98 | 98 | - case: testAttrsUntypedNoUntypedDefs
|
99 | 99 | mypy_config: |
|
100 |
| - disallow_untyped_defs = True |
| 100 | + disallow_untyped_defs = True |
101 | 101 | main: |
|
102 | 102 | import attr
|
103 | 103 | @attr.s
|
|
316 | 316 | class Confused:
|
317 | 317 | ...
|
318 | 318 |
|
319 |
| -
|
320 | 319 | - case: testAttrsInheritance
|
321 | 320 | main: |
|
322 | 321 | import attr
|
|
469 | 468 | return self.x # E: Incompatible return value type (got "List[T]", expected "T")
|
470 | 469 | reveal_type(A) # N: Revealed type is "def [T] (x: builtins.list[T`1], y: T`1) -> main.A[T`1]"
|
471 | 470 | a = A([1], 2)
|
472 |
| - reveal_type(a) # N: Revealed type is "main.A[builtins.int*]" |
473 |
| - reveal_type(a.x) # N: Revealed type is "builtins.list[builtins.int*]" |
474 |
| - reveal_type(a.y) # N: Revealed type is "builtins.int*" |
| 471 | + reveal_type(a) # N: Revealed type is "main.A[builtins.int]" |
| 472 | + reveal_type(a.x) # N: Revealed type is "builtins.list[builtins.int]" |
| 473 | + reveal_type(a.y) # N: Revealed type is "builtins.int" |
475 | 474 |
|
476 | 475 | A(['str'], 7) # E: Cannot infer type argument 1 of "A"
|
477 | 476 | A([1], '2') # E: Cannot infer type argument 1 of "A"
|
478 | 477 |
|
479 |
| -
|
480 | 478 | - case: testAttrsUntypedGenericInheritance
|
481 | 479 | main: |
|
482 | 480 | from typing import Generic, TypeVar
|
|
514 | 512 | pass
|
515 | 513 |
|
516 | 514 | sub_int = Sub[int](attr=1)
|
517 |
| - reveal_type(sub_int) # N: Revealed type is "main.Sub[builtins.int*]" |
518 |
| - reveal_type(sub_int.attr) # N: Revealed type is "builtins.int*" |
| 515 | + reveal_type(sub_int) # N: Revealed type is "main.Sub[builtins.int]" |
| 516 | + reveal_type(sub_int.attr) # N: Revealed type is "builtins.int" |
519 | 517 |
|
520 | 518 | sub_str = Sub[str](attr='ok')
|
521 |
| - reveal_type(sub_str) # N: Revealed type is "main.Sub[builtins.str*]" |
522 |
| - reveal_type(sub_str.attr) # N: Revealed type is "builtins.str*" |
| 519 | + reveal_type(sub_str) # N: Revealed type is "main.Sub[builtins.str]" |
| 520 | + reveal_type(sub_str.attr) # N: Revealed type is "builtins.str" |
523 | 521 |
|
524 | 522 | - case: testAttrsGenericInheritance2
|
525 | 523 | main: |
|
|
764 | 762 | return 'hello'
|
765 | 763 |
|
766 | 764 | - case: testAttrsUsingBadConverter
|
767 |
| - mypy_config: |
768 |
| - strict_optional = False |
| 765 | + mypy_config: strict_optional = False |
769 | 766 | main: |
|
770 | 767 | import attr
|
771 | 768 | from typing import overload
|
|
792 | 789 | main:17: note: Revealed type is "def (bad: Any, bad_overloaded: Any) -> main.A"
|
793 | 790 |
|
794 | 791 | - case: testAttrsUsingBadConverterReprocess
|
795 |
| - mypy_config: |
796 |
| - strict_optional = False |
| 792 | + mypy_config: strict_optional = False |
797 | 793 | main: |
|
798 | 794 | import attr
|
799 | 795 | from typing import overload
|
|
1169 | 1165 | c = attr.ib(15)
|
1170 | 1166 | D(b=17)
|
1171 | 1167 |
|
1172 |
| -
|
1173 | 1168 | - case: testAttrsKwOnlySubclass
|
1174 | 1169 | main: |
|
1175 | 1170 | import attr
|
|
1211 | 1206 | reveal_type(B) # N: Revealed type is "def (x: main.C) -> main.B"
|
1212 | 1207 |
|
1213 | 1208 | - case: testDisallowUntypedWorksForwardBad
|
1214 |
| - mypy_config: |
1215 |
| - disallow_untyped_defs = True |
| 1209 | + mypy_config: disallow_untyped_defs = True |
1216 | 1210 | main: |
|
1217 | 1211 | import attr
|
1218 | 1212 |
|
|
1357 | 1351 | foo = x
|
1358 | 1352 |
|
1359 | 1353 | reveal_type(B) # N: Revealed type is "def (foo: builtins.int) -> main.B"
|
| 1354 | +
|
| 1355 | +- case: testFields |
| 1356 | + main: | |
| 1357 | + from attrs import define, fields |
| 1358 | +
|
| 1359 | + @define |
| 1360 | + class A: |
| 1361 | + a: int |
| 1362 | + b: str |
| 1363 | +
|
| 1364 | + reveal_type(fields(A)) # N: Revealed type is "Any" |
| 1365 | +
|
| 1366 | +- case: testFieldsError |
| 1367 | + main: | |
| 1368 | + from attrs import fields |
| 1369 | +
|
| 1370 | + class A: |
| 1371 | + a: int |
| 1372 | + b: str |
| 1373 | +
|
| 1374 | + fields(A) # E: Argument 1 to "fields" has incompatible type "Type[A]"; expected "Type[AttrsInstance]" |
0 commit comments