Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pydoc: better support of method aliases #79147

Closed
serhiy-storchaka opened this issue Oct 12, 2018 · 6 comments
Closed

Pydoc: better support of method aliases #79147

serhiy-storchaka opened this issue Oct 12, 2018 · 6 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 34966
Nosy @terryjreedy, @serhiy-storchaka, @1st1, @miss-islington
PRs
  • bpo-34966: Improve support of method aliases in pydoc. #9823
  • [3.7] bpo-34966: Improve support of method aliases in pydoc. (GH-9823) #10407
  • [3.6] bpo-34966: Improve support of method aliases in pydoc. (GH-9823) #10408
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2018-11-08.07:24:13.687>
    created_at = <Date 2018-10-12.15:50:11.626>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'Pydoc: better support of method aliases'
    updated_at = <Date 2018-11-08.07:24:13.686>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-11-08.07:24:13.686>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2018-11-08.07:24:13.687>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2018-10-12.15:50:11.626>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34966
    keywords = ['patch']
    message_count = 6.0
    messages = ['327593', '327608', '327609', '329456', '329458', '329459']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'serhiy.storchaka', 'yselivanov', 'miss-islington']
    pr_nums = ['9823', '10407', '10408']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34966'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 12, 2018
    @terryjreedy
    Copy link
    Member

    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
    Copy link
    Member Author

    The original function is present too.

    | tkraise(self, aboveThis=None)
    | Raise this widget in the stacking order.

    @serhiy-storchaka serhiy-storchaka self-assigned this Oct 29, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset a44d34e by Serhiy Storchaka in branch 'master':
    bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
    a44d34e

    @miss-islington
    Copy link
    Contributor

    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
    Copy link
    Contributor

    New changeset 11a33e1 by Miss Islington (bot) in branch '3.6':
    bpo-34966: Improve support of method aliases in pydoc. (GH-9823)
    11a33e1

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants