gemini-code-assist[bot] commented on code in PR #37828:
URL: https://github.com/apache/beam/pull/37828#discussion_r2920436608


##########
sdks/python/apache_beam/yaml/yaml_ml.py:
##########
@@ -487,9 +487,10 @@ def fn(x: PredictionResult):
               model_handler_provider._postprocess_fn_internal()),
           inference_args=inference_args)
       | beam.Map(
-          lambda row: beam.Row(**{
-              inference_tag: row[1], **row[0]._asdict()
-          })).with_output_types(schema))
+          lambda row: beam.Row(
+              **{
+                  str(inference_tag): row[1], **row[0]._asdict()
+              })).with_output_types(schema))

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   While the explicit cast to `str()` is correct to fix the `bad-unpacking` 
error, the dictionary construction and unpacking can be made more idiomatic and 
concise. Placing the unpacked dictionary `**row[0]._asdict()` before the new 
field also makes the field order consistent with how the schema is constructed, 
improving readability.
   
   ```python
             lambda row: beam.Row(**{**row[0]._asdict(), str(inference_tag): 
row[1]})).with_output_types(schema))
   ```



-- 
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]

Reply via email to