jrmccluskey commented on code in PR #27633:
URL: https://github.com/apache/beam/pull/27633#discussion_r1273591349


##########
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:
   I believe typing._GenericAlias will always have a definition at this point. 
Once we drop support for 3.8 we won't have to check for `types.GenericAlias`'s 
existence either. I added some explicit unit test cases to typehints_test.py 
just to double-check that we had some coverage



-- 
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]

Reply via email to