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

ASF GitHub Bot logged work on BEAM-8487:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Feb/20 22:13
            Start Date: 21/Feb/20 22:13
    Worklog Time Spent: 10m 
      Work Description: udim commented on issue #10932: [BEAM-8487] Handle 
nested forward references
URL: https://github.com/apache/beam/pull/10932#issuecomment-589859233
 
 
   R: @tvalentyn 
   CC: @robertwb 
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 390943)
    Time Spent: 1h 20m  (was: 1h 10m)

> 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: Major
>          Time Spent: 1h 20m
>  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