tvalentyn commented on code in PR #27633: URL: https://github.com/apache/beam/pull/27633#discussion_r1272809541
########## sdks/python/apache_beam/typehints/typehints.py: ########## @@ -355,11 +355,12 @@ def is_typing_generic(type_param): Such objects are considered valid type parameters. - Always returns false for Python versions below 3.7. + For Python versions 3.9 and above, also permits types.GenericAlias. """ - if hasattr(typing, '_GenericAlias'): - return isinstance(type_param, typing._GenericAlias) - return False + if hasattr(types, "GenericAlias") and isinstance(type_param, + types.GenericAlias): + return True + return isinstance(type_param, typing._GenericAlias) Review Comment: is `typing._GenericAlias` always defined for all supported python versions? I worry that we might get attribute errors if the first condition doesn't pass and `typing._GenericAlias` becomes deprecated in some (newer?) python version.. Also do we have test coverage for scenario where is_typing_generic returns false ? -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
