Skip to content

gh-139817: Attribute __qualname__ is added to TypeAliasType - #139919

Merged
JelleZijlstra merged 8 commits into
python:mainfrom
efimov-mikhail:issue-139817-type-alias-qualname
Oct 15, 2025
Merged

gh-139817: Attribute __qualname__ is added to TypeAliasType#139919
JelleZijlstra merged 8 commits into
python:mainfrom
efimov-mikhail:issue-139817-type-alias-qualname

Conversation

@efimov-mikhail

@efimov-mikhailefimov-mikhail commented Oct 10, 2025

Copy link
Copy Markdown
Member

@efimov-mikhailefimov-mikhail changed the title gh-139817: Parameter __qualname__ is added to TypeAliasTypegh-139817: Attribute __qualname__ is added to TypeAliasTypeOct 10, 2025
@efimov-mikhail

Copy link
Copy Markdown
MemberAuthor

CC @sobolevn

@efimov-mikhail

Copy link
Copy Markdown
MemberAuthor

I'm totally not sure that this solution is fully correct.
But it works in typical situations, and improves introspection.

@JelleZijlstraJelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment threadObjects/typevarobject.c
Comment threadObjects/typevarobject.c
Comment threadLib/test/test_type_aliases.py
@efimov-mikhail

Copy link
Copy Markdown
MemberAuthor

I've added some tests on __name__ and __qualname__, docs and news

@AlexWaygood
AlexWaygood removed their request for review October 11, 2025 23:56
Comment threadObjects/typevarobject.c Outdated
@efimov-mikhail

Copy link
Copy Markdown
MemberAuthor

I've added new constructor parameter: X = TypeAliasType("X", int, qualname="foo.X"). It looks like there is no much extra complexity and this solution is OK. But we can provide another variant, if it's needed.

Comment threadObjects/typevarobject.c
@efimov-mikhail

efimov-mikhail commented Oct 15, 2025

Copy link
Copy Markdown
MemberAuthor

Sorry for ping, @JelleZijlstra.

This PR could be merged, or I've missed something?

@JelleZijlstra
JelleZijlstra merged commit f673f0e into python:mainOct 15, 2025
45 checks passed
@efimov-mikhail

Copy link
Copy Markdown
MemberAuthor

Thanks!

StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@efimov-mikhail@JelleZijlstra