damccorm commented on code in PR #40798:
URL: https://github.com/apache/beam/pull/40798#discussion_r4380759647
##########
sdks/python/apache_beam/runners/common.py:
##########
@@ -717,8 +717,11 @@ def __init__(self, placeholder):
self.placeholder = placeholder
if all(core.DoFn.ElementParam != arg for arg in default_arg_values):
- # TODO(https://github.com/apache/beam/issues/19631): Handle cases in which
- # len(arg_names) == len(default_arg_values).
+ if (default_arg_values and len(arg_names) == len(default_arg_values) and
+ not isinstance(default_arg_values[0], core._DoFnParam) and
+ default_arg_values[0] is not core.DoFn.BundleFinalizerParam):
+ # The implicit element occupies the first slot even if it has a default.
+ default_arg_values = default_arg_values[1:]
Review Comment:
Nit (non-blocking): For a single-parameter `def process(self, element=1):`,
slicing `default_arg_values[1:]` produces `[]`, so
`arg_names[-len(default_arg_values):]` on line 736 evaluates to
`arg_names[-0:]` (`['element']`). `zip(..., [])` still yields nothing today,
though guarding the loop on line 736 with `if default_arg_values:` would avoid
the `-0` slice pitfall if `strict=True` is ever added later.
--
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]