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
reveal_type(cls) # N: Revealed type is "Type[__main__.A]"
767
+
reveal_type(cls) # N: Revealed type is "type[__main__.A]"
765
768
reveal_type(cls.other()) # N: Revealed type is "builtins.str"
766
769
return x
767
770
@@ -1210,7 +1213,7 @@ def my_factory() -> int:
1210
1213
return 7
1211
1214
@attr.s
1212
1215
class A:
1213
-
x: int = attr.ib(factory=list) # E: Incompatible types in assignment (expression has type "List[Never]", variable has type "int")
1216
+
x: int = attr.ib(factory=list) # E: Incompatible types in assignment (expression has type "list[Never]", variable has type "int")
1214
1217
y: str = attr.ib(factory=my_factory) # E: Incompatible types in assignment (expression has type "int", variable has type "str")
1215
1218
[builtins fixtures/list.pyi]
1216
1219
@@ -1521,7 +1524,7 @@ class A:
1521
1524
b: int = attr.ib()
1522
1525
c: str = attr.ib()
1523
1526
1524
-
reveal_type(A.__attrs_attrs__) # N: Revealed type is "Tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1527
+
reveal_type(A.__attrs_attrs__) # N: Revealed type is "tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1525
1528
reveal_type(A.__attrs_attrs__[0]) # N: Revealed type is "attr.Attribute[builtins.int]"
1526
1529
reveal_type(A.__attrs_attrs__.b) # N: Revealed type is "attr.Attribute[builtins.int]"
1527
1530
A.__attrs_attrs__.x # E: "____main___A_AttrsAttributes__" has no attribute "x"
@@ -1536,7 +1539,7 @@ class A:
1536
1539
b = attr.ib()
1537
1540
c = attr.ib()
1538
1541
1539
-
reveal_type(A.__attrs_attrs__) # N: Revealed type is "Tuple[attr.Attribute[Any], attr.Attribute[Any], fallback=__main__.A.____main___A_AttrsAttributes__]"
1542
+
reveal_type(A.__attrs_attrs__) # N: Revealed type is "tuple[attr.Attribute[Any], attr.Attribute[Any], fallback=__main__.A.____main___A_AttrsAttributes__]"
1540
1543
reveal_type(A.__attrs_attrs__[0]) # N: Revealed type is "attr.Attribute[Any]"
1541
1544
reveal_type(A.__attrs_attrs__.b) # N: Revealed type is "attr.Attribute[Any]"
1542
1545
A.__attrs_attrs__.x # E: "____main___A_AttrsAttributes__" has no attribute "x"
@@ -1551,7 +1554,7 @@ class A:
1551
1554
b: int
1552
1555
c: str
1553
1556
1554
-
reveal_type(A.__attrs_attrs__) # N: Revealed type is "Tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1557
+
reveal_type(A.__attrs_attrs__) # N: Revealed type is "tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1555
1558
reveal_type(A.__attrs_attrs__[0]) # N: Revealed type is "attr.Attribute[builtins.int]"
1556
1559
reveal_type(A.__attrs_attrs__.b) # N: Revealed type is "attr.Attribute[builtins.int]"
1557
1560
A.__attrs_attrs__.x # E: "____main___A_AttrsAttributes__" has no attribute "x"
takes_attrs_cls(A(1, "")) # E: Argument 1 to "takes_attrs_cls" has incompatible type "A"; expected "Type[AttrsInstance]"
1583
-
takes_attrs_instance(A) # E: Argument 1 to "takes_attrs_instance" has incompatible type "Type[A]"; expected "AttrsInstance" \
1585
+
takes_attrs_cls(A(1, "")) # E: Argument 1 to "takes_attrs_cls" has incompatible type "A"; expected "type[AttrsInstance]"
1586
+
takes_attrs_instance(A) # E: Argument 1 to "takes_attrs_instance" has incompatible type "type[A]"; expected "AttrsInstance" \
1584
1587
# N: ClassVar protocol member AttrsInstance.__attrs_attrs__ can never be matched by a class object
1588
+
1585
1589
[builtins fixtures/plugin_attrs.pyi]
1586
1590
1587
1591
[case testAttrsFields]
@@ -1593,7 +1597,7 @@ class A:
1593
1597
b: int
1594
1598
c: str
1595
1599
1596
-
reveal_type(f(A)) # N: Revealed type is "Tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1600
+
reveal_type(f(A)) # N: Revealed type is "tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1597
1601
reveal_type(f(A)[0]) # N: Revealed type is "attr.Attribute[builtins.int]"
1598
1602
reveal_type(f(A).b) # N: Revealed type is "attr.Attribute[builtins.int]"
1599
1603
f(A).x # E: "____main___A_AttrsAttributes__" has no attribute "x"
@@ -1617,7 +1621,7 @@ class A:
1617
1621
TA = TypeVar('TA', bound=A)
1618
1622
1619
1623
def f(t: TA) -> None:
1620
-
reveal_type(fields(t)) # N: Revealed type is "Tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1624
+
reveal_type(fields(t)) # N: Revealed type is "tuple[attr.Attribute[builtins.int], attr.Attribute[builtins.str], fallback=__main__.A.____main___A_AttrsAttributes__]"
1621
1625
reveal_type(fields(t)[0]) # N: Revealed type is "attr.Attribute[builtins.int]"
1622
1626
reveal_type(fields(t).b) # N: Revealed type is "attr.Attribute[builtins.int]"
1623
1627
fields(t).x # E: "____main___A_AttrsAttributes__" has no attribute "x"
@@ -1636,8 +1640,8 @@ class A:
1636
1640
if has(A):
1637
1641
fields(A)
1638
1642
else:
1639
-
fields(A) # E: Argument 1 to "fields" has incompatible type "Type[A]"; expected "Type[AttrsInstance]"
1640
-
fields(None) # E: Argument 1 to "fields" has incompatible type "None"; expected "Type[AttrsInstance]"
1643
+
fields(A) # E: Argument 1 to "fields" has incompatible type "type[A]"; expected "type[AttrsInstance]"
1644
+
fields(None) # E: Argument 1 to "fields" has incompatible type "None"; expected "type[AttrsInstance]"
1641
1645
fields(cast(Any, 42))
1642
1646
fields(cast(Type[Any], 43))
1643
1647
@@ -1655,8 +1659,8 @@ class A:
1655
1659
b, c = bc
1656
1660
self.__attrs_init__(b, c)
1657
1661
1658
-
reveal_type(A) # N: Revealed type is "def (bc: Tuple[builtins.int, builtins.str]) -> __main__.A"
1659
-
reveal_type(A.__init__) # N: Revealed type is "def (self: __main__.A, bc: Tuple[builtins.int, builtins.str])"
1662
+
reveal_type(A) # N: Revealed type is "def (bc: tuple[builtins.int, builtins.str]) -> __main__.A"
1663
+
reveal_type(A.__init__) # N: Revealed type is "def (self: __main__.A, bc: tuple[builtins.int, builtins.str])"
1660
1664
reveal_type(A.__attrs_init__) # N: Revealed type is "def (self: __main__.A, b: builtins.int, c: builtins.str)"
1661
1665
1662
1666
[builtins fixtures/plugin_attrs.pyi]
@@ -1733,22 +1737,22 @@ class Some:
1733
1737
y: str
1734
1738
z: bool
1735
1739
1736
-
reveal_type(Some.__slots__) # N: Revealed type is "Tuple[builtins.str, builtins.str, builtins.str]"
1740
+
reveal_type(Some.__slots__) # N: Revealed type is "tuple[builtins.str, builtins.str, builtins.str]"
1737
1741
1738
1742
@dataclass(slots=True)
1739
1743
class Other:
1740
1744
x: int
1741
1745
y: str
1742
1746
1743
-
reveal_type(Other.__slots__) # N: Revealed type is "Tuple[builtins.str, builtins.str]"
1747
+
reveal_type(Other.__slots__) # N: Revealed type is "tuple[builtins.str, builtins.str]"
1744
1748
1745
1749
1746
1750
@dataclass
1747
1751
class NoSlots:
1748
1752
x: int
1749
1753
y: str
1750
1754
1751
-
NoSlots.__slots__ # E: "Type[NoSlots]" has no attribute "__slots__"
1755
+
NoSlots.__slots__ # E: "type[NoSlots]" has no attribute "__slots__"
1752
1756
[builtins fixtures/plugin_attrs.pyi]
1753
1757
1754
1758
[case testAttrsWithMatchArgs]
@@ -1763,8 +1767,8 @@ class ToMatch:
1763
1767
z: int = attr.field(kw_only=True)
1764
1768
i: int = attr.field(init=False)
1765
1769
1766
-
reveal_type(ToMatch(x=1, y=2, z=3).__match_args__) # N: Revealed type is "Tuple[Literal['x']?, Literal['y']?]"
1767
-
reveal_type(ToMatch(1, 2, z=3).__match_args__) # N: Revealed type is "Tuple[Literal['x']?, Literal['y']?]"
1770
+
reveal_type(ToMatch(x=1, y=2, z=3).__match_args__) # N: Revealed type is "tuple[Literal['x']?, Literal['y']?]"
1771
+
reveal_type(ToMatch(1, 2, z=3).__match_args__) # N: Revealed type is "tuple[Literal['x']?, Literal['y']?]"
1768
1772
[builtins fixtures/plugin_attrs.pyi]
1769
1773
1770
1774
[case testAttrsWithMatchArgsDefaultCase]
@@ -1777,15 +1781,15 @@ class ToMatch1:
1777
1781
y: int
1778
1782
1779
1783
t1: ToMatch1
1780
-
reveal_type(t1.__match_args__) # N: Revealed type is "Tuple[Literal['x']?, Literal['y']?]"
1784
+
reveal_type(t1.__match_args__) # N: Revealed type is "tuple[Literal['x']?, Literal['y']?]"
1781
1785
1782
1786
@attr.define
1783
1787
class ToMatch2:
1784
1788
x: int
1785
1789
y: int
1786
1790
1787
1791
t2: ToMatch2
1788
-
reveal_type(t2.__match_args__) # N: Revealed type is "Tuple[Literal['x']?, Literal['y']?]"
1792
+
reveal_type(t2.__match_args__) # N: Revealed type is "tuple[Literal['x']?, Literal['y']?]"
1789
1793
[builtins fixtures/plugin_attrs.pyi]
1790
1794
1791
1795
[case testAttrsWithMatchArgsOverrideExisting]
@@ -1800,15 +1804,15 @@ class ToMatch:
1800
1804
y: int
1801
1805
1802
1806
# It works the same way runtime does:
1803
-
reveal_type(ToMatch(x=1, y=2).__match_args__) # N: Revealed type is "Tuple[Literal['a']?, Literal['b']?]"
1807
+
reveal_type(ToMatch(x=1, y=2).__match_args__) # N: Revealed type is "tuple[Literal['a']?, Literal['b']?]"
1804
1808
1805
1809
@attr.s(auto_attribs=True)
1806
1810
class WithoutMatch:
1807
1811
__match_args__: Final = ('a', 'b')
1808
1812
x: int
1809
1813
y: int
1810
1814
1811
-
reveal_type(WithoutMatch(x=1, y=2).__match_args__) # N: Revealed type is "Tuple[Literal['a']?, Literal['b']?]"
1815
+
reveal_type(WithoutMatch(x=1, y=2).__match_args__) # N: Revealed type is "tuple[Literal['a']?, Literal['b']?]"
1812
1816
[builtins fixtures/plugin_attrs.pyi]
1813
1817
1814
1818
[case testAttrsWithMatchArgsOldVersion]
@@ -2176,7 +2180,7 @@ class B:
2176
2180
a_or_b: A[int] | B
2177
2181
a2 = attrs.evolve(a_or_b, x=42, y=True)
2178
2182
a2 = attrs.evolve(a_or_b, x=42, y=True, z='42') # E: Argument "z" to "evolve" of "Union[A[int], B]" has incompatible type "str"; expected "Never"
2179
-
a2 = attrs.evolve(a_or_b, x=42, y=True, w={}) # E: Argument "w" to "evolve" of "Union[A[int], B]" has incompatible type "Dict[Never, Never]"; expected "Never"
2183
+
a2 = attrs.evolve(a_or_b, x=42, y=True, w={}) # E: Argument "w" to "evolve" of "Union[A[int], B]" has incompatible type "dict[Never, Never]"; expected "Never"
0 commit comments