-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add new checker and bare-name-capture-pattern
message.
#10424
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
base: main
Are you sure you want to change the base?
Add new checker and bare-name-capture-pattern
message.
#10424
Conversation
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10424 +/- ##
==========================================
- Coverage 95.86% 95.85% -0.02%
==========================================
Files 176 177 +1
Lines 19155 19197 +42
==========================================
+ Hits 18363 18401 +38
- Misses 792 796 +4
π New features to boost your workflow:
|
f1ca097
to
0e5ef7c
Compare
remaining-patterns-unreachable
checker.unreachable-match-patterns
message and new checker.
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 check!
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.
Seems very sensible to me!
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.
Let's put this in 4.0 once the remarks are handled !
This comment has been minimized.
This comment has been minimized.
``unreachable-match-patterns``. This will emit an error message when a name capture pattern is used in a match statement which would make the remaining patterns unreachable. This code is a SyntaxError at runtime. Closes pylint-dev#7128
for more information, see https://pre-commit.ci
β¦ 3.10 or higher.
Co-authored-by: Jacob Walls <[email protected]>
Co-authored-by: Jacob Walls <[email protected]>
ID. (pylint/script/get_unused_message_id_category.py).
text in the checker code.
The example intentionally contains a `SyntaxError` which will also raise a `SyntaxError` from Ruff.
Co-authored-by: Pierre Sassoulas <[email protected]>
ad3ec16
to
26a0f0a
Compare
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Pierre Sassoulas <[email protected]>
unreachable-match-patterns
message and new checker.bare-name-capture-pattern
message.
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.
Great work ! I'll let @jacobtylerwalls merge
Co-authored-by: Jacob Walls <[email protected]>
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.
Thanks for working on it @mbyrnepr2! This looks like a great addition.
I saw the discussion where the error should be emitted. Just to provide one more data point, pylance
has a similar error message: Irrefutable pattern is allowed only for the last case statement
which is emitted for the cases which currently trigger the check.
There is also another message Pattern will never be matched for subject type "Never"
for the second and third cases but that's likely based on the type inference result.
Co-authored-by: Marc Mueller <[email protected]>
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 034d78f |
Type of Changes
Description
This will emit an error message when a name capture pattern is used in a match statement which would make the remaining patterns unreachable. This code is a SyntaxError at runtime.
Closes #7128