mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +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
|
@ -1,9 +1,9 @@
|
|||
use crate::string_token_flags::StringKind;
|
||||
use ruff_python_ast::AnyStringKind;
|
||||
|
||||
/// The context representing the current f-string that the lexer is in.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct FStringContext {
|
||||
kind: StringKind,
|
||||
kind: AnyStringKind,
|
||||
|
||||
/// The level of nesting for the lexer when it entered the current f-string.
|
||||
/// The nesting level includes all kinds of parentheses i.e., round, square,
|
||||
|
@ -17,7 +17,7 @@ pub(crate) struct FStringContext {
|
|||
}
|
||||
|
||||
impl FStringContext {
|
||||
pub(crate) const fn new(kind: StringKind, nesting: u32) -> Self {
|
||||
pub(crate) const fn new(kind: AnyStringKind, nesting: u32) -> Self {
|
||||
debug_assert!(kind.is_f_string());
|
||||
Self {
|
||||
kind,
|
||||
|
@ -26,7 +26,7 @@ impl FStringContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn kind(&self) -> StringKind {
|
||||
pub(crate) const fn kind(&self) -> AnyStringKind {
|
||||
debug_assert!(self.kind.is_f_string());
|
||||
self.kind
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue