github-actions[bot] commented on code in PR #40757:
URL: https://github.com/apache/beam/pull/40757#discussion_r4364375016


##########
sdks/python/apache_beam/typehints/typehints.py:
##########
@@ -1536,6 +1548,9 @@ def is_consistent_with(
     # Cannot check unsupported parameterized generic which will cause 
issubclass
     # to fail with an exception.
     return False
+  elif _is_unchecked_protocol(base):

Review Comment:
   **🟡 Medium**: Because `elif _is_unchecked_protocol(base):` is placed after 
`elif isinstance(sub, RowTypeConstraint):` (line 1540) and `elif 
isinstance(sub, TypeConstraint):` (line 1542), `is_consistent_with(sub, base)` 
still returns `False` whenever `sub` is a Beam `TypeConstraint` (for example, 
`List[int]`, `Tuple[int, int]`, `Dict[str, int]`, `Set[int]`, or 
`RowTypeConstraint`—such as in `p | beam.Create([[1, 2]]) | beam.Map(fn)` where 
`fn` is annotated with a `Protocol`).
   
   Moving the `_is_unchecked_protocol(base)` check above `elif isinstance(sub, 
RowTypeConstraint):` (or right after `if isinstance(sub, AnyTypeConstraint) or 
isinstance(base, AnyTypeConstraint):`) ensures that container/row `PCollection` 
element types are also considered consistent with an unchecked `Protocol`.



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