damccorm commented on code in PR #33427:
URL: https://github.com/apache/beam/pull/33427#discussion_r1905675980
##########
sdks/python/apache_beam/typehints/native_type_compatibility.py:
##########
@@ -216,6 +275,24 @@ def convert_collections_to_typing(typ):
return typ
+def is_builtin(typ):
+ if typ in _BUILTINS:
+ return True
+ return getattr(typ, '__origin__', None) in _BUILTINS
+
+
+# During type inference of WindowedValue, we need to pass in the inner value
+# type. This cannot be achieved immediately with WindowedValue class because it
+# is not parameterized. Changing it to a generic class (e.g. WindowedValue[T])
+# could work in theory. However, the class is cythonized and it seems that
+# cython does not handle generic classes well.
+# The workaround here is to create a separate class solely for the type
+# inference purpose. This class should never be used for creating instances.
+class TypedWindowedValue(Generic[T]):
Review Comment:
It doesn't look like we actually use this class yet - is that right? If so,
should we just defer this change until we need it?
##########
sdks/python/apache_beam/typehints/native_type_compatibility.py:
##########
@@ -197,6 +226,36 @@ def convert_builtin_to_typing(typ):
return typ
+def convert_typing_to_builtin(typ):
+ """Converts a given typing collections type to its builtin counterpart.
+
+ Args:
+ typ: A typing type (e.g., typing.List[int]).
+
+ Returns:
+ type: The corresponding builtin type (e.g., list).
Review Comment:
```suggestion
type: The corresponding builtin type (e.g., list[int]).
```
Nit: this should still match the input, right?
##########
sdks/python/apache_beam/typehints/native_type_compatibility.py:
##########
@@ -99,14 +115,25 @@ def _match_issubclass(match_against):
return lambda user_type: _safe_issubclass(user_type, match_against)
+def _is_primative(user_type, primative):
Review Comment:
```suggestion
def _is_primitive(user_type, primative):
```
Nit: here and elsewhere
--
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]