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

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

                Author: ASF GitHub Bot
            Created on: 20/Feb/19 08:13
            Start Date: 20/Feb/19 08:13
    Worklog Time Spent: 10m 
      Work Description: RobbeSneyders commented on pull request #7873: 
[BEAM-6709] Check tuple typing failure.
URL: https://github.com/apache/beam/pull/7873#discussion_r258371258
 
 

 ##########
 File path: sdks/python/apache_beam/typehints/native_type_compatibility.py
 ##########
 @@ -37,14 +38,33 @@
 
 def _get_arg(typ, index):
   """Returns the index-th argument to the given type."""
-  return typ.__args__[index]
+  try:
+    return typ.__args__[index]
+  except AttributeError:
+    if (3, 0, 0) <= sys.version_info[0:3] < (3, 5, 3):
+      # On Python versions < 3.5.3, the Tuple and Union type from typing do
+      # not have an __args__ attribute, but a __tuple_params__, and a
+      # __union_params__ and __union_set_params__ argument respectively.
+      args = next(value for key, value in typ.__dict__.items()
 
 Review comment:
   I tried to make this check generic, not knowing if there were any other 
types following these same conventions. However, looking at the linked 
revision, it seems limited to `Tuple` and `Union`, so I agree that it would be 
better to clean this up.
   
   Thanks!
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 201139)
    Time Spent: 1.5h  (was: 1h 20m)

> Typehinting depends on typing changes in Python 3.5.3
> -----------------------------------------------------
>
>                 Key: BEAM-6709
>                 URL: https://issues.apache.org/jira/browse/BEAM-6709
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-py-core
>            Reporter: Robbe
>            Assignee: Robbe
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> On Python versions < 3.5.3, the Tuple and Union type from typing do not have 
> an `__args__` attribute, but a `__tuple_params__`, and a `__union_params__` 
> and `__union_set_params__` argument respectively.
> The current implementation fails <3.5.3 since it depends on the `__args__` 
> attribute



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to