You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2023/01/17 16:00:12 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #24986: Add explicit error for PEP 585 type hints

damccorm commented on code in PR #24986:
URL: https://github.com/apache/beam/pull/24986#discussion_r1072392767


##########
sdks/python/apache_beam/typehints/typehints.py:
##########
@@ -1190,6 +1190,12 @@ def normalize(x, none_as_type=False):
     return type(None)
   elif x in _KNOWN_PRIMITIVE_TYPES:
     return _KNOWN_PRIMITIVE_TYPES[x]
+  elif sys.version_info >= (3, 9) and isinstance(x, types.GenericAlias):
+    # TODO(https://github.com/apache/beam/issues/23366): handle PEP 585
+    # generic type hints properly
+    raise TypeError(
+        'PEP 585 generic type hints like %s are not yet supported, '
+        'use typing module containers instead.' % x)

Review Comment:
   Could we drop a link to either docs on typing module containers?



##########
sdks/python/apache_beam/typehints/typehints.py:
##########
@@ -1190,6 +1190,12 @@ def normalize(x, none_as_type=False):
     return type(None)
   elif x in _KNOWN_PRIMITIVE_TYPES:
     return _KNOWN_PRIMITIVE_TYPES[x]
+  elif sys.version_info >= (3, 9) and isinstance(x, types.GenericAlias):
+    # TODO(https://github.com/apache/beam/issues/23366): handle PEP 585
+    # generic type hints properly
+    raise TypeError(
+        'PEP 585 generic type hints like %s are not yet supported, '
+        'use typing module containers instead.' % x)

Review Comment:
   Could we drop a link to docs on typing module containers?



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org