Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Sep 1, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jun 8, 2023

@AlexWaygood AlexWaygood changed the title Simplify the implementation of typing.Annotated gh-105509: Simplify the implementation of typing.Annotated Jun 8, 2023
…IG57j.rst

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

@sobolevn sobolevn left a comment

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
Copy link
Member Author

AlexWaygood commented Jun 8, 2023

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.

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

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