mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Move W605
to the AST checker (#11402)
## Summary This PR moves the `W605` rule to the AST checker. This is part of #11401 ## Test Plan `cargo test`
This commit is contained in:
parent
4b41e4de7f
commit
ca99e9e2f0
5 changed files with 98 additions and 56 deletions
|
@ -2,8 +2,7 @@ use std::iter::FusedIterator;
|
|||
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::AnyNodeRef;
|
||||
use crate::{self as ast, Expr};
|
||||
use crate::{self as ast, AnyNodeRef, AnyStringFlags, Expr};
|
||||
|
||||
/// Unowned pendant to [`ast::Expr`] that stores a reference instead of a owned value.
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
|
@ -452,6 +451,17 @@ pub enum StringLikePart<'a> {
|
|||
FString(&'a ast::FString),
|
||||
}
|
||||
|
||||
impl StringLikePart<'_> {
|
||||
/// Returns the [`AnyStringFlags`] for the current string-like part.
|
||||
pub fn flags(&self) -> AnyStringFlags {
|
||||
match self {
|
||||
StringLikePart::String(string) => AnyStringFlags::from(string.flags),
|
||||
StringLikePart::Bytes(bytes) => AnyStringFlags::from(bytes.flags),
|
||||
StringLikePart::FString(f_string) => AnyStringFlags::from(f_string.flags),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ast::StringLiteral> for StringLikePart<'a> {
|
||||
fn from(value: &'a ast::StringLiteral) -> Self {
|
||||
StringLikePart::String(value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue