robertwb commented on a change in pull request #12459:
URL: https://github.com/apache/beam/pull/12459#discussion_r465402767



##########
File path: sdks/python/apache_beam/dataframe/frame_base.py
##########
@@ -226,6 +232,68 @@ def wrapper(self, *args, **kwargs):
   return wrapper
 
 
+def maybe_inplace(func):
+  @functools.wraps(func)
+  def wrapper(self, inplace=False, **kwargs):
+    result = func(self, **kwargs)
+    if inplace:
+      self._expr = result._expr
+    else:
+      return result
+
+  return wrapper
+
+
+def args_to_kwargs(base_type):
+  def wrap(func):
+    if sys.version_info < (3, ):
+      getargspec = inspect.getargspec
+    else:
+      getargspec = inspect.getfullargspec
+
+    # This is used to map all positional arguments to keyword arguments.
+    base = getattr(base_type, func.__name__)
+    while hasattr(base, '__wrapped__'):
+      base = base.__wrapped__
+    base_argspec = getargspec(base)
+    arg_names = base_argspec.args
+
+    # These are used to populate any defaults in base for arguments in func.
+    if base_argspec.defaults:
+      arg_to_default = dict(
+          zip(
+              base_argspec.args[-len(base_argspec.defaults):],
+              base_argspec.defaults))
+    else:
+      arg_to_default = {}
+
+    unwrapped_func = func
+    while hasattr(unwrapped_func, '__wrapped__'):
+      unwrapped_func = unwrapped_func.__wrapped__
+    # args that do not have defaults in func, but do have defaults in base

Review comment:
       I think I never want one without the other, but I'll see what it looks 
like to break them up. 




----------------------------------------------------------------
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:
[email protected]


Reply via email to