jrmccluskey commented on code in PR #25795:
URL: https://github.com/apache/beam/pull/25795#discussion_r1139108726


##########
sdks/python/apache_beam/typehints/trivial_inference.py:
##########
@@ -498,6 +518,40 @@ def infer_return_type_func(f, input_types, debug=False, 
depth=0):
       else:
         return_type = typehints.Any
       state.stack[-pop_count:] = [return_type]
+    elif opname == 'CALL':
+      pop_count = 1 + arg
+      # Keyword Args case
+      if state.kw_names is not None:
+        if isinstance(state.stack[-pop_count], Const):
+          from apache_beam.pvalue import Row
+          if state.stack[-pop_count].value == Row:
+            fields = state.kw_names
+            return_type = row_type.RowTypeConstraint.from_fields(
+                list(
+                    zip(fields,
+                        Const.unwrap_all(state.stack[-pop_count + 1:]))))
+          else:
+            return_type = Any

Review Comment:
   We don't attempt type hinting on keyword args beyond rows (historically it's 
been hard to do that, with the post-3.11 practice of the KW names being stored 
as a tuple in the state rather than on the stack it may be easier to handle 
that case) and if we recurse more than 5 times we call it as an Any. Right now 
I'm trying to keep the behavior consistent with previous behavior, moving 
forward we'll be able to improve these mechanics



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