tvalentyn commented on code in PR #25743:
URL: https://github.com/apache/beam/pull/25743#discussion_r1131566457
##########
sdks/python/apache_beam/transforms/core.py:
##########
@@ -1387,6 +1388,47 @@ def partition_for(self, element, num_partitions, *args,
**kwargs):
return self._fn(element, num_partitions, *args, **kwargs)
+def _get_function_body_without_inners(func):
+ source_lines = inspect.getsourcelines(func)[0]
Review Comment:
`total_yield` and `tax_return` could trigger false positives here. I took a
closer look, I am no longer sure unconditionally failing the pipeline is the
right thing to do here, as we are fighting against Python language rules. I
think we can print a warning potentially, and update the documentation to
recommend `yield from` instead of return for iterables. We should do the due
diligence to make sure `yield from` achieves the desired result though to make
sure there are no surprises.
##########
CHANGES.md:
##########
@@ -68,6 +68,7 @@
## Breaking Changes
+* Python SDK now does not allow mixing the yield and return statements in
`DoFn.process()` ([#22969](https://github.com/apache/beam/issues/22969)).
`yield` is recommended for emitting elements and `yield from` for iterators.
Review Comment:
```suggestion
* Python SDK now does not allow mixing the yield and return statements in
`DoFn.process()` ([#22969](https://github.com/apache/beam/issues/22969)). We
recommend to use `yield` for emitting individual elements and `yield from` for
emitting the content of entire iterables.
```
##########
CHANGES.md:
##########
@@ -68,6 +68,7 @@
## Breaking Changes
+* Python SDK now does not allow mixing the yield and return statements in
`DoFn.process()` ([#22969](https://github.com/apache/beam/issues/22969)).
`yield` is recommended for emitting elements and `yield from` for iterators.
Review Comment:
this suggestion should be added to Beam docs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]