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


##########
sdks/python/apache_beam/typehints/decorators.py:
##########
@@ -546,12 +547,21 @@ def extract_tagged_outputs(self):
       A copy of this instance with TaggedOutput members moved from the main
       output type into the output kwargs dict.
     """
+    opts = get_pipeline_options()
+    if opts and opts.is_compat_version_prior_to("2.72.0"):
+      return self
     if self.output_types is None or not self.has_simple_output_type():
       return self
-    output_type = self.output_types[0][0]
+    # Tags already set via decorator/chain style — nothing to extract.
+    if self.output_types[1]:
+      return self
 
+    output_type = self.output_types[0][0]
     clean_type, extracted_tags = _extract_tagged_from_type(output_type)
-    if not extracted_tags:
+
+    # Bare TaggedOutput e.g. if -> int | TaggedOutput then clean_type = int
+    # and extracted_tags = {}
+    if not extracted_tags and clean_type == output_type:

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   The comment here is a bit confusing. It provides an example of what happens 
with a bare `TaggedOutput` but doesn't fully clarify the logic of the `if` 
condition. The condition correctly handles cases where `extracted_tags` is 
empty, but `clean_type` has been modified (e.g., by stripping a bare 
`TaggedOutput`), which is the desired new behavior. A more explanatory comment 
would improve code clarity and maintainability for future developers.
   
   ```suggestion
       # If no tags were extracted, only return if the type is also unchanged.
       # A bare `TaggedOutput` (e.g. in `int | TaggedOutput`) results in no
       # extracted tags, but `clean_type` is modified, so we should proceed.
       if not extracted_tags and clean_type == output_type:
   ```



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