Skip to content

Commit 7555d98

Browse files
authored
Make conversion to Iterable tighter (#25866)
1 parent de578e6 commit 7555d98

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

sdks/python/apache_beam/typehints/native_type_compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def convert_collections_to_typing(typ):
201201
typ = typing.Iterator[typ.__args__]
202202
elif hasattr(typ, 'send') and hasattr(typ, 'throw'):
203203
typ = typing.Generator[typ.__args__]
204-
else:
204+
elif _match_is_exactly_iterable(typ):
205205
typ = typing.Iterable[typ.__args__]
206206
return typ
207207

sdks/python/apache_beam/typehints/native_type_compatibility_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ def test_convert_to_beam_type_with_collections_types(self):
156156
'nested iterable',
157157
tuple[bytes, collections.abc.Iterable[int]],
158158
typehints.Tuple[bytes, typehints.Iterable[int]]),
159+
(
160+
'iterable over tuple',
161+
collections.abc.Iterable[tuple[str, int]],
162+
typehints.Iterable[typehints.Tuple[str, int]]),
163+
(
164+
'mapping not caught',
165+
collections.abc.Mapping[str, int],
166+
collections.abc.Mapping[str, int]),
159167
]
160168

161169
for test_case in test_cases:

0 commit comments

Comments
 (0)