Fix N818 range (#1503)

This commit is contained in:
Harutaka Kawamura 2022-12-31 21:43:03 +09:00 committed by GitHub
parent 14248cb8cb
commit 938ad9a39e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View file

@ -582,9 +582,12 @@ where
}
if self.settings.enabled.contains(&CheckCode::N818) {
if let Some(check) =
pep8_naming::checks::error_suffix_on_exception_name(stmt, bases, name)
{
if let Some(check) = pep8_naming::checks::error_suffix_on_exception_name(
stmt,
bases,
name,
self.locator,
) {
self.add_check(check);
}
}

View file

@ -246,6 +246,7 @@ pub fn error_suffix_on_exception_name(
class_def: &Stmt,
bases: &[Expr],
name: &str,
locator: &SourceCodeLocator,
) -> Option<Check> {
if !bases.iter().any(|base| {
if let ExprKind::Name { id, .. } = &base.node {
@ -262,6 +263,6 @@ pub fn error_suffix_on_exception_name(
}
Some(Check::new(
CheckKind::ErrorSuffixOnExceptionName(name.to_string()),
Range::from_located(class_def),
identifier_range(class_def, locator),
))
}

View file

@ -6,20 +6,20 @@ expression: checks
ErrorSuffixOnExceptionName: C
location:
row: 9
column: 0
column: 6
end_location:
row: 10
column: 8
row: 9
column: 7
fix: ~
parent: ~
- kind:
ErrorSuffixOnExceptionName: E
location:
row: 17
column: 0
column: 6
end_location:
row: 18
column: 8
row: 17
column: 7
fix: ~
parent: ~