[ 
https://issues.apache.org/jira/browse/BEAM-8487?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17121835#comment-17121835
 ] 

Kenneth Knowles commented on BEAM-8487:
---------------------------------------

This issue is assigned but has not received an update in 30 days so it has been 
labeled "stale-assigned". If you are still working on the issue, please give an 
update and remove the label. If you are no longer working on the issue, please 
unassign so someone else may work on it. In 7 days the issue will be 
automatically unassigned.

> Python typehints: support forward references
> --------------------------------------------
>
>                 Key: BEAM-8487
>                 URL: https://issues.apache.org/jira/browse/BEAM-8487
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>            Reporter: Udi Meiri
>            Assignee: Udi Meiri
>            Priority: P2
>              Labels: stale-assigned
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Typehints may be given as string literals: 
> https://www.python.org/dev/peps/pep-0484/#forward-references
> These are currently not evaluated and result in errors.
> Example 1:
> {code}
>   def test_typed_callable_string_hints(self):
>     def do_fn(element: 'int') -> 'typehints.List[str]':
>       return [[str(element)] * 2]
>     result = [1, 2] | beam.ParDo(do_fn)
>     self.assertEqual([['1', '1'], ['2', '2']], sorted(result))
> {code}
> This results in:
> {code}
> >     return issubclass(sub, base)
> E     TypeError: issubclass() arg 2 must be a class or tuple of classes
> typehints.py:1168: TypeError
> {code}
> Example 2:
> {code}
>   def test_typed_dofn_string_hints(self):
>     class MyDoFn(beam.DoFn):
>       def process(self, element: 'int') -> 'typehints.List[str]':
>         return [[str(element)] * 2]
>     result = [1, 2] | beam.ParDo(MyDoFn())
>     self.assertEqual([['1', '1'], ['2', '2']], sorted(result))
> {code}
> This results in:
> {code}
> >     raise ValueError('%s is not iterable' % type_hint)
> E     ValueError: typehints.List[str] is not iterable
> typehints.py:1194: ValueError
> {code}
> where the non-iterable entity the error refers to is a string literal 
> ("typehints.List[str]").



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to