示例#1
0
 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)
示例#2
0
 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)