Skip to content

gh-105509: Simplify the implementation of typing.Annotated#105510

Merged
hauntsaninja merged 4 commits into
python:mainfrom
AlexWaygood:refactor-annotated
Sep 1, 2023
Merged

gh-105509: Simplify the implementation of typing.Annotated#105510
hauntsaninja merged 4 commits into
python:mainfrom
AlexWaygood:refactor-annotated

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Jun 8, 2023

Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood changed the title Simplify the implementation of typing.Annotated gh-105509: Simplify the implementation of typing.Annotated Jun 8, 2023
Comment thread Misc/NEWS.d/next/Library/2023-06-08-15-56-45.gh-issue-105509.YIG57j.rst Outdated
…IG57j.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

@sobolevn sobolevn 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.

Quick note: right now it is possible to use Annotated in isinstance(1, typing.Annotated). However, it does not make much sense anyway:

>>> isinstance(typing.Annotated[int, 1], typing.Annotated)
False

With this patch applied it will raise a TypeError.

I don't think that it is a big deal.

@AlexWaygood

AlexWaygood commented Jun 8, 2023

Copy link
Copy Markdown
Member Author

Yeah. You can think up ways that this could break people's code, if they're doing strange things with typing at runtime (and as such, I definitely don't think it should be backported). But I don't think we're changing anything about the public API for this symbol here, so nothing about the contract is being broken.

@hauntsaninja hauntsaninja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me! Couldn't find any isinstance(..., Annotated) in a quick search

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the implementation of typing.Annotated

5 participants