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

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
merged 9 commits into from
Jul 23, 2024

Conversation

Eclips4
Copy link
Member

@Eclips4 Eclips4 commented Jul 22, 2024

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

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.

Yes, you need a recursive visitor for this.

This comment has been minimized.

@Eclips4 Eclips4 requested a review from sobolevn July 22, 2024 19:22
mypy/fastparse.py Outdated Show resolved Hide resolved
mypy/fastparse.py Outdated Show resolved Hide resolved
mypy/fastparse.py Outdated Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

@Eclips4 Eclips4 requested a review from sobolevn July 22, 2024 20:18
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.

Thank you, one last nit :)

mypy/fastparse.py Outdated Show resolved Hide resolved

This comment has been minimized.

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.

Thanks! Congrats on your first mypy PR :)

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

mypy/fastparse.py Outdated Show resolved Hide resolved
@Eclips4 Eclips4 requested a review from JelleZijlstra July 23, 2024 18:43
Copy link
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
19 checks passed
@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