mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-16 08:30:30 +00:00
Rename AnyStringKind
-> AnyStringFlags
(#11405)
## Summary This PR renames `AnyStringKind` to `AnyStringFlags` and `AnyStringFlags` to `AnyStringFlagsInner`. The main motivation is to have consistent usage of "kind" and "flags". For each string kind, it's "flags" like `StringLiteralFlags`, `BytesLiteralFlags`, and `FStringFlags` but it was `AnyStringKind` for the "any" variant.
This commit is contained in:
parent
be0ccabbaa
commit
6ecb4776de
54 changed files with 378 additions and 371 deletions
|
@ -5,7 +5,7 @@
|
|||
//!
|
||||
//! [CPython source]: https://github.com/python/cpython/blob/dfc2e065a2e71011017077e549cd2f9bf4944c54/Grammar/Tokens
|
||||
|
||||
use ruff_python_ast::{AnyStringKind, BoolOp, Int, IpyEscapeKind, Operator, UnaryOp};
|
||||
use ruff_python_ast::{AnyStringFlags, BoolOp, Int, IpyEscapeKind, Operator, UnaryOp};
|
||||
use std::fmt;
|
||||
|
||||
use crate::Mode;
|
||||
|
@ -44,11 +44,11 @@ pub enum Tok {
|
|||
value: Box<str>,
|
||||
/// Flags that can be queried to determine the quote style
|
||||
/// and prefixes of the string
|
||||
kind: AnyStringKind,
|
||||
flags: AnyStringFlags,
|
||||
},
|
||||
/// Token value for the start of an f-string. This includes the `f`/`F`/`fr` prefix
|
||||
/// and the opening quote(s).
|
||||
FStringStart(AnyStringKind),
|
||||
FStringStart(AnyStringFlags),
|
||||
/// 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 +56,7 @@ pub enum Tok {
|
|||
value: Box<str>,
|
||||
/// Flags that can be queried to determine the quote style
|
||||
/// and prefixes of the string
|
||||
kind: AnyStringKind,
|
||||
flags: AnyStringFlags,
|
||||
},
|
||||
/// Token value for the end of an f-string. This includes the closing quote.
|
||||
FStringEnd,
|
||||
|
@ -245,8 +245,8 @@ impl fmt::Display for Tok {
|
|||
Int { value } => write!(f, "{value}"),
|
||||
Float { value } => write!(f, "{value}"),
|
||||
Complex { real, imag } => write!(f, "{real}j{imag}"),
|
||||
String { value, kind } => {
|
||||
write!(f, "{}", kind.format_string_contents(value))
|
||||
String { value, flags } => {
|
||||
write!(f, "{}", flags.format_string_contents(value))
|
||||
}
|
||||
FStringStart(_) => f.write_str("FStringStart"),
|
||||
FStringMiddle { value, .. } => f.write_str(value),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue