Skip to content

PEP 695: Add detection and error reporting for the use of incorrect expressions within the scope of a type parameter and a type alias#17560

Merged
sobolevn merged 9 commits into
python:masterfrom
Eclips4:more-detection-and-errors
Jul 23, 2024
Merged

Conversation

@Eclips4

@Eclips4 Eclips4 commented Jul 22, 2024

Copy link
Copy Markdown
Member

This fixes part of #15238:

Add detection and error reporting for use of assignment expressions, yield, yield from, and await expressions within the type parameter scope; see this section of PEP for details

@JelleZijlstra

Copy link
Copy Markdown
Member

This seems incomplete because it detects these cases only at the top level, not anywhere within the expression. For example, def f[x: (T + (yield 42))](): pass should also be flagged.

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

Yes, you need a recursive visitor for this.

@github-actions

This comment has been minimized.

@Eclips4
Eclips4 requested a review from sobolevn July 22, 2024 19:22
Comment thread mypy/fastparse.py Outdated
Comment thread mypy/fastparse.py Outdated
Comment thread mypy/fastparse.py Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Eclips4
Eclips4 requested a review from sobolevn July 22, 2024 20:18

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

Thank you, one last nit :)

Comment thread mypy/fastparse.py Outdated
Co-authored-by: sobolevn <mail@sobolevn.me>
@github-actions

This comment has been minimized.

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

Thanks! Congrats on your first mypy PR :)

I will leave it open for a couple of days for others to have a potential feedback.

Comment thread mypy/fastparse.py Outdated
@Eclips4
Eclips4 requested a review from JelleZijlstra July 23, 2024 18:43
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sobolevn
sobolevn merged commit f2cee90 into python:master Jul 23, 2024
@Eclips4
Eclips4 deleted the more-detection-and-errors branch July 27, 2024 13:11
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.

3 participants