Skip to content

Commit 4205b78

Browse files
ilevkivskyiericmarkmartin
authored andcommitted
Test case for fixed namedtuple method call (python#18666)
Fixes python#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 6ab2f60 commit 4205b78

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test-data/unit/check-namedtuple.test

+14
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)