You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pydoc supports aliases. If the alias is defined in the same class
classA:
deffoo(self, x=42): passbar=foo
it will render the docstring only for the original function. For the alias it will output just "bar = foo(self, x=42)".
But this doesn't work if the original function or alias are inherited. It often happened in the tkinter and turtle modules which have a hierarchy of classes, and aliases defined in parent classes. Compare for example the rendering for methods itemconfig and lift in help(tkinter.Listbox).
The proposed PR makes pydoc detecting aliases for inherited methods.
| itemconfig = itemconfigure(self, index, cnf=None, **kw)
|
| itemconfigure(self, index, cnf=None, **kw)
| Configure resources of an ITEM.
Alias of function in inherited namespace.
| lift = tkraise(self, aboveThis=None)
| Raise this widget in the stacking order.
This is also marked as an alias. The difference is the inclusions of the docstring of the original. I think it should be, since it would not otherwise be present in the help output.
Activity
serhiy-storchaka commentedon Oct 12, 2018
Pydoc supports aliases. If the alias is defined in the same class
it will render the docstring only for the original function. For the alias it will output just "bar = foo(self, x=42)".
But this doesn't work if the original function or alias are inherited. It often happened in the tkinter and turtle modules which have a hierarchy of classes, and aliases defined in parent classes. Compare for example the rendering for methods itemconfig and lift in help(tkinter.Listbox).
The proposed PR makes pydoc detecting aliases for inherited methods.
terryjreedy commentedon Oct 12, 2018
What do you mean by 'does not work'.
Alias of function in same namespace.
| itemconfig = itemconfigure(self, index, cnf=None, **kw)
|
| itemconfigure(self, index, cnf=None, **kw)
| Configure resources of an ITEM.
Alias of function in inherited namespace.
| lift = tkraise(self, aboveThis=None)
| Raise this widget in the stacking order.
This is also marked as an alias. The difference is the inclusions of the docstring of the original. I think it should be, since it would not otherwise be present in the help output.
serhiy-storchaka commentedon Oct 12, 2018
The original function is present too.
| tkraise(self, aboveThis=None)
| Raise this widget in the stacking order.
serhiy-storchaka commentedon Nov 8, 2018
New changeset a44d34e by Serhiy Storchaka in branch 'master':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
a44d34e
miss-islington commentedon Nov 8, 2018
New changeset 9d36581 by Miss Islington (bot) in branch '3.7':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
9d36581
miss-islington commentedon Nov 8, 2018
New changeset 11a33e1 by Miss Islington (bot) in branch '3.6':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
11a33e1