← 返回首页
gh-89547: Add support for nesting special forms like Final by hmc-cs-mdrissi · Pull Request #116092 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-89547: Add support for nesting special forms like Final#116092

Closed
hmc-cs-mdrissi wants to merge 1 commit into
python:mainfrom
hmc-cs-mdrissi:support_nested_special_forms
Closed

gh-89547: Add support for nesting special forms like Final#116092
hmc-cs-mdrissi wants to merge 1 commit into
python:mainfrom
hmc-cs-mdrissi:support_nested_special_forms

Conversation

hmc-cs-mdrissi commented Feb 29, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Resolves this issue. The main goal was to permit ClassVar[Final[int]] and Final[ClassVar[int]]. This drops validation check that Final/ClassVar argument is not a special form.

This does allow some silly cases like ClassVar[ClassVar[int]] but I think it's simpler to allow them then have more complex validation rules at runtime. I did not remove special form check for other forms so Union[ClassVar[int], int] remains forbidden and list[ClassVar[int]] is also forbidden. There already was a test case that list[ClassVar[int]] fails.

I also added couple tests for Annotated to ensure it can nest freely with ClassVar/Final.

ghost commented Feb 29, 2024

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:

Copy link
Copy Markdown
Contributor Author

Hmm, for CLA it's probably easier if I close and remake the PR with email of this account. That's my work email, which has a github account, but it's github enterprise account and unsure how to sign with it.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

1 participant

Footer

© 2026 GitHub, Inc.