# mypy 0.530
foo.py:14: warning: Returning Any from function declared to return "int"
foo.py:14: error: Item "type" of "Union[Type[Foo], Type[Bar]]" has no attribute "x"
from typing import *
class Foo(NamedTuple):
a: int
@classmethod
def x(cls) -> int: return 1
class Bar(NamedTuple):
a: int
@classmethod
def x(cls) -> int: return 1
def foo(t: Type[Union[Foo, Bar]]) -> int:
return t.x()
If I make them usual classes instead of namedtuples, it works