ruff/crates
Andrew Gallant 28b1aa201b
ruff_python_formatter: fix 'dynamic' mode with doctests (#9129)
This fixes a bug where the current indent level was not calculated
correctly for doctests. Namely, it didn't account for the extra indent
level (in terms of ASCII spaces) used by by the PS1 (`>>> `) and PS2
(`... `) prompts. As a result, lines could extend up to 4 spaces beyond
the configured line length limit.

We fix that by passing the `CodeExampleKind` to the `format` routine
instead of just the code itself. In this way, `format` can query whether
there will be any extra indent added _after_ formatting the code and
take that into account for its line length setting.

We add a few regression tests, taken directly from @stinodego's
examples.

Fixes #9126
2023-12-14 09:53:43 -05:00
..
flake8_to_ruff Bump version to v0.1.8 (#9116) 2023-12-13 13:19:51 -05:00
ruff_benchmark Bump ureq from 2.8.0 to 2.9.1 (#8993) 2023-12-04 09:53:25 -06:00
ruff_cache Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_cli Bump version to v0.1.8 (#9116) 2023-12-13 13:19:51 -05:00
ruff_dev Update ruff-dev to use SourceKind (#8878) 2023-11-28 14:27:35 -06:00
ruff_diagnostics Update applicability messages for clarity in tests (#8541) 2023-11-07 16:11:43 +00:00
ruff_formatter remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_index Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_linter Bump version to v0.1.8 (#9116) 2023-12-13 13:19:51 -05:00
ruff_macros remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_notebook Allow transparent cell magics (#8911) 2023-12-07 14:15:43 -06:00
ruff_python_ast Add as_slice method for all string nodes (#9111) 2023-12-13 06:31:20 +00:00
ruff_python_codegen Add as_slice method for all string nodes (#9111) 2023-12-13 06:31:20 +00:00
ruff_python_formatter ruff_python_formatter: fix 'dynamic' mode with doctests (#9129) 2023-12-14 09:53:43 -05:00
ruff_python_index Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_literal remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_python_parser New AST nodes for f-string elements (#8835) 2023-12-07 10:28:05 -06:00
ruff_python_resolver Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_semantic Allow flake8-type-checking rules to automatically quote runtime-evaluated references (#6001) 2023-12-13 03:12:38 +00:00
ruff_python_stdlib Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_python_trivia Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_shrinking Bump version to v0.1.8 (#9116) 2023-12-13 13:19:51 -05:00
ruff_source_file remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_text_size Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
ruff_wasm Bump serde-wasm-bindgen from 0.6.1 to 0.6.3 (#9089) 2023-12-11 08:52:07 +00:00
ruff_workspace config: add new docstring-code-format knob (#8854) 2023-12-13 11:02:11 -05:00