Skip to content

Commit b8c2dbf

Browse files
authored
Merge pull request #38190 from apache/forwardRefCherrypick
[Cherrypick] Support annotationlib in native_type_compatibility (#38188)
2 parents 959c542 + d0f5d98 commit b8c2dbf

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

sdks/python/apache_beam/typehints/native_type_compatibility.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@
8383
collections.abc.Mapping,
8484
]
8585

86-
_CONVERTED_MODULES = ('typing', 'collections', 'collections.abc')
86+
_CONVERTED_MODULES = (
87+
'typing',
88+
'collections',
89+
'collections.abc',
90+
'annotationlib',
91+
)
8792

8893

8994
def _get_args(typ):

sdks/python/apache_beam/typehints/native_type_compatibility_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ def test_forward_reference(self):
346346
self.assertEqual(
347347
typehints.List[typehints.Any], convert_to_beam_type(list['int']))
348348

349+
def test_annotationlib_forward_ref(self):
350+
beam_type = convert_to_beam_type(dict[str, typing.ForwardRef('foo.Bar')])
351+
self.assertEqual(typehints.Dict[str, typehints.Any], beam_type)
352+
349353
def test_convert_nested_to_beam_type(self):
350354
self.assertEqual(typehints.List[typing.Any], typehints.List[typehints.Any])
351355
self.assertEqual(

0 commit comments

Comments
 (0)