mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 07:37:38 +00:00
Simplify formatting of strings by using flags from the AST nodes (#10489)
This commit is contained in:
parent
fc792d1d2e
commit
7caf0d064a
22 changed files with 725 additions and 809 deletions
|
@ -4,10 +4,9 @@
|
|||
//! loosely based on the token definitions found in the [CPython source].
|
||||
//!
|
||||
//! [CPython source]: https://github.com/python/cpython/blob/dfc2e065a2e71011017077e549cd2f9bf4944c54/Include/internal/pycore_token.h;
|
||||
use crate::string_token_flags::StringKind;
|
||||
use crate::Mode;
|
||||
|
||||
use ruff_python_ast::{Int, IpyEscapeKind};
|
||||
use ruff_python_ast::{AnyStringKind, Int, IpyEscapeKind};
|
||||
use std::fmt;
|
||||
|
||||
/// The set of tokens the Python source code can be tokenized in.
|
||||
|
@ -44,11 +43,11 @@ pub enum Tok {
|
|||
value: Box<str>,
|
||||
/// Flags that can be queried to determine the quote style
|
||||
/// and prefixes of the string
|
||||
kind: StringKind,
|
||||
kind: AnyStringKind,
|
||||
},
|
||||
/// Token value for the start of an f-string. This includes the `f`/`F`/`fr` prefix
|
||||
/// and the opening quote(s).
|
||||
FStringStart(StringKind),
|
||||
FStringStart(AnyStringKind),
|
||||
/// Token value that includes the portion of text inside the f-string that's not
|
||||
/// part of the expression part and isn't an opening or closing brace.
|
||||
FStringMiddle {
|
||||
|
@ -56,7 +55,7 @@ pub enum Tok {
|
|||
value: Box<str>,
|
||||
/// Flags that can be queried to determine the quote style
|
||||
/// and prefixes of the string
|
||||
kind: StringKind,
|
||||
kind: AnyStringKind,
|
||||
},
|
||||
/// Token value for the end of an f-string. This includes the closing quote.
|
||||
FStringEnd,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue