ruff/crates
Brent Westbrook e4423044f8
[`ruff`] Validate arguments before offering a fix (`RUF056`) (#18631)
## Summary

Fixes https://github.com/astral-sh/ruff/issues/18628 by avoiding a fix
if there are "unknown" arguments, including any keyword arguments and
more than the expected 2 positional arguments.

I'm a bit on the fence here because it also seems reasonable to avoid a
diagnostic at all. Especially in the final test case I added (`not
my_dict.get(default=False)`), the hint suggesting to remove
`default=False` seems pretty misleading. At the same time, I guess the
diagnostic at least calls attention to the call site, which could help
to fix the missing argument bug too.

As I commented on the issue, I double-checked that keyword arguments are
invalid as far back as Python 3.8, even though the positional-only
marker was only added to the
[docs](https://docs.python.org/3.11/library/stdtypes.html#dict.get) in
3.12 (link is to 3.11, showing its absence).

## Test Plan

New tests derived from the bug report

## Stabilization

This was planned to be stabilized in 0.12, and the bug is less severe
than some others, but if there's nobody opposed, I will plan **not to
stabilize** this one for now.
2025-06-13 23:07:02 +00:00
..
ruff Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
ruff_annotate_snippets Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_benchmark [ty] Add --config-file CLI arg (#18083) 2025-05-27 08:00:38 +02:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_dev Remove `Message::to_rule` (#18447) 2025-06-05 12:48:29 -04:00
ruff_diagnostics Add a `ViolationMetadata::rule` method (#18234) 2025-05-28 09:27:09 -04:00
ruff_formatter Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_graph [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_linter [`ruff`] Validate arguments before offering a fix (`RUF056`) (#18631) 2025-06-13 23:07:02 +00:00
ruff_macros Remove `Message::to_rule` (#18447) 2025-06-05 12:48:29 -04:00
ruff_notebook Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_options_metadata [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ruff_python_ast [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_ast_integration_tests [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_codegen [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_formatter [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_parser [syntax-errors] Raise unsupported syntax error for template strings prior to Python 3.14 (#18664) 2025-06-13 14:04:37 -05:00
ruff_python_resolver Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_semantic [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_stdlib Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_trivia Treat `ty: ` comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_server Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
ruff_source_file Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_text_size Add rustfmt.toml file (#18197) 2025-05-19 11:40:58 -04:00
ruff_wasm Bump 0.11.13 (#18484) 2025-06-05 15:18:38 -05:00
ruff_workspace Remove `Message::to_rule` (#18447) 2025-06-05 12:48:29 -04:00
ty [ty] Add partial support for `TypeIs` (#18589) 2025-06-13 15:27:45 -07:00
ty_ide [ty] Add some "inside string" tests for `object.<CURSOR>` completions 2025-06-12 07:50:49 -04:00
ty_project [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ty_python_semantic [ty] Add partial support for `TypeIs` (#18589) 2025-06-13 15:27:45 -07:00
ty_server Support cancellation requests (#18627) 2025-06-12 22:08:42 +02:00
ty_test [ty] Pull types on synthesized Python files created by mdtest (#18539) 2025-06-12 10:32:17 +01:00
ty_vendored [ty] Generate the top and bottom materialization of a type (#18594) 2025-06-12 12:06:16 +05:30
ty_wasm [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00