python / python/cpython

help() of a method wrongly identifies it as a module-level function

Open
#94,506 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.11 3.12 3.13 stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Consider the following class:

class K:
    def verbify(self):
        """Docstring"""

help() on the unbound method (actually a function) K.verbify wrongly identifies it as a module-level function, displaying this in Python3.10:

Help on function verbify in module __main__:

verbify(self)
    Docstring

It should identify the function using __qualname__ rather than __name__':

>>> K.verbify.__qualname__
'K.verbify'
>>> K.verbify.__name__
'verbify'

In contrast, help() on the bound method correctly identifies that verbify is a method belonging to K: help(K().verbify) displays verbify() method of __main__.K instance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided K.verbify example and compare help(K.verbify) with help(K().verbify). Trace the implementation used by help() and update the unbound-function description to use qualname; done when it identifies K.verbify while preserving the existing bound-method description.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.