-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Added checks for invalid usage of continue/break/return in except* block #18132
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks good overall.
A few comments for you to consider, plus one issue that needs to be fixed in the tests:
This comment has been minimized.
This comment has been minimized.
Thanks for the comments! I've pushed a commit with all the changes. |
…trol flow in except* block
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few minor comments.
…e except* block, other minor fixes
for more information, see https://pre-commit.ci
test-data/unit/check-python311.test
Outdated
from typing import Sequence | ||
class range(Sequence[int]): | ||
def __init__(self, __x: int, __y: int = ..., __z: int = ...) -> None: pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be replaced by a dummy list?
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #18123
This PR addresses an issue where mypy incorrectly allows break/continue/return statements in the except* block. (see https://peps.python.org/pep-0654/#forbidden-combinations)