Skip to content

Commit df3384f

Browse files
authored
Also check the existence of _fields in addition to__annotations__ for NamedTuple. (#36337)
* Check the existence of _fields instead of __annotations__ for NamedTuple. * Still need to check the existence of __annotations__. * Format the changes
1 parent 3534960 commit df3384f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

sdks/python/apache_beam/typehints/native_type_compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _match_is_exactly_sequence(user_type):
164164
def match_is_named_tuple(user_type):
165165
return (
166166
_safe_issubclass(user_type, typing.Tuple) and
167-
hasattr(user_type, '__annotations__'))
167+
hasattr(user_type, '__annotations__') and hasattr(user_type, '_fields'))
168168

169169

170170
def _match_is_optional(user_type):

0 commit comments

Comments
 (0)