ruff/crates/ruff_python_parser/resources
Brent Westbrook 24b1b1d52c
[syntax-errors] Duplicate attributes in match class pattern (#17186)
Summary
--

Detects duplicate attributes in a `match` class pattern:

```python
match x:
    case Class(x=1, x=2): ...
```

which are more analogous to the similar check for mapping patterns than
to the
multiple assignments rule.

I also realized that both this and the mapping check would only work on
top-level patterns, despite the possibility that they can be nested
inside other
patterns:

```python
match x:
    case [{"x": 1, "x": 2}]: ...  # false negative in the old version
```

and moved these checks into the recursive pattern visitor instead.

I also tidied up some of the names like the `multiple_case_assignment`
function
and the `MultipleCaseAssignmentVisitor`, which are now doing more than
checking
for multiple assignments.

Test Plan
--

New inline tests for both classes and mappings.
2025-04-03 17:55:37 -04:00
..
inline [syntax-errors] Duplicate attributes in match class pattern (#17186) 2025-04-03 17:55:37 -04:00
invalid Consider 2-character EOL before line continuation (#12035) 2024-06-26 14:00:48 +05:30
valid [syntax-errors] Starred expressions in return, yield, and for (#17134) 2025-04-02 08:38:25 -04:00
.editorconfig Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30