An exception class's name does not end in Error, Exception or Warning
What it finds
PEP 8 asks for the suffix Error on exception classes that are errors, and the standard library ends the others in Exception, Warning, Exit or Interrupt. Such a suffix tells readers of except InvalidInput: that a type of exception is meant. Checked are classes whose bases are Exception, BaseException or a name with one of these suffixes. Stubs are not checked, since their names are those of the code they describe.
From the rule's source, exception_name_suffix.rs.
class InvalidInput(Exception):tx0 reports: the exception class InvalidInput does not end in Error pass class Timeout(errors.NetworkError):tx0 reports: the exception class Timeout does not end pass class ParseError(ValueError): pass class DeprecatedWarning(UserWarning): pass class Handler(object): pass Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:exception-name-suffix" = "note"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:exception-name-suffix] reason="..."tx0 explain tx0/python:exception-name-suffix shows the same in the terminal. Found a false positive? Report it.