Skip to content

Commit 43b300a

Browse files
committed
Change the name of the message.
1 parent 26a0f0a commit 43b300a

File tree

12 files changed

+26
-26
lines changed

12 files changed

+26
-26
lines changed

doc/data/messages/u/unreachable-match-patterns/bad.py renamed to doc/data/messages/b/bare-name-capture-pattern/bad.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
color = blue
77
match color:
8-
case red: # [unreachable-match-patterns]
8+
case red: # [bare-name-capture-pattern]
99
print("I see red!")
10-
case green: # [unreachable-match-patterns]
10+
case green: # [bare-name-capture-pattern]
1111
print("Grass is green")
1212
case blue:
1313
print("I'm feeling the blues :(")
File renamed without changes.

doc/data/ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ line-length = 103
55
extend-exclude = [
66
"messages/d/duplicate-argument-name/bad.py",
77
"messages/s/syntax-error/bad.py",
8-
"messages/u/unreachable-match-patterns/bad.py",
8+
"messages/b/bare-name-capture-pattern/bad.py",
99
# syntax error in newer python versions
1010
"messages/s/star-needs-assignment-target/bad.py",
1111
"messages/i/invalid-star-assignment-target/bad.py",

doc/user_guide/checkers/features.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ Verbatim name of the checker is ``match_statements``.
680680

681681
Match Statements checker Messages
682682
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
683-
:unreachable-match-patterns (E1901): *The name capture `case %s` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this.*
683+
:bare-name-capture-pattern (E1901): *The name capture `case %s` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this.*
684684
Emitted when a name capture pattern in a match statement is used and there
685685
are case statements below it.
686686

doc/user_guide/messages/messages_overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ All messages in the error category:
6363
error/bad-str-strip-call
6464
error/bad-string-format-type
6565
error/bad-super-call
66+
error/bare-name-capture-pattern
6667
error/bidirectional-unicode
6768
error/broken-collections-callable
6869
error/broken-noreturn
@@ -165,7 +166,6 @@ All messages in the error category:
165166
error/unexpected-special-method-signature
166167
error/unhashable-member
167168
error/unpacking-non-sequence
168-
error/unreachable-match-patterns
169169
error/unrecognized-inline-option
170170
error/unrecognized-option
171171
error/unsubscriptable-object

doc/whatsnew/fragments/7128.new_check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Add ``match-statements`` checker and the following message:
2-
``unreachable-match-patterns``.
2+
``bare-name-capture-pattern``.
33
This will emit an error message when a name capture pattern is used in a match statement which would make the remaining patterns unreachable.
44
This code is a SyntaxError at runtime.
55

pylint/checkers/match_statements_checker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ class MatchStatementChecker(BaseChecker):
2424
"E1901": (
2525
"The name capture `case %s` makes the remaining patterns unreachable. "
2626
"Use a dotted name (for example an enum) to fix this.",
27-
"unreachable-match-patterns",
27+
"bare-name-capture-pattern",
2828
"Emitted when a name capture pattern in a match statement is used "
2929
"and there are case statements below it.",
3030
)
3131
}
3232

33-
@only_required_for_messages("unreachable-match-patterns")
33+
@only_required_for_messages("bare-name-capture-pattern")
3434
def visit_match(self, node: nodes.Match) -> None:
3535
"""Check if a name capture pattern prevents the other cases from being
3636
reached.
@@ -43,7 +43,7 @@ def visit_match(self, node: nodes.Match) -> None:
4343
and idx < len(node.cases) - 1
4444
):
4545
self.add_message(
46-
"unreachable-match-patterns",
46+
"bare-name-capture-pattern",
4747
node=case,
4848
args=case.pattern.name.name,
4949
confidence=HIGH,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Functional tests for the ``bare-name-capture-pattern`` message"""
2+
3+
4+
a = 'a'
5+
b = 'b'
6+
s = 'a'
7+
8+
9+
match s:
10+
case a: # [bare-name-capture-pattern]
11+
pass
12+
case b: # [bare-name-capture-pattern]
13+
pass
14+
case s:
15+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bare-name-capture-pattern:10:0:None:None::The name capture `case a` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this.:HIGH
2+
bare-name-capture-pattern:12:0:None:None::The name capture `case b` makes the remaining patterns unreachable. Use a dotted name (for example an enum) to fix this.:HIGH

0 commit comments

Comments
 (0)