Added checks for invalid usage of continue/break/return in except* block#18132
Merged
JukkaL merged 8 commits intopython:masterfrom Nov 21, 2024
Merged
Added checks for invalid usage of continue/break/return in except* block#18132JukkaL merged 8 commits intopython:masterfrom
JukkaL merged 8 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Collaborator
brianschubert
left a comment
There was a problem hiding this comment.
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.
Contributor
Author
|
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.
JukkaL
reviewed
Nov 11, 2024
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
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
Comment on lines
+227
to
+229
| from typing import Sequence | ||
| class range(Sequence[int]): | ||
| def __init__(self, __x: int, __y: int = ..., __z: int = ...) -> None: pass |
Collaborator
There was a problem hiding this comment.
Can this be replaced by a dummy list?
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
hauntsaninja
pushed a commit
that referenced
this pull request
Nov 14, 2024
The vast majority of mypy's code follows PEP 8 naming conventions. However, we currently don't enforce this in the linter config. I noticed this in a recent PR which included a `camelCase` name: #18132 (comment). Ruff has some rules to enforce PEP 8 naming style ([pep8-naming](https://docs.astral.sh/ruff/rules/#pep8-naming-n)). I think it would be a good idea to enable some of these to help contributors catch naming discrepancies before PR review. We have a few notable exceptions to PEP 8 naming (e.g. functions named to match ast node names), but these are easily accounted for with some config file ignores and handful of `# noqa`'s.
Contributor
Author
|
Is this PR ready to merge? |
JukkaL
approved these changes
Nov 21, 2024
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
Looks good to me, thanks for the updates!
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)