Skip to content

bpo-46539: Pass status of special typeforms to forward references #30926

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

Merged
merged 6 commits into from
Jan 27, 2022

Conversation

GBeauregard
Copy link
Contributor

@GBeauregard GBeauregard commented Jan 26, 2022

Previously this didn't matter because there weren't any valid code paths
that could trigger a type conversion with a special form, but after the bug
fix for Annotated wrapping special forms it's now possible to annotate
something like Annotated['ClassVar[int]', (3, 4)]. This change would
also be needed for proposed future changes, such as allowing ClassVar
and Final to nest each other in dataclasses.

https://bugs.python.org/issue46539

Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
@JelleZijlstra JelleZijlstra self-requested a review January 26, 2022 20:41
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

(This is not a full review.)

@GBeauregard GBeauregard changed the title bpo-46539: Pass status of special forms to forward references bpo-46539: Pass status of special typeforms to forward references Jan 26, 2022
@GBeauregard GBeauregard marked this pull request as ready for review January 27, 2022 01:58
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Okay, looks good. Taking into account the recent discussions of backports for typing.py, should this be backported?

@gvanrossum gvanrossum merged commit ced5005 into python:main Jan 27, 2022
@JelleZijlstra
Copy link
Member

I think it should be, this one is even more clearly a bugfix (and frankly, not that likely to appear in practice).

@JelleZijlstra JelleZijlstra added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Jan 27, 2022
@miss-islington
Copy link
Contributor

Thanks @GBeauregard for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @GBeauregard for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 27, 2022
…thonGH-30926)

Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
(cherry picked from commit ced5005)

Co-authored-by: Gregory Beauregard <greg@greg.red>
@bedevere-bot
Copy link

GH-30946 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Jan 27, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 27, 2022
…thonGH-30926)

Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
(cherry picked from commit ced5005)

Co-authored-by: Gregory Beauregard <greg@greg.red>
@bedevere-bot
Copy link

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

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jan 27, 2022
miss-islington added a commit that referenced this pull request Jan 27, 2022
…-30926)

Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
(cherry picked from commit ced5005)

Co-authored-by: Gregory Beauregard <greg@greg.red>
miss-islington added a commit that referenced this pull request Jan 27, 2022
…-30926)

Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
(cherry picked from commit ced5005)

Co-authored-by: Gregory Beauregard <greg@greg.red>
@GBeauregard GBeauregard deleted the fix-special-forms branch February 6, 2022 09:03
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…thonGH-30926)

Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
(cherry picked from commit ced5005)

Co-authored-by: Gregory Beauregard <greg@greg.red>
Daraan added a commit to Daraan/typing_extensions that referenced this pull request Mar 26, 2025
Sign up for free to 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.

6 participants