diff --git a/resources/test/fixtures/N818.py b/resources/test/fixtures/N818.py index 0b1f4b54cf..f993759d24 100644 --- a/resources/test/fixtures/N818.py +++ b/resources/test/fixtures/N818.py @@ -10,5 +10,9 @@ class C(Exception): pass -class D(AnotherError): +class D(BaseException): + pass + + +class E(AnotherError): pass diff --git a/src/pep8_naming/checks.rs b/src/pep8_naming/checks.rs index 9cbf01880f..b85055c20d 100644 --- a/src/pep8_naming/checks.rs +++ b/src/pep8_naming/checks.rs @@ -224,7 +224,7 @@ pub fn error_suffix_on_exception_name( ) -> Option { if bases.iter().any(|base| { if let ExprKind::Name { id, .. } = &base.node { - id.ends_with("Exception") || id.ends_with("Error") + id == "Exception" || id.ends_with("Error") } else { false } diff --git a/src/snapshots/ruff__linter__tests__N818_N818.py.snap b/src/snapshots/ruff__linter__tests__N818_N818.py.snap index a705736500..3eadb42f47 100644 --- a/src/snapshots/ruff__linter__tests__N818_N818.py.snap +++ b/src/snapshots/ruff__linter__tests__N818_N818.py.snap @@ -12,12 +12,12 @@ expression: checks column: 0 fix: ~ - kind: - ErrorSuffixOnExceptionName: D + ErrorSuffixOnExceptionName: E location: - row: 13 + row: 17 column: 0 end_location: - row: 15 + row: 19 column: 0 fix: ~