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]