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 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -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: ~
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue