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 2020/11/03 13:42:36 UTC

[GitHub] [beam] tvalentyn commented on a change in pull request #13246: [BEAM-4091] Add warning when ignoring type hints

tvalentyn commented on a change in pull request #13246:
URL: https://github.com/apache/beam/pull/13246#discussion_r516341288



##########
File path: sdks/python/apache_beam/transforms/ptransform.py
##########
@@ -1000,17 +1000,24 @@ def expand(self, pcoll):
   @wraps(fn)
   def callable_ptransform_factory(*args, **kwargs):
     res = _PTransformFnPTransform(fn, *args, **kwargs)
+    # Apply type hints applied before or after the ptransform_fn decorator,
+    # falling back on PTransform defaults.
+    # If the @with_{input,output}_types decorator comes before ptransform_fn,
+    # the type hints get applied to this function. If it comes after they will
+    # get applied to fn, and @wraps will copy the _type_hints attribute to
+    # this function.
+    type_hints = get_type_hints(callable_ptransform_factory)
     if ptransform_fn_typehints_enabled:
-      # Apply type hints applied before or after the ptransform_fn decorator,
-      # falling back on PTransform defaults.
-      # If the @with_{input,output}_types decorator comes before ptransform_fn,
-      # the type hints get applied to this function. If it comes after they will
-      # get applied to fn, and @wraps will copy the _type_hints attribute to
-      # this function.
-      type_hints = get_type_hints(callable_ptransform_factory)
       res._set_type_hints(type_hints.with_defaults(res.get_type_hints()))
       _LOGGER.debug(
           'type hints for %s: %s', res.default_label(), res.get_type_hints())
+    elif type_hints:
+      _LOGGER.warning(

Review comment:
       How noisy would this log be ? Does it warrant a `warning` or should it be an `info` instead ?




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

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