11from collections import OrderedDict
22from contextlib import ExitStack
3- import functools
43import inspect
54import itertools
65import logging
@@ -49,14 +48,17 @@ def _axis_method_wrapper(attr_name, method_name, *, doc_sub=None):
4948 dedented to simplify further manipulations.
5049 """
5150
52- method = getattr (maxis .Axis , method_name )
5351 get_method = attrgetter (f"{ attr_name } .{ method_name } " )
5452
55- @functools .wraps (method )
5653 def wrapper (self , * args , ** kwargs ):
5754 return get_method (self )(* args , ** kwargs )
5855
59- doc = wrapper .__doc__
56+ # Manually copy the signature instead of using functools.wraps because
57+ # displaying the Axis method source when asking for the Axes method source
58+ # would be confusing.
59+ wrapped_method = getattr (maxis .Axis , method_name )
60+ wrapper .__signature__ = inspect .signature (wrapped_method )
61+ doc = wrapped_method .__doc__
6062 if doc :
6163 doc_sub = {"this Axis" : f"the { attr_name } " , ** (doc_sub or {})}
6264 for k , v in doc_sub .items ():
@@ -66,7 +68,14 @@ def wrapper(self, *args, **kwargs):
6668 doc = doc .replace (k , v )
6769 wrapper .__doc__ = inspect .cleandoc (doc )
6870
69- return wrapper
71+ class Placeholder :
72+ def __set_name__ (self , owner , name ):
73+ wrapper .__module__ = owner .__module__
74+ wrapper .__name__ = name
75+ wrapper .__qualname__ = f"{ owner .__qualname__ } .{ name } "
76+ setattr (owner , name , wrapper )
77+
78+ return Placeholder ()
7079
7180
7281def _process_plot_format (fmt ):
0 commit comments