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

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

                Author: ASF GitHub Bot
            Created on: 21/Aug/20 15:22
            Start Date: 21/Aug/20 15:22
    Worklog Time Spent: 10m 
      Work Description: udim commented on a change in pull request #12654:
URL: https://github.com/apache/beam/pull/12654#discussion_r474766773



##########
File path: sdks/python/apache_beam/transforms/external.py
##########
@@ -127,17 +127,21 @@ def _get_named_tuple_instance(self):
         for key, value in self._values.items() if value is not None
     }
 
+    # In python 2 named_fields_to_schema will not accept str because its
+    # ambiguous. This converts str hints to ByteString recursively so its clear
+    # we intend to use BYTES.
     # TODO(BEAM-7372): Remove coercion to ByteString
     def coerce_str_to_bytes(typ):
       if typ == str:
         return ByteString
 
       elif hasattr(typ, '__args__'):

Review comment:
       Probably should also check if `hasattr(typ, '__origin__')` to be safe.
   In native_type_compatibility we also check `getattr(typ, '__module__', None) 
!= 'typing'` to exclude stuff that's not from the typing module.




----------------------------------------------------------------
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:
[email protected]


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

    Worklog Id:     (was: 473312)
    Time Spent: 20m  (was: 10m)

> NativeTypeCompatibilityTest.test_convert_to_beam_types flake
> ------------------------------------------------------------
>
>                 Key: BEAM-10766
>                 URL: https://issues.apache.org/jira/browse/BEAM-10766
>             Project: Beam
>          Issue Type: Bug
>          Components: test-failures
>            Reporter: Kyle Weaver
>            Assignee: Brian Hulette
>            Priority: P1
>              Labels: flaky-test
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> [https://ci-beam.apache.org/job/beam_PreCommit_Python_cron/3125/]
> [https://ci-beam.apache.org/job/beam_PreCommit_Python_commit/14680/]
> self = 
> <apache_beam.typehints.native_type_compatibility_test.NativeTypeCompatibilityTest
>  testMethod=test_convert_to_beam_types>
> def test_convert_to_beam_types(self):
>  typing_types = [
>  bytes,
>  typing.List[bytes],
>  typing.List[typing.Tuple[bytes, int]],
>  typing.Union[int, typing.List[int]]
>  ]
>  beam_types = [
>  bytes,
>  typehints.List[bytes],
>  typehints.List[typehints.Tuple[bytes, int]],
>  typehints.Union[int, typehints.List[int]]
>  ]
>  converted_beam_types = convert_to_beam_types(typing_types)
> > self.assertEqual(converted_beam_types, beam_types)
> E AssertionError: Lists differ: [<type 'str'>, List[Any], List... != [<type 
> 'str'>, List[str], List...
> E 
> E First differing element 1:
> E List[Any]
> E List[str]
> E 
> E - [<type 'str'>, List[Any], List[Tuple[str, int]], Union[List[int], int]]
> E ? ^^^
> E 
> E + [<type 'str'>, List[str], List[Tuple[str, int]], Union[List[int], int]]
> E ? ^^^
> apache_beam/typehints/native_type_compatibility_test.py:214: AssertionError



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

Reply via email to