`__annotate__` functions generated by CPython for class methods have an incorrect `__qualname__` · Issue #137814 · python/cpython · GitHub
Skip to content

__annotate__ functions generated by CPython for class methods have an incorrect __qualname__ #137814

Description

@DavidCEllis

Bug report

Bug description:

The __qualname__ of __annotate__ functions of methods of classes incorrectly refers to the __annotate__ function of the class itself.

class Example:
    x: int
    def func(self, x: int) -> str: ...

print(f"{Example.__annotate__.__qualname__ = }")
print(f"{Example.func.__annotate__.__qualname__ = }")

Output:

Example.__annotate__.__qualname__ = 'Example.__annotate__'
Example.func.__annotate__.__qualname__ = 'Example.__annotate__'

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions