mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-16 16:40:19 +00:00
Allow Locator#slice
to take Ranged
(#6922)
## Summary As a small quality-of-life improvement, the locator can now slice like `locator.slice(stmt)` instead of requiring `locator.slice(stmt.range())`. ## Test Plan `cargo test`
This commit is contained in:
parent
58f5f27dc3
commit
aea7500c1e
42 changed files with 89 additions and 96 deletions
|
@ -788,12 +788,12 @@ fn format_docstring(string_part: &FormatStringPart, f: &mut PyFormatter) -> Form
|
|||
let locator = f.context().locator();
|
||||
|
||||
// Black doesn't change the indentation of docstrings that contain an escaped newline
|
||||
if locator.slice(string_part.range()).contains("\\\n") {
|
||||
if locator.slice(string_part).contains("\\\n") {
|
||||
return string_part.fmt(f);
|
||||
}
|
||||
|
||||
let (normalized, _) = normalize_string(
|
||||
locator.slice(string_part.range()),
|
||||
locator.slice(string_part),
|
||||
string_part.preferred_quotes,
|
||||
string_part.is_raw_string,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue