def testSimplifyUnions(self): src = textwrap.dedent(""" a = ... # type: int or int b = ... # type: int or ? c = ... # type: int or (int or float) """) new_src = textwrap.dedent(""" a = ... # type: int b = ... # type: ? c = ... # type: int or float """) self.AssertSourceEquals( self.ApplyVisitorToString(src, optimize.SimplifyUnions()), new_src)
def test_simplify_unions(self): src = pytd_src(""" from typing import Any a = ... # type: Union[int, int] b = ... # type: Union[int, Any] c = ... # type: Union[int, int, float] """) new_src = pytd_src(""" from typing import Any a = ... # type: int b = ... # type: Any c = ... # type: Union[int, float] """) self.AssertSourceEquals( self.ApplyVisitorToString(src, optimize.SimplifyUnions()), new_src)