You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/04 13:55:27 UTC

[GitHub] [beam] damccorm opened a new issue, #19903: Python typehints: merge unions of tuples of the same size

damccorm opened a new issue, #19903:
URL: https://github.com/apache/beam/issues/19903

   When inferring PCollection element types, merge Unions of identically-sized Tuples:
   Union[Tuple[a, b], Tuple[c, d]] =\> Tuple[Union[a, c], Union[b, d]]
   
   cc: [~robertwb]
   
   Example:
   ```
   
   def fn(element: Tuple[str, Any]):
     ....
   p | Create([('a', None), ('b', None)] + [('c', 1), ('d',
   3)]) | ParDo(fn)
   
   ```
   
   This pipeline will fail with something like:
   ```
   
   apache_beam.typehints.decorators.TypeCheckError: Type hint violation for 'ParDo': requires Tuple[str,
   Any] but got Union[Tuple[str, NoneType], Tuple[str, int]] for element
   
   ```
   
   
   In test form:
   ```
   
     def test_union_of_tuple(self):
       self.assertCompatible(
           typehints.Tuple[str, typehints.Any],
   
          typehints.Union[typehints.Tuple[str, type(None)],
                           typehints.Tuple[str,
   int]])
   
   ```
   
   
   Imported from Jira [BEAM-8464](https://issues.apache.org/jira/browse/BEAM-8464). Original Jira may contain additional context.
   Reported by: udim.


-- 
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: github-unsubscribe@beam.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org