GeezerVison is showing github.com — TypeAliasType objects have no `__qualname__` · Issue #139817 · python/cpython
TypeAliasType objects have no __qualname__ #139817Labels interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug report
Bug description:
This means that introspection is worse for type statements declared e.g. within class bodies.
A
cc @JelleZijlstra
CPython versions tested on:
3.12, 3.13, 3.14, 3.15, CPython main branch
Operating systems tested on:
No response
Linked PRs
Activityefimov-mikhail commented on Oct 9, 2025 I would like to make a PR for adding __qualname__, but maybe I'll be needed some guidance about it. JelleZijlstra commented on Oct 10, 2025 There's two parts to this: adding a __qualname__ attribute to the TypeAliasType object (easy), and setting it correctly at runtime (hard). This will likely need changes to the bytecode, so that when we generate code for a type statement we pass the right qualname in. (Unless there's some clever way we can get it at runtime in the implementation of INTRINSIC_TYPEALIAS?) That probably means we can do it only in 3.15 at this point. Reacted by Mikhail Efimov, Xuanteng Huang and JoBe xuantengh commented on Oct 10, 2025 JelleZijlstra commented on Oct 10, 2025 Vec[int] is an instance of types.GenericAlias, not TypeAliasType. It should not be part of this issue and should not have a __qualname__ attribute.
efimov-mikhail commented on Oct 15, 2025 Qualified names for TypeAliasType have been added on main branch. So, this issue may be closed? Do we want to add qualified names for other typing objects or port them onto previous versions? added 2 commits that reference this issue on Oct 15, 2025gh-139817: typing docs: Fix indentation of `.. versionadded::` note f… JelleZijlstra commented on Oct 15, 2025 Thank you! We shouldn't backport this because it's a new feature, and if any other typing objects have similar issues, we should open a new issue. So that means we're done here. Reacted by Alex Waygood and Mikhail Efimov minaminan22-dot commented on Oct 15, 2025 encukou commented on Oct 16, 2025 JelleZijlstra commented on Oct 16, 2025 Thanks, sorry for missing the refleak! Reacted by Mikhail Efimov encukou commented on Oct 16, 2025 Thanks for the test that caught the refleak early :) Reacted by Mikhail Efimov
MetadataMetadatainterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DevelopmentNo branches or pull requestsIssue actions
|