You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test-data/unit/check-plugin-attrs.test
-57
Original file line number
Diff line number
Diff line change
@@ -1554,63 +1554,6 @@ takes_attrs_cls(A(1, "")) # E: Argument 1 to "takes_attrs_cls" has incompatible
1554
1554
takes_attrs_instance(A) # E: Argument 1 to "takes_attrs_instance" has incompatible type "Type[A]"; expected "AttrsInstance" # N: ClassVar protocol member AttrsInstance.__attrs_attrs__ can never be matched by a class object
1555
1555
[builtins fixtures/plugin_attrs.pyi]
1556
1556
1557
-
[case testAttrsFields]
1558
-
import attr
1559
-
from attrs import fields as f # Common usage.
1560
-
1561
-
@attr.define
1562
-
class A:
1563
-
b: int
1564
-
c: str
1565
-
1566
-
reveal_type(f(A)) # N: Revealed type is "Tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1567
-
reveal_type(f(A)[0]) # N: Revealed type is "attr.Attribute[builtins.int]"
1568
-
reveal_type(f(A).b) # N: Revealed type is "attr.Attribute[builtins.int]"
1569
-
f(A).x # E: "____main___A_AttrsAttributes__" has no attribute "x"
1570
-
1571
-
for ff in f(A):
1572
-
reveal_type(ff) # N: Revealed type is "attr.Attribute[Any]"
1573
-
1574
-
[builtins fixtures/plugin_attrs.pyi]
1575
-
1576
-
[case testAttrsGenericFields]
1577
-
from typing import TypeVar
1578
-
1579
-
import attr
1580
-
from attrs import fields
1581
-
1582
-
@attr.define
1583
-
class A:
1584
-
b: int
1585
-
c: str
1586
-
1587
-
TA = TypeVar('TA', bound=A)
1588
-
1589
-
def f(t: TA) -> None:
1590
-
reveal_type(fields(t)) # N: Revealed type is "Tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1591
-
reveal_type(fields(t)[0]) # N: Revealed type is "attr.Attribute[builtins.int]"
1592
-
reveal_type(fields(t).b) # N: Revealed type is "attr.Attribute[builtins.int]"
1593
-
fields(t).x # E: "____main___A_AttrsAttributes__" has no attribute "x"
1594
-
1595
-
1596
-
[builtins fixtures/plugin_attrs.pyi]
1597
-
1598
-
[case testNonattrsFields]
1599
-
# flags: --no-strict-optional
1600
-
from typing import Any, cast, Type
1601
-
from attrs import fields
1602
-
1603
-
class A:
1604
-
b: int
1605
-
c: str
1606
-
1607
-
fields(A) # E: Argument 1 to "fields" has incompatible type "Type[A]"; expected an attrs class
1608
-
fields(None) # E: Argument 1 to "fields" has incompatible type "None"; expected an attrs class
0 commit comments