mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Allow ctypes.WinError()
in flake8-raise (#6731)
Closes https://github.com/astral-sh/ruff/issues/6730.
This commit is contained in:
parent
83f68891e0
commit
d5a51b4e45
2 changed files with 17 additions and 0 deletions
|
@ -52,3 +52,10 @@ class Class:
|
|||
|
||||
# OK
|
||||
raise Class.error()
|
||||
|
||||
|
||||
import ctypes
|
||||
|
||||
|
||||
# OK
|
||||
raise ctypes.WinError(1)
|
||||
|
|
|
@ -71,6 +71,16 @@ pub(crate) fn unnecessary_paren_on_raise_exception(checker: &mut Checker, expr:
|
|||
return;
|
||||
}
|
||||
|
||||
// `ctypes.WinError()` is a function, not a class. It's part of the standard library, so
|
||||
// we might as well get it right.
|
||||
if checker
|
||||
.semantic()
|
||||
.resolve_call_path(func)
|
||||
.is_some_and(|call_path| matches!(call_path.as_slice(), ["ctypes", "WinError"]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let range = match_parens(func.end(), checker.locator(), checker.source_type)
|
||||
.expect("Expected call to include parentheses");
|
||||
let mut diagnostic = Diagnostic::new(UnnecessaryParenOnRaiseException, range);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue