mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 09:22:19 +00:00
Remove unnecessary quote-stripping method (#3372)
This commit is contained in:
parent
8437399496
commit
c0ad875339
2 changed files with 3 additions and 24 deletions
|
@ -38,22 +38,9 @@ pub fn is_upper(s: &str) -> bool {
|
|||
cased
|
||||
}
|
||||
|
||||
/// Remove prefixes (u, r, b) and quotes around a string. This expects the given
|
||||
/// string to be a valid Python string representation, it doesn't do any
|
||||
/// validation.
|
||||
pub fn strip_quotes_and_prefixes(s: &str) -> &str {
|
||||
match STRING_QUOTE_PREFIX_REGEX.captures(s) {
|
||||
Some(caps) => match caps.name("raw") {
|
||||
Some(m) => m.as_str(),
|
||||
None => s,
|
||||
},
|
||||
None => s,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::str::{is_lower, is_upper, strip_quotes_and_prefixes};
|
||||
use crate::str::{is_lower, is_upper};
|
||||
|
||||
#[test]
|
||||
fn test_is_lower() {
|
||||
|
@ -76,12 +63,4 @@ mod tests {
|
|||
assert!(!is_upper(""));
|
||||
assert!(!is_upper("_"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_quotes_and_prefixes() {
|
||||
assert_eq!(strip_quotes_and_prefixes(r#"'a'"#), "a");
|
||||
assert_eq!(strip_quotes_and_prefixes(r#"bur'a'"#), "a");
|
||||
assert_eq!(strip_quotes_and_prefixes(r#"UrB'a'"#), "a");
|
||||
assert_eq!(strip_quotes_and_prefixes(r#""a""#), "a");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue