From dc180dc2775d949c60501fb2c8a76e5c3c031ec6 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 14 Dec 2022 22:50:26 -0500 Subject: [PATCH] Negate ignore_names condition --- src/flake8_builtins/checks.rs | 2 +- src/mccabe/checks.rs | 1 - src/pep8_naming/checks.rs | 2 +- ...uff__pep8_naming__tests__N802_N802.py.snap | 41 +++++++++++++++---- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/flake8_builtins/checks.rs b/src/flake8_builtins/checks.rs index 3ac3ed954f..e611c6be67 100644 --- a/src/flake8_builtins/checks.rs +++ b/src/flake8_builtins/checks.rs @@ -1,4 +1,4 @@ -use rustpython_ast::{Located}; +use rustpython_ast::Located; use crate::ast::types::Range; use crate::checks::{Check, CheckKind}; diff --git a/src/mccabe/checks.rs b/src/mccabe/checks.rs index 6dbfe5e7b1..71caa32c46 100644 --- a/src/mccabe/checks.rs +++ b/src/mccabe/checks.rs @@ -1,7 +1,6 @@ use rustpython_ast::{ExcepthandlerKind, ExprKind, Stmt, StmtKind}; use crate::ast::helpers::identifier_range; - use crate::checks::{Check, CheckKind}; use crate::source_code_locator::SourceCodeLocator; diff --git a/src/pep8_naming/checks.rs b/src/pep8_naming/checks.rs index 9645247acc..6411faa653 100644 --- a/src/pep8_naming/checks.rs +++ b/src/pep8_naming/checks.rs @@ -33,7 +33,7 @@ pub fn invalid_function_name( ignore_names: &[String], locator: &SourceCodeLocator, ) -> Option { - if name.to_lowercase() != name && ignore_names.iter().any(|ignore_name| ignore_name == name) { + if name.to_lowercase() != name && !ignore_names.iter().any(|ignore_name| ignore_name == name) { return Some(Check::new( CheckKind::InvalidFunctionName(name.to_string()), identifier_range(func_def, locator), diff --git a/src/pep8_naming/snapshots/ruff__pep8_naming__tests__N802_N802.py.snap b/src/pep8_naming/snapshots/ruff__pep8_naming__tests__N802_N802.py.snap index 55f29b04e7..b74b8c9044 100644 --- a/src/pep8_naming/snapshots/ruff__pep8_naming__tests__N802_N802.py.snap +++ b/src/pep8_naming/snapshots/ruff__pep8_naming__tests__N802_N802.py.snap @@ -3,21 +3,48 @@ source: src/pep8_naming/mod.rs expression: checks --- - kind: - InvalidFunctionName: tearDownModule + InvalidFunctionName: Bad location: - row: 32 + row: 4 column: 4 end_location: - row: 32 - column: 18 + row: 4 + column: 7 fix: ~ - kind: - InvalidFunctionName: tearDown + InvalidFunctionName: _Bad location: - row: 37 + row: 8 + column: 4 + end_location: + row: 8 + column: 8 + fix: ~ +- kind: + InvalidFunctionName: BAD + location: + row: 12 + column: 4 + end_location: + row: 12 + column: 7 + fix: ~ +- kind: + InvalidFunctionName: BAD_FUNC + location: + row: 16 + column: 4 + end_location: + row: 16 + column: 12 + fix: ~ +- kind: + InvalidFunctionName: testTest + location: + row: 40 column: 8 end_location: - row: 37 + row: 40 column: 16 fix: ~