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
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?
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.
Activity
efimov-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.
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.
gh-139817: Attribute `__qualname__` is added to `TypeAliasType` (#139919
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?
pythongh-139817: Fix indentation of `.. versionadded::` note for `Typ…
gh-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.
minaminan22-dot commented on Oct 15, 2025
pythongh-139817: Fix refleak in TypeAliasType(qualname=non_string)
encukou commented on Oct 16, 2025
Commit f673f0e has a refleak. Fix in #140197.
gh-139817: Fix refleak in TypeAliasType(qualname=non_string) (GH-140197)
JelleZijlstra commented on Oct 16, 2025
Thanks, sorry for missing the refleak!
encukou commented on Oct 16, 2025
Thanks for the test that caught the refleak early :)
pythongh-139817: Attribute `__qualname__` is added to `TypeAliasType` (…
pythongh-139817: typing docs: Fix indentation of `.. versionadded::` …
pythongh-139817: Fix refleak in TypeAliasType(qualname=non_string) (p…
Initial support for Python 3.15.0a8 (#21255)
Initial support for Python 3.15.0a8 (#21255)