pitrou commented on a change in pull request #10581:
URL: https://github.com/apache/arrow/pull/10581#discussion_r662174593



##########
File path: python/pyarrow/compute.py
##########
@@ -173,22 +176,37 @@ def _handle_options(name, option_class, options, kwargs):
     return options
 
 
-_wrapper_template = dedent("""\
-    def make_wrapper(func, option_class):
-        def {func_name}({args_sig}{kwonly}, memory_pool=None):
-            return func.call([{args_sig}], None, memory_pool)
-        return {func_name}
-    """)
-
-_wrapper_options_template = dedent("""\
-    def make_wrapper(func, option_class):
-        def {func_name}({args_sig}{kwonly}, options=None, memory_pool=None,
-                        **kwargs):
-            options = _handle_options({func_name!r}, option_class, options,
+def _make_generic_wrapper(func_name, func, option_class):
+    if option_class is None:
+        def wrapper(*args, memory_pool=None):
+            return func.call(args, None, memory_pool)
+    else:
+        def wrapper(*args, memory_pool=None, options=None, **kwargs):
+            options = _handle_options(func_name, option_class, options,
                                       kwargs)
-            return func.call([{args_sig}], options, memory_pool)
-        return {func_name}
-    """)
+            return func.call(args, options, memory_pool)
+    return wrapper
+
+
+def _make_dummy_equivalent(args_sig, kwonly, option_class):
+    # Make a dummy callable with the signature that we want to expose
+    # as the real function's signature.
+    str_sig = f"{args_sig}{kwonly}, memory_pool=None"
+    if option_class is not None:
+        str_sig += ", options=None"
+        sig = inspect.signature(option_class)
+        for p in sig.parameters.values():
+            p_default = p.default if p.default is not p.empty else None
+            try:
+                # If the default value cannot be represented accurately,
+                # use None instead

Review comment:
       Hmm, I'm not sure there's an example of this, no. We can probably simply 
assert for now.




-- 
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-unsubscr...@arrow.apache.org

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


Reply via email to