diff --git a/sdks/python/apache_beam/typehints/typehints_test.py b/sdks/python/apache_beam/typehints/typehints_test.py index cd7f9fc4e30fc..d8893a3f474a2 100644 --- a/sdks/python/apache_beam/typehints/typehints_test.py +++ b/sdks/python/apache_beam/typehints/typehints_test.py @@ -104,6 +104,15 @@ class SubClass(SuperClass): pass +T = typing.TypeVar('T') + + +class NonBuiltInGeneric(typing.NamedTuple('Entry', [('Field1', T), + ('Field2', T)]), + typing.Generic[T]): + pass + + class TypeHintTestCase(unittest.TestCase): def assertCompatible(self, base, sub): # pylint: disable=invalid-name base, sub = native_type_compatibility.convert_to_beam_types([base, sub]) @@ -1645,5 +1654,12 @@ def test_pipe_operator_as_union(self): native_type_compatibility.convert_to_beam_type(type_b)) +class TestNonBuiltInGenerics(unittest.TestCase): + def test_no_error_thrown(self): + input = NonBuiltInGeneric[str] + output = typehints.normalize(input) + self.assertEqual(input, output) + + if __name__ == '__main__': unittest.main()