ruff/crates
Shaygan Hooshyari 4d109514d6
[`flake8-type-checking`] Support auto-quoting when annotations contain quotes (#11811)
## Summary

This PR updates the fix generation logic for auto-quoting an annotation
to generate an edit even when there's a quote character present.

The logic uses the visitor pattern, maintaining it's state on where it
is and generating the string value one node at a time. This can be
considered as a specialized form of `Generator`. The state required to
maintain is whether we're currently inside a `typing.Literal` or
`typing.Annotated` because the string value in those types should not be
un-quoted i.e., `Generic[Literal["int"]]` should become
`"Generic[Literal['int']]`, the quotes inside the `Literal` should be
preserved.

Fixes: https://github.com/astral-sh/ruff/issues/9137

## Test Plan

Add various test cases to validate this change, validate the snapshots.
There are no ecosystem changes to go through.

---------

Signed-off-by: Shaygan <hey@glyphack.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2024-10-23 16:34:03 +05:30
..
red_knot Upgrade salsa (#13757) 2024-10-15 11:06:32 +00:00
red_knot_python_semantic [red-knot] Use track_caller for expect_ methods (#13884) 2024-10-23 12:48:19 +02:00
red_knot_server Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
red_knot_test [red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804) 2024-10-22 07:42:40 +00:00
red_knot_vendored Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
red_knot_wasm Use backticks for code in red-knot messages (#13599) 2024-10-02 03:14:28 +00:00
red_knot_workspace [red-knot] rename {Class,Module,Function} => {Class,Module,Function}Literal (#13873) 2024-10-22 22:10:53 +02:00
ruff Modernize build scripts (#13837) 2024-10-20 22:35:35 +01:00
ruff_benchmark Bump MSRV to Rust 1.80 (#13826) 2024-10-20 10:55:36 +02:00
ruff_cache Fix cache key collisions for paths with separators (#12159) 2024-07-03 07:36:46 -05:00
ruff_db Speed up mdtests (#13832) 2024-10-21 20:06:41 +01:00
ruff_dev Alternate quotes for strings inside f-strings in preview (#13860) 2024-10-23 07:57:53 +02:00
ruff_diagnostics [Minor typo] Fix article in "an fix" (#12797) 2024-08-10 21:22:00 -04:00
ruff_formatter Use backticks for code in red-knot messages (#13599) 2024-10-02 03:14:28 +00:00
ruff_graph Bump MSRV to Rust 1.80 (#13826) 2024-10-20 10:55:36 +02:00
ruff_index [red-knot] small efficiency improvements and bugfixes to use-def map building (#12373) 2024-07-18 09:24:58 -07:00
ruff_linter [`flake8-type-checking`] Support auto-quoting when annotations contain quotes (#11811) 2024-10-23 16:34:03 +05:30
ruff_macros Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
ruff_notebook Bump MSRV to Rust 1.80 (#13826) 2024-10-20 10:55:36 +02:00
ruff_python_ast Alternate quotes for strings inside f-strings in preview (#13860) 2024-10-23 07:57:53 +02:00
ruff_python_ast_integration_tests [internal] `ComparableExpr` (f)strings and bytes made invariant under concatenation (#13301) 2024-09-25 16:58:57 +02:00
ruff_python_codegen Simplify iteration idioms (#13834) 2024-10-20 22:25:27 +01:00
ruff_python_formatter Alternate quotes for strings inside f-strings in preview (#13860) 2024-10-23 07:57:53 +02:00
ruff_python_index Enable token-based rules on source with syntax errors (#11950) 2024-07-02 08:57:46 +00:00
ruff_python_literal Remove some unused `pub` functions (#11576) 2024-05-28 09:56:51 -04:00
ruff_python_parser Short circuit `lex_identifier` if the name is longer or shorter than any known keyword (#13815) 2024-10-19 11:07:15 +00:00
ruff_python_resolver chore(deps): update rust crate insta to v1.38.0 (#10701) 2024-04-01 15:44:30 +00:00
ruff_python_semantic Simplify iteration idioms (#13834) 2024-10-20 22:25:27 +01:00
ruff_python_stdlib Harmonise methods for distinguishing different Python source types (#13682) 2024-10-09 13:18:52 +00:00
ruff_python_trivia [red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804) 2024-10-22 07:42:40 +00:00
ruff_python_trivia_integration_tests Build `CommentRanges` outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_server Upgrade to Rust 1.82 (#13816) 2024-10-19 16:05:50 +02:00
ruff_source_file [red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804) 2024-10-22 07:42:40 +00:00
ruff_text_size [red-knot] type inference/checking test framework (#13636) 2024-10-08 12:33:19 -07:00
ruff_wasm Changelog for Ruff v0.7 (#13794) 2024-10-17 16:14:21 +00:00
ruff_workspace Simplify iteration idioms (#13834) 2024-10-20 22:25:27 +01:00