mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-23 11:55:10 +00:00
[pylint
] Include builtin warnings in useless-exception-statement (PLW0133
) (#10394)
## Summary Closes https://github.com/astral-sh/ruff/issues/10392.
This commit is contained in:
parent
4db5c29f19
commit
324390607c
5 changed files with 140 additions and 76 deletions
|
@ -368,3 +368,79 @@ pub fn is_ipython_builtin(name: &str) -> bool {
|
|||
// Constructed by converting the `IPYTHON_BUILTINS` slice to a `match` expression.
|
||||
matches!(name, "__IPYTHON__" | "display" | "get_ipython")
|
||||
}
|
||||
|
||||
/// Returns `true` if the given name is that of a builtin exception.
|
||||
///
|
||||
/// See: <https://docs.python.org/3/library/exceptions.html#exception-hierarchy>
|
||||
pub fn is_exception(name: &str) -> bool {
|
||||
matches!(
|
||||
name,
|
||||
"BaseException"
|
||||
| "BaseExceptionGroup"
|
||||
| "GeneratorExit"
|
||||
| "KeyboardInterrupt"
|
||||
| "SystemExit"
|
||||
| "Exception"
|
||||
| "ArithmeticError"
|
||||
| "FloatingPointError"
|
||||
| "OverflowError"
|
||||
| "ZeroDivisionError"
|
||||
| "AssertionError"
|
||||
| "AttributeError"
|
||||
| "BufferError"
|
||||
| "EOFError"
|
||||
| "ExceptionGroup"
|
||||
| "ImportError"
|
||||
| "ModuleNotFoundError"
|
||||
| "LookupError"
|
||||
| "IndexError"
|
||||
| "KeyError"
|
||||
| "MemoryError"
|
||||
| "NameError"
|
||||
| "UnboundLocalError"
|
||||
| "OSError"
|
||||
| "BlockingIOError"
|
||||
| "ChildProcessError"
|
||||
| "ConnectionError"
|
||||
| "BrokenPipeError"
|
||||
| "ConnectionAbortedError"
|
||||
| "ConnectionRefusedError"
|
||||
| "ConnectionResetError"
|
||||
| "FileExistsError"
|
||||
| "FileNotFoundError"
|
||||
| "InterruptedError"
|
||||
| "IsADirectoryError"
|
||||
| "NotADirectoryError"
|
||||
| "PermissionError"
|
||||
| "ProcessLookupError"
|
||||
| "TimeoutError"
|
||||
| "ReferenceError"
|
||||
| "RuntimeError"
|
||||
| "NotImplementedError"
|
||||
| "RecursionError"
|
||||
| "StopAsyncIteration"
|
||||
| "StopIteration"
|
||||
| "SyntaxError"
|
||||
| "IndentationError"
|
||||
| "TabError"
|
||||
| "SystemError"
|
||||
| "TypeError"
|
||||
| "ValueError"
|
||||
| "UnicodeError"
|
||||
| "UnicodeDecodeError"
|
||||
| "UnicodeEncodeError"
|
||||
| "UnicodeTranslateError"
|
||||
| "Warning"
|
||||
| "BytesWarning"
|
||||
| "DeprecationWarning"
|
||||
| "EncodingWarning"
|
||||
| "FutureWarning"
|
||||
| "ImportWarning"
|
||||
| "PendingDeprecationWarning"
|
||||
| "ResourceWarning"
|
||||
| "RuntimeWarning"
|
||||
| "SyntaxWarning"
|
||||
| "UnicodeWarning"
|
||||
| "UserWarning"
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue