mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05: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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user