mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:48 +00:00
Fix N818 range (#1503)
This commit is contained in:
parent
14248cb8cb
commit
938ad9a39e
3 changed files with 14 additions and 10 deletions
|
@ -582,9 +582,12 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.settings.enabled.contains(&CheckCode::N818) {
|
if self.settings.enabled.contains(&CheckCode::N818) {
|
||||||
if let Some(check) =
|
if let Some(check) = pep8_naming::checks::error_suffix_on_exception_name(
|
||||||
pep8_naming::checks::error_suffix_on_exception_name(stmt, bases, name)
|
stmt,
|
||||||
{
|
bases,
|
||||||
|
name,
|
||||||
|
self.locator,
|
||||||
|
) {
|
||||||
self.add_check(check);
|
self.add_check(check);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,7 @@ pub fn error_suffix_on_exception_name(
|
||||||
class_def: &Stmt,
|
class_def: &Stmt,
|
||||||
bases: &[Expr],
|
bases: &[Expr],
|
||||||
name: &str,
|
name: &str,
|
||||||
|
locator: &SourceCodeLocator,
|
||||||
) -> Option<Check> {
|
) -> Option<Check> {
|
||||||
if !bases.iter().any(|base| {
|
if !bases.iter().any(|base| {
|
||||||
if let ExprKind::Name { id, .. } = &base.node {
|
if let ExprKind::Name { id, .. } = &base.node {
|
||||||
|
@ -262,6 +263,6 @@ pub fn error_suffix_on_exception_name(
|
||||||
}
|
}
|
||||||
Some(Check::new(
|
Some(Check::new(
|
||||||
CheckKind::ErrorSuffixOnExceptionName(name.to_string()),
|
CheckKind::ErrorSuffixOnExceptionName(name.to_string()),
|
||||||
Range::from_located(class_def),
|
identifier_range(class_def, locator),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,20 @@ expression: checks
|
||||||
ErrorSuffixOnExceptionName: C
|
ErrorSuffixOnExceptionName: C
|
||||||
location:
|
location:
|
||||||
row: 9
|
row: 9
|
||||||
column: 0
|
column: 6
|
||||||
end_location:
|
end_location:
|
||||||
row: 10
|
row: 9
|
||||||
column: 8
|
column: 7
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
ErrorSuffixOnExceptionName: E
|
ErrorSuffixOnExceptionName: E
|
||||||
location:
|
location:
|
||||||
row: 17
|
row: 17
|
||||||
column: 0
|
column: 6
|
||||||
end_location:
|
end_location:
|
||||||
row: 18
|
row: 17
|
||||||
column: 8
|
column: 7
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue