Skip to content

Commit 5502cd3

Browse files
committed
Minor improvement
1 parent 768c4c9 commit 5502cd3

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pylint/checkers/match_statements_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def visit_match(self, node: nodes.Match) -> None:
120120
def visit_matchas(self, node: nodes.MatchAs) -> None:
121121
match node:
122122
case nodes.MatchAs(
123-
parent=nodes.MatchClass(cls=nodes.Name() as cls_name),
123+
parent=nodes.MatchClass(cls=nodes.Name() as cls_name, patterns=[_]),
124124
name=nodes.AssignName(name=name),
125125
pattern=None,
126126
):

tests/functional/m/match_class_pattern.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def f3(x):
6363
case str(y): ... # [match-class-bind-self]
6464
case str() as y: ...
6565
case str("Hello" as y): ...
66+
case tuple(y, 2): ... # pylint: disable=too-many-positional-sub-patterns
67+
case tuple((y, 2)): ...
6668

6769
def f4(x):
6870
"""Check for positional attributes if keywords could be used."""

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:73:13:73:17:f4:Use keyword attributes instead of positional ones:HIGH
13-
match-class-positional-attributes:75:13:75: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:HIGH
13+
match-class-positional-attributes:77:13:77:20:f4:Use keyword attributes instead of positional ones:HIGH

0 commit comments

Comments
 (0)