ruff/crates
Dhruv Manilawala e474f36473
[ty] Avoid duplicate diagnostic in unpacking (#18897)
## Summary

This PR fixes astral-sh/ty#185 by avoiding to infer the value expression
for an unpacking.

This is done simply by only inferring the value expression in a
non-unpacking branch for assignment statement, for statement, with
statement and comprehensions.

This is a simpler alternative to
https://github.com/astral-sh/ruff/pull/18890 which I only realized in
hindsight! Ideally, the solution would to consider the "unpack" as it's
own region and do all of the inference of every expressions involved in
an unpacking inside the unpack query and then merge the results in the
outer query. This would require access to the `Unpack` ingredient which
is stored on the `Definition`. And, this would require create the said
`Definition`s for all attributes and subscript expressions. It does
simplify the target inference logic by streamlining it into a single
`infer_target` method instead of the `infer_target`/`infer_target_impl`
split.

Additionally, #18890 also solves a couple of TODOs around raising errors
around attribute / subscript assignment.

## Test Plan

Update the existing test, go through a couple of ecosystem diagnostic.
2025-06-24 07:49:44 +05:30
..
ruff Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_annotate_snippets Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_benchmark [ty] Add Tanjun benchmark (#18850) 2025-06-21 18:29:02 +02:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02: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 fix casing of analyze.direction variant names (#18892) 2025-06-23 14:30:30 +02:00
ruff_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_linter [pyupgrade] Extend version detection to include sys.version_info.major (UP036) (#18633) 2025-06-23 20:01:55 +00:00
ruff_macros Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_notebook Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_options_metadata
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 [pylint] Supress PLE2510/2512/2513/2514/2515 autofix if the text contains an odd number of backslashes (#18856) 2025-06-23 10:11:51 +02: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 Disallow newlines in format specifiers of single quoted f- or t-strings (#18708) 2025-06-18 14:56:15 +02:00
ruff_python_resolver Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_semantic [flake8-comprehensions] Handle template strings for comprehension fixes (#18710) 2025-06-19 16:23:46 -05: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 Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04: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 Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_workspace Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ty [ty] Support --python=<symlink to executable> (#18827) 2025-06-21 20:28:47 +01:00
ty_ide [ty] Include imported sub-modules as attributes on modules for completions (#18898) 2025-06-23 12:48:16 -04:00
ty_project [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02:00
ty_python_semantic [ty] Avoid duplicate diagnostic in unpacking (#18897) 2025-06-24 07:49:44 +05:30
ty_server [ty] Add python.ty.disableLanguageServices config (#18230) 2025-06-17 13:50:45 +05:30
ty_test Remove extra dot in rule documentation (#18871) 2025-06-23 00:33:21 +00:00
ty_vendored Sync vendored typeshed stubs (#18679) 2025-06-15 10:20:33 +01:00
ty_wasm [ty] Add infrastructure for AST garbage collection (#18445) 2025-06-05 11:43:18 -04:00