Skip to content

Commit 03cf35c

Browse files
authored
Test case for fixed namedtuple method call (#18666)
Fixes #15600 The issue was previously "fixed" because of another bug. Now that everything is properly fixed, we can add this "regression" test just in case.
1 parent 2831eb1 commit 03cf35c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test-data/unit/check-namedtuple.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,3 +1505,17 @@ def g(x: Union[A, B, str]) -> Union[A, B, str]:
15051505

15061506
# no errors should be raised above.
15071507
[builtins fixtures/tuple.pyi]
1508+
1509+
[case testNamedTupleUnionAnyMethodCall]
1510+
from collections import namedtuple
1511+
from typing import Any, Union
1512+
1513+
T = namedtuple("T", ["x"])
1514+
1515+
class C(T):
1516+
def f(self) -> bool:
1517+
return True
1518+
1519+
c: Union[C, Any]
1520+
reveal_type(c.f()) # N: Revealed type is "Union[builtins.bool, Any]"
1521+
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)