Skip to content

bpo-44524: Don't modify MRO when inheriting from typing.Annotated - #27841

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
Fidget-Spinner:name_annotated
Aug 25, 2021
Merged

bpo-44524: Don't modify MRO when inheriting from typing.Annotated#27841
serhiy-storchaka merged 5 commits into
python:mainfrom
Fidget-Spinner:name_annotated

Conversation

@Fidget-Spinner

@Fidget-SpinnerFidget-Spinner commented Aug 19, 2021

Copy link
Copy Markdown
Member

Comment threadLib/typing.py
@Fidget-Spinner

Copy link
Copy Markdown
MemberAuthor

Wait don't merge yet, I need to update some things.

@Fidget-Spinner
Fidget-Spinner marked this pull request as draft August 21, 2021 06:51
@Fidget-Spinner

Fidget-Spinner commented Aug 21, 2021

Copy link
Copy Markdown
MemberAuthor

Interestingly, Annotated[Any, 'foo'].__name__ now returns Any, because it sets origin to Any.

This behavior is quite opinionated, but is consistent with how get_type_hints treats Annotated (it strips the Annotated information and just gives the contained type). Nonetheless, I have made it return 'Annotated'.

@Fidget-Spinner
Fidget-Spinner marked this pull request as ready for review August 21, 2021 08:08
@Fidget-SpinnerFidget-Spinner changed the title bpo-44524: Temporarily exclude _name from typing.Annotatedbpo-44524: Don't modify MRO when inheriting from typing.AnnotatedAug 21, 2021
@serhiy-storchaka

Copy link
Copy Markdown
Member

Merge?

@Fidget-Spinner

Copy link
Copy Markdown
MemberAuthor

Merge?

Please do. I don't have permissions to merge this myself.

@serhiy-storchaka
serhiy-storchaka merged commit 23384a1 into python:mainAug 25, 2021
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @Fidget-Spinner for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-botbedevere-bot removed the needs backport to 3.10 only security fixes label Aug 25, 2021
@bedevere-bot

Copy link
Copy Markdown

GH-27950 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 25, 2021
…thonGH-27841)
(cherry picked from commit 23384a1)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Aug 25, 2021
…-27841)
(cherry picked from commit 23384a1)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
@Fidget-Spinner
Fidget-Spinner deleted the name_annotated branch August 26, 2021 12:43
@farcatfarcatmannequin mentioned this pull request Apr 14, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstype-bugAn unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@Fidget-Spinner@serhiy-storchaka@miss-islington@bedevere-bot@the-knights-who-say-ni