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:
Simon Brugman 2023-02-16 05:20:33 +01:00 committed by GitHub
parent 147c6ff1db
commit cc30738148
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 1263 additions and 591 deletions

View file

@ -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]