mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 18:02:58 +00:00
Implement a common trait for the string flags (#11564)
This commit is contained in:
parent
6be00d5775
commit
246a3388ee
20 changed files with 184 additions and 153 deletions
|
@ -37,7 +37,7 @@ use unicode_normalization::UnicodeNormalization;
|
|||
use ruff_python_ast::{
|
||||
str::Quote,
|
||||
str_prefix::{AnyStringPrefix, FStringPrefix},
|
||||
AnyStringFlags, Int, IpyEscapeKind,
|
||||
AnyStringFlags, Int, IpyEscapeKind, StringFlags,
|
||||
};
|
||||
use ruff_text_size::{TextLen, TextRange, TextSize};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use ruff_python_ast::AnyStringFlags;
|
||||
use ruff_python_ast::{AnyStringFlags, StringFlags};
|
||||
|
||||
/// The context representing the current f-string that the lexer is in.
|
||||
#[derive(Debug)]
|
||||
|
@ -36,13 +36,13 @@ impl FStringContext {
|
|||
}
|
||||
|
||||
/// Returns the quote character for the current f-string.
|
||||
pub(crate) const fn quote_char(&self) -> char {
|
||||
pub(crate) fn quote_char(&self) -> char {
|
||||
self.flags.quote_style().as_char()
|
||||
}
|
||||
|
||||
/// Returns the triple quotes for the current f-string if it is a triple-quoted
|
||||
/// f-string, `None` otherwise.
|
||||
pub(crate) const fn triple_quotes(&self) -> Option<&'static str> {
|
||||
pub(crate) fn triple_quotes(&self) -> Option<&'static str> {
|
||||
if self.is_triple_quoted() {
|
||||
Some(self.flags.quote_str())
|
||||
} else {
|
||||
|
@ -56,7 +56,7 @@ impl FStringContext {
|
|||
}
|
||||
|
||||
/// Returns `true` if the current f-string is a triple-quoted f-string.
|
||||
pub(crate) const fn is_triple_quoted(&self) -> bool {
|
||||
pub(crate) fn is_triple_quoted(&self) -> bool {
|
||||
self.flags.is_triple_quoted()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use bstr::ByteSlice;
|
||||
|
||||
use ruff_python_ast::{self as ast, AnyStringFlags, Expr};
|
||||
use ruff_python_ast::{self as ast, AnyStringFlags, Expr, StringFlags};
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
|
||||
use crate::lexer::{LexicalError, LexicalErrorType};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
use ruff_python_ast::{AnyStringFlags, BoolOp, Int, IpyEscapeKind, Operator, UnaryOp};
|
||||
use ruff_python_ast::{AnyStringFlags, BoolOp, Int, IpyEscapeKind, Operator, StringFlags, UnaryOp};
|
||||
|
||||
/// The set of tokens the Python source code can be tokenized in.
|
||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue