Skip to content

Commit 17fb9c0

Browse files
authored
Return type for _ExpandIntoRanges DoFn should be Iterable. (#22548)
The following fails otherwise: ``` import apache_beam as beam from apache_beam.io import textio with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions( runtime_type_check=True, type_check_additional='all')) as p: p | beam.Create(['/bin/sh']) | textio.ReadAllFromText() ``` ``` apache_beam.typehints.typehints.CompositeTypeHintError: Union[FileMetadata, OffsetRange] type-constraint violated. Expected an instance of one of: ('FileMetadata', 'OffsetRange'), received tuple instead. ```
1 parent 6a02184 commit 17fb9c0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sdks/python/apache_beam/io/filebasedsource.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# pytype: skip-file
3030

3131
from typing import Callable
32+
from typing import Iterable
3233
from typing import Tuple
3334
from typing import Union
3435

@@ -347,7 +348,7 @@ def __init__(
347348
self._compression_type = compression_type
348349

349350
def process(self, element: Union[str, FileMetadata], *args,
350-
**kwargs) -> Tuple[FileMetadata, OffsetRange]:
351+
**kwargs) -> Iterable[Tuple[FileMetadata, OffsetRange]]:
351352
if isinstance(element, FileMetadata):
352353
metadata_list = [element]
353354
else:

0 commit comments

Comments
 (0)