This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Pydoc: better support of method aliases
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: miss-islington, serhiy.storchaka, terry.reedy, yselivanov
Priority: normal Keywords: patch

Created on 2018-10-12 15:50 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9823 merged serhiy.storchaka, 2018-10-12 15:59
PR 10407 merged miss-islington, 2018-11-08 06:48
PR 10408 merged miss-islington, 2018-11-08 06:48
Messages (6)
msg327593 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-12 15:50
Pydoc supports aliases. If the alias is defined in the same class

    class A:
        def foo(self, x=42): pass
        bar = 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.
msg327608 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-10-12 18:27
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.
msg327609 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-12 18:51
The original function is present too.

 |  tkraise(self, aboveThis=None)
 |      Raise this widget in the stacking order.
msg329456 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-08 06:48
New changeset a44d34e17908a49d584f86c4f8642a50707b7150 by Serhiy Storchaka in branch 'master':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
https://github.com/python/cpython/commit/a44d34e17908a49d584f86c4f8642a50707b7150
msg329458 - (view) Author: miss-islington (miss-islington) Date: 2018-11-08 07:08
New changeset 9d3658147b56e24e96e174510b6ee91c8141e530 by Miss Islington (bot) in branch '3.7':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
https://github.com/python/cpython/commit/9d3658147b56e24e96e174510b6ee91c8141e530
msg329459 - (view) Author: miss-islington (miss-islington) Date: 2018-11-08 07:20
New changeset 11a33e171b89ea9267672b0664d739ca06e459ca by Miss Islington (bot) in branch '3.6':
bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
https://github.com/python/cpython/commit/11a33e171b89ea9267672b0664d739ca06e459ca
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79147
2018-11-08 07:24:13serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 2.7
2018-11-08 07:20:31miss-islingtonsetmessages: + msg329459
2018-11-08 07:08:09miss-islingtonsetnosy: + miss-islington
messages: + msg329458
2018-11-08 06:48:33miss-islingtonsetpull_requests: + pull_request9692
2018-11-08 06:48:27miss-islingtonsetpull_requests: + pull_request9691
2018-11-08 06:48:15serhiy.storchakasetmessages: + msg329456
2018-10-29 18:33:35serhiy.storchakasetassignee: serhiy.storchaka
2018-10-12 18:51:47serhiy.storchakasetmessages: + msg327609
2018-10-12 18:27:58terry.reedysetnosy: + terry.reedy
messages: + msg327608
2018-10-12 15:59:57serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request9200
2018-10-12 15:50:11serhiy.storchakacreate