This is an automated email from the ASF dual-hosted git repository. jrmccluskey pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 7555d989799 Make conversion to Iterable tighter (#25866) 7555d989799 is described below commit 7555d9897996362a82e6e5d25202ddf29931338d Author: Jack McCluskey <34928439+jrmcclus...@users.noreply.github.com> AuthorDate: Fri Mar 17 15:23:55 2023 -0400 Make conversion to Iterable tighter (#25866) --- sdks/python/apache_beam/typehints/native_type_compatibility.py | 2 +- .../apache_beam/typehints/native_type_compatibility_test.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/typehints/native_type_compatibility.py b/sdks/python/apache_beam/typehints/native_type_compatibility.py index f0ef1b2e2c3..d03d5db4045 100644 --- a/sdks/python/apache_beam/typehints/native_type_compatibility.py +++ b/sdks/python/apache_beam/typehints/native_type_compatibility.py @@ -201,7 +201,7 @@ def convert_collections_to_typing(typ): typ = typing.Iterator[typ.__args__] elif hasattr(typ, 'send') and hasattr(typ, 'throw'): typ = typing.Generator[typ.__args__] - else: + elif _match_is_exactly_iterable(typ): typ = typing.Iterable[typ.__args__] return typ diff --git a/sdks/python/apache_beam/typehints/native_type_compatibility_test.py b/sdks/python/apache_beam/typehints/native_type_compatibility_test.py index 013fa354b82..89045ae7a25 100644 --- a/sdks/python/apache_beam/typehints/native_type_compatibility_test.py +++ b/sdks/python/apache_beam/typehints/native_type_compatibility_test.py @@ -156,6 +156,14 @@ class NativeTypeCompatibilityTest(unittest.TestCase): 'nested iterable', tuple[bytes, collections.abc.Iterable[int]], typehints.Tuple[bytes, typehints.Iterable[int]]), + ( + 'iterable over tuple', + collections.abc.Iterable[tuple[str, int]], + typehints.Iterable[typehints.Tuple[str, int]]), + ( + 'mapping not caught', + collections.abc.Mapping[str, int], + collections.abc.Mapping[str, int]), ] for test_case in test_cases: