@@ -1640,3 +1640,129 @@ follow_imports = skip
1640
1640
main:3: error: Revealed type is 'builtins.int'
1641
1641
[out2]
1642
1642
main:3: error: Revealed type is 'Any'
1643
+
1644
+ [case testIncrementalNamedTupleInMethod]
1645
+ from ntcrash import nope
1646
+ [file ntcrash.py]
1647
+ from typing import NamedTuple
1648
+ class C:
1649
+ def f(self) -> None:
1650
+ A = NamedTuple('A', [('x', int), ('y', int)])
1651
+ [out1]
1652
+ main:1: error: Module 'ntcrash' has no attribute 'nope'
1653
+ [out2]
1654
+ main:1: error: Module 'ntcrash' has no attribute 'nope'
1655
+
1656
+ [case testIncrementalNamedTupleInMethod2]
1657
+ from ntcrash import nope
1658
+ [file ntcrash.py]
1659
+ from typing import NamedTuple
1660
+ class C:
1661
+ class D:
1662
+ def f(self) -> None:
1663
+ A = NamedTuple('A', [('x', int), ('y', int)])
1664
+ [out1]
1665
+ main:1: error: Module 'ntcrash' has no attribute 'nope'
1666
+ [out2]
1667
+ main:1: error: Module 'ntcrash' has no attribute 'nope'
1668
+
1669
+ [case testIncrementalNamedTupleInMethod3]
1670
+ from ntcrash import nope
1671
+ [file ntcrash.py]
1672
+ from typing import NamedTuple
1673
+ class C:
1674
+ def a(self):
1675
+ class D:
1676
+ def f(self) -> None:
1677
+ A = NamedTuple('A', [('x', int), ('y', int)])
1678
+ [out1]
1679
+ main:1: error: Module 'ntcrash' has no attribute 'nope'
1680
+ [out2]
1681
+ main:1: error: Module 'ntcrash' has no attribute 'nope'
1682
+
1683
+ [case testIncrementalNamedTupleInMethod4]
1684
+ from ntcrash import C
1685
+ reveal_type(C().a)
1686
+ reveal_type(C().b)
1687
+ reveal_type(C().c)
1688
+ [file ntcrash.py]
1689
+ from typing import NamedTuple
1690
+ class C:
1691
+ def __init__(self) -> None:
1692
+ A = NamedTuple('A', [('x', int)])
1693
+ self.a = A(0)
1694
+ self.b = A(0) # type: A
1695
+ self.c = A
1696
+ [out1]
1697
+ main:2: error: Revealed type is 'Tuple[builtins.int, fallback=ntcrash.C.A@4]'
1698
+ main:3: error: Revealed type is 'Tuple[builtins.int, fallback=ntcrash.C.A@4]'
1699
+ main:4: error: Revealed type is 'def (x: builtins.int) -> Tuple[builtins.int, fallback=ntcrash.C.A@4]'
1700
+ [out2]
1701
+ main:2: error: Revealed type is 'Tuple[builtins.int, fallback=ntcrash.C.A@4]'
1702
+ main:3: error: Revealed type is 'Tuple[builtins.int, fallback=ntcrash.C.A@4]'
1703
+ main:4: error: Revealed type is 'def (x: builtins.int) -> Tuple[builtins.int, fallback=ntcrash.C.A@4]'
1704
+
1705
+ [case testIncrementalTypedDictInMethod]
1706
+ from tdcrash import nope
1707
+ [file tdcrash.py]
1708
+ from mypy_extensions import TypedDict
1709
+ class C:
1710
+ def f(self) -> None:
1711
+ A = TypedDict('A', {'x': int, 'y': int})
1712
+ [builtins fixtures/dict.pyi]
1713
+ [out1]
1714
+ main:1: error: Module 'tdcrash' has no attribute 'nope'
1715
+ [out2]
1716
+ main:1: error: Module 'tdcrash' has no attribute 'nope'
1717
+
1718
+ [case testIncrementalTypedDictInMethod2]
1719
+ from tdcrash import nope
1720
+ [file tdcrash.py]
1721
+ from mypy_extensions import TypedDict
1722
+ class C:
1723
+ class D:
1724
+ def f(self) -> None:
1725
+ A = TypedDict('A', {'x': int, 'y': int})
1726
+ [builtins fixtures/dict.pyi]
1727
+ [out1]
1728
+ main:1: error: Module 'tdcrash' has no attribute 'nope'
1729
+ [out2]
1730
+ main:1: error: Module 'tdcrash' has no attribute 'nope'
1731
+
1732
+ [case testIncrementalTypedDictInMethod3]
1733
+ from tdcrash import nope
1734
+ [file tdcrash.py]
1735
+ from mypy_extensions import TypedDict
1736
+ class C:
1737
+ def a(self):
1738
+ class D:
1739
+ def f(self) -> None:
1740
+ A = TypedDict('A', {'x': int, 'y': int})
1741
+ [builtins fixtures/dict.pyi]
1742
+ [out1]
1743
+ main:1: error: Module 'tdcrash' has no attribute 'nope'
1744
+ [out2]
1745
+ main:1: error: Module 'tdcrash' has no attribute 'nope'
1746
+
1747
+ [case testIncrementalTypedDictInMethod4]
1748
+ from ntcrash import C
1749
+ reveal_type(C().a)
1750
+ reveal_type(C().b)
1751
+ reveal_type(C().c)
1752
+ [file ntcrash.py]
1753
+ from mypy_extensions import TypedDict
1754
+ class C:
1755
+ def __init__(self) -> None:
1756
+ A = TypedDict('A', {'x': int})
1757
+ self.a = A(x=0)
1758
+ self.b = A(x=0) # type: A
1759
+ self.c = A
1760
+ [builtins fixtures/dict.pyi]
1761
+ [out1]
1762
+ main:2: error: Revealed type is 'TypedDict(x=builtins.int, _fallback=typing.Mapping[builtins.str, builtins.int])'
1763
+ main:3: error: Revealed type is 'TypedDict(x=builtins.int, _fallback=ntcrash.C.A@4)'
1764
+ main:4: error: Revealed type is 'def () -> ntcrash.C.A@4'
1765
+ [out2]
1766
+ main:2: error: Revealed type is 'TypedDict(x=builtins.int, _fallback=typing.Mapping[builtins.str, builtins.int])'
1767
+ main:3: error: Revealed type is 'TypedDict(x=builtins.int, _fallback=ntcrash.C.A@4)'
1768
+ main:4: error: Revealed type is 'def () -> ntcrash.C.A@4'
0 commit comments