mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-09 18:02:19 +00:00
Add support for reformatting byte strings (#3176)
This commit is contained in:
parent
f967f344fc
commit
1e7233a8eb
20 changed files with 90 additions and 59 deletions
10
crates/ruff_python/src/bytes.rs
Normal file
10
crates/ruff_python/src/bytes.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
/// See: <https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals>
|
||||
pub const TRIPLE_QUOTE_PREFIXES: &[&str] = &[
|
||||
"br'''", "rb'''", "bR'''", "Rb'''", "Br'''", "rB'''", "RB'''", "BR'''", "b'''", "br\"\"\"",
|
||||
"rb\"\"\"", "bR\"\"\"", "Rb\"\"\"", "Br\"\"\"", "rB\"\"\"", "RB\"\"\"", "BR\"\"\"", "b\"\"\"",
|
||||
"B\"\"\"",
|
||||
];
|
||||
pub const SINGLE_QUOTE_PREFIXES: &[&str] = &[
|
||||
"br'", "rb'", "bR'", "Rb'", "Br'", "rB'", "RB'", "BR'", "b'", "br\"", "rb\"", "bR\"", "Rb\"",
|
||||
"Br\"", "rB\"", "RB\"", "BR\"", "b\"", "B\"",
|
||||
];
|
|
@ -1,7 +1,8 @@
|
|||
pub mod builtins;
|
||||
pub mod bytes;
|
||||
pub mod future;
|
||||
pub mod identifiers;
|
||||
pub mod keyword;
|
||||
pub mod string;
|
||||
pub mod str;
|
||||
pub mod sys;
|
||||
pub mod typing;
|
||||
|
|
|
@ -6,7 +6,7 @@ pub const TRIPLE_QUOTE_PREFIXES: &[&str] = &[
|
|||
"u\"\"\"", "u'''", "r\"\"\"", "r'''", "U\"\"\"", "U'''", "R\"\"\"", "R'''", "\"\"\"", "'''",
|
||||
];
|
||||
pub const SINGLE_QUOTE_PREFIXES: &[&str] = &[
|
||||
"u\"", "u'", "r\"", "r'", "u\"", "u'", "r\"", "r'", "U\"", "U'", "R\"", "R'", "\"", "'",
|
||||
"u\"", "u'", "r\"", "r'", "U\"", "U'", "R\"", "R'", "\"", "'",
|
||||
];
|
||||
pub const TRIPLE_QUOTE_SUFFIXES: &[&str] = &["\"\"\"", "'''"];
|
||||
pub const SINGLE_QUOTE_SUFFIXES: &[&str] = &["\"", "'"];
|
||||
|
@ -53,7 +53,7 @@ pub fn strip_quotes_and_prefixes(s: &str) -> &str {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::string::{is_lower, is_upper, strip_quotes_and_prefixes};
|
||||
use crate::str::{is_lower, is_upper, strip_quotes_and_prefixes};
|
||||
|
||||
#[test]
|
||||
fn test_is_lower() {
|
Loading…
Add table
Add a link
Reference in a new issue