You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "damccorm (via GitHub)" <gi...@apache.org> on 2023/01/25 15:19:24 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #25147: Update typehint code to allow primitive composite types in python 3.9+

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


##########
sdks/python/apache_beam/typehints/typehints.py:
##########
@@ -389,10 +389,12 @@ def validate_composite_type_param(type_param, error_msg_prefix):
   if sys.version_info.major == 3 and sys.version_info.minor >= 10:
     if isinstance(type_param, types.UnionType):
       is_not_type_constraint = False
-  is_forbidden_type = (
-      isinstance(type_param, type) and type_param in DISALLOWED_PRIMITIVE_TYPES)
+  if sys.version_info.major == 3 and sys.version_info.minor < 9:

Review Comment:
   Could you add a comment explaining the pre/post 3.9, 3.10 logic in this block?



##########
sdks/python/apache_beam/typehints/typehints_test.py:
##########
@@ -379,9 +379,10 @@ def test_getitem_params_must_be_type_or_constraint(self):
       typehints.Tuple[5, [1, 3]]
     self.assertTrue(e.exception.args[0].startswith(expected_error_prefix))
 
-    with self.assertRaises(TypeError) as e:
-      typehints.Tuple[list, dict]
-    self.assertTrue(e.exception.args[0].startswith(expected_error_prefix))
+    if sys.version_info < (3, 9):
+      with self.assertRaises(TypeError) as e:
+        typehints.Tuple[list, dict]
+      self.assertTrue(e.exception.args[0].startswith(expected_error_prefix))

Review Comment:
   Can we add else clauses to these tests that validate that they don't throw?



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