Skip to content

Commit 9ba694b

Browse files
committed
Code review
1 parent 96cf94e commit 9ba694b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

doc/user_guide/checkers/features.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ Match Statements checker Messages
694694
:multiple-class-sub-patterns (E1904): *Multiple sub-patterns for attribute %s*
695695
Emitted when there is more than one sub-pattern for a specific attribute in
696696
a class pattern.
697-
:match-class-bind-self (R1905): *Use '%s' instead*
697+
:match-class-bind-self (R1905): *Use '%s() as %s' instead*
698698
Match class patterns are faster if the name binding happens for the whole
699699
pattern and any lookup for `__match_args__` can be avoided.
700700
:match-class-positional-attributes (R1906): *Use keyword attributes instead of positional ones*

pylint/checkers/match_statements_checker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class MatchStatementChecker(BaseChecker):
6464
"attribute in a class pattern.",
6565
),
6666
"R1905": (
67-
"Use '%s' instead",
67+
"Use '%s() as %s' instead",
6868
"match-class-bind-self",
6969
"Match class patterns are faster if the name binding happens "
7070
"for the whole pattern and any lookup for `__match_args__` "
@@ -132,7 +132,7 @@ def visit_matchas(self, node: nodes.MatchAs) -> None:
132132
self.add_message(
133133
"match-class-bind-self",
134134
node=node,
135-
args=(f"{cls_name.name}() as {name}",),
135+
args=(cls_name.name, name),
136136
confidence=HIGH,
137137
)
138138

@@ -197,7 +197,7 @@ def visit_matchclass(self, node: nodes.MatchClass) -> None:
197197
self.add_message(
198198
"match-class-positional-attributes",
199199
node=node,
200-
confidence=HIGH,
200+
confidence=INFERENCE,
201201
)
202202

203203
if (

tests/functional/m/match_class_pattern.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ multiple-class-sub-patterns:49:13:49:29:f2:Multiple sub-patterns for attribute x
99
undefined-variable:55:13:55:23:f2:Undefined variable 'NotDefined':UNDEFINED
1010
match-class-bind-self:60:17:60:18:f3:Use 'int() as y' instead:HIGH
1111
match-class-bind-self:63:17:63:18:f3:Use 'str() as y' instead:HIGH
12-
match-class-positional-attributes:75:13:75:17:f4:Use keyword attributes instead of positional ones:HIGH
13-
match-class-positional-attributes:77:13:77:20:f4:Use keyword attributes instead of positional ones:HIGH
12+
match-class-positional-attributes:75:13:75:17:f4:Use keyword attributes instead of positional ones:INFERENCE
13+
match-class-positional-attributes:77:13:77:20:f4:Use keyword attributes instead of positional ones:INFERENCE

0 commit comments

Comments
 (0)