ruff/crates
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
..
red_knot ruff_db: switch diagnostic rendering over to std::fmt::Display 2025-04-02 11:01:16 -04:00
red_knot_ide [red-knot] Add Type::TypeVar variant (#17102) 2025-04-03 14:36:29 -04:00
red_knot_project Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
red_knot_python_semantic Enable overindented docs lint (#17182) 2025-04-03 20:27:11 +01:00
red_knot_server red_knot: use Diagnostic inside of red knot 2025-04-02 10:10:01 -04:00
red_knot_test Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
red_knot_vendored Sync vendored typeshed stubs (#17106) 2025-04-01 17:44:27 +01:00
red_knot_wasm ruff_db: switch diagnostic rendering over to std::fmt::Display 2025-04-02 11:01:16 -04:00
ruff Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_annotate_snippets Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_benchmark red_knot: use Diagnostic inside of red knot 2025-04-02 10:10:01 -04:00
ruff_cache
ruff_db ruff_db: simplify lifetimes on DiagnosticDisplay 2025-04-02 12:47:02 -04:00
ruff_dev Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_diagnostics
ruff_formatter Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_graph Pass ParserOptions to the parser (#16220) 2025-02-19 10:50:50 -05:00
ruff_index [red-knot] Don't use separate ID types for each alist (#16415) 2025-02-28 14:55:55 -05:00
ruff_linter [syntax-errors] Duplicate attributes in match class pattern (#17186) 2025-04-03 17:55:37 -04:00
ruff_macros Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_notebook Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_ast Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_ast_integration_tests Visit Identifier node as part of the SourceOrderVisitor (#17110) 2025-04-01 16:58:09 +02:00
ruff_python_codegen Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_formatter Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_index
ruff_python_literal Preserve triple quotes and prefixes for strings (#15818) 2025-02-04 08:41:06 -05:00
ruff_python_parser [syntax-errors] Duplicate attributes in match class pattern (#17186) 2025-04-03 17:55:37 -04:00
ruff_python_resolver Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_semantic Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_python_stdlib
ruff_python_trivia [red-knot] Ignore surrounding whitespace when looking for <!-- snapshot-diagnostics --> directives in mdtests (#16380) 2025-02-27 13:25:31 +00:00
ruff_python_trivia_integration_tests Pass ParserOptions to the parser (#16220) 2025-02-19 10:50:50 -05:00
ruff_server Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171) 2025-04-03 15:59:44 +00:00
ruff_source_file
ruff_text_size [ruff] itertools.starmap(..., zip(...)) (RUF058) (#15483) 2025-01-16 15:18:12 +01:00
ruff_wasm Bump 0.11.3 (#17173) 2025-04-03 09:05:40 -04:00
ruff_workspace [flake8-import-conventions] Add import numpy.typing as npt to default flake8-import-conventions.aliases (#17133) 2025-04-02 09:25:46 +02:00