mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-14 15:40:20 +00:00
Implement flake8-module-naming
(#2855)
- Implement N999 (following flake8-module-naming) in pep8_naming - Refactor pep8_naming: split rules.rs into file per rule - Documentation for majority of the violations Closes https://github.com/charliermarsh/ruff/issues/2734
This commit is contained in:
parent
147c6ff1db
commit
cc30738148
45 changed files with 1263 additions and 591 deletions
|
@ -3,7 +3,8 @@ use regex::Regex;
|
|||
|
||||
pub static STRING_QUOTE_PREFIX_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r#"^(?i)[urb]*['"](?P<raw>.*)['"]$"#).unwrap());
|
||||
pub static LOWER_OR_UNDERSCORE: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[a-z_]+$").unwrap());
|
||||
pub static LOWER_OR_UNDERSCORE: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"^[a-z][a-z0-9_]*$").unwrap());
|
||||
|
||||
pub fn is_lower(s: &str) -> bool {
|
||||
let mut cased = false;
|
||||
|
@ -64,10 +65,15 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_is_lower_underscore() {
|
||||
assert!(is_lower_with_underscore("a"));
|
||||
assert!(is_lower_with_underscore("abc"));
|
||||
assert!(is_lower_with_underscore("abc0"));
|
||||
assert!(is_lower_with_underscore("abc_"));
|
||||
assert!(is_lower_with_underscore("a_b_c"));
|
||||
assert!(!is_lower_with_underscore("a-b-c"));
|
||||
assert!(!is_lower_with_underscore("a_B_c"));
|
||||
assert!(!is_lower_with_underscore("0abc"));
|
||||
assert!(!is_lower_with_underscore("_abc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue