PEP 8 recommends naming conventions for classes, functions, constants, and more. The use of inconsistent naming styles between import and alias names may lead readers to expect an import to be of another type (e.g., confuse a Python class with a constant). Ruff takes this rule from pep8-naming and made it stable in v0.0.82.
- Code
N817- Message
CamelCase `{}` imported as acronym `{}`
The Error suffix is recommended by PEP 8: Ruff takes this rule from pep8-naming and made it stable in v0.0.89.
- Code
N818- Message
Exception name `{}` should be named with an Error suffix
PEP 8 recommends the use of the snake_case naming convention for module names: Ruff takes this rule from pep8-naming and made it stable in v0.0.248.
- Code
N999- Message
Invalid module name: '{}'
Mypy expects that all references to names have a corresponding definition in an active scope, such as an assignment, function definition or an import. This can catch missing definitions, missing imports, and typos. mypy enables this error code by default.
- Code
name-defined- Severity
- error
The definition of a named tuple or a TypedDict must be named consistently when using the call-based syntax. mypy enables this error code by default.
- Code
name-match- Severity
- error
742 requires that when TypeIs is used, the narrowed type must be a subtype of the original type. mypy enables this error code by default.
- Code
narrowed-type-not-subtype- Severity
- error
If you use --warn-return-any, mypy generates an error if you return a value with a plain Any type in a function that is annotated to return a non-Any value. You can use this to enforce better boundaries around unsafe/dynamic code. mypy does not enable this error code by default. Use --enable-error-code no-any-return to enable it.
- Code
no-any-return- Severity
- error
If you use --disallow-any-unimported, mypy generates an error if a component of a type becomes Any because mypy couldn't resolve an import. These "stealth" Any types can be surprising and accidentally cause imprecise type checking. mypy does not enable this error code by default. Use --enable-error-code no-any-unimported to enable it.
- Code
no-any-unimported- Severity
- error
Overloaded functions outside of stub files must be followed by a non overloaded implementation. mypy enables this error code by default.
- Code
no-overload-impl- Severity
- error
Mypy may generate an error if you have multiple definitions for a name in the same namespace. The reason is that this is often an error, as the second definition may overwrite the first one. mypy enables this error code by default.
- Code
no-redef- Severity
- error
If you use --disallow-untyped-calls, mypy generates an error when you call an unannotated function in an annotated function. mypy does not enable this error code by default. Use --enable-error-code no-untyped-call to enable it.
- Code
no-untyped-call- Severity
- error
If you use --disallow-untyped-defs, mypy requires that all functions have annotations (either a Python 3 annotation or a type comment). mypy does not enable this error code by default. Use --enable-error-code no-untyped-def to enable it.
- Code
no-untyped-def- Severity
- error
The preferred way to annotate the type of None is None. NoneType is equivalent, but mypy won't allow it by default. mypy enables this error code by default.
- Code
nonetype-type- Severity
- error
NumPy's np.int has long been an alias of the builtin int; the same is true of np.float and others. These aliases exist primarily for historic reasons, and have been a cause of frequent confusion for newcomers. Ruff takes this rule from NumPy-specific rules and made it stable in v0.0.247.
- Code
NPY001- Message
Type alias `np.{}` is deprecated, replace with builtin type
According to the NumPy documentation's Legacy Random Generation: Ruff takes this rule from NumPy-specific rules and made it stable in v0.0.248.
- Code
NPY002- Message
Replace legacy `np.random.{}` call with `np.random.Generator`
When NumPy functions are deprecated, they are usually replaced with newer, more efficient versions, or with functions that are more consistent with the rest of the NumPy API. Ruff takes this rule from NumPy-specific rules and made it stable in v0.0.276.
- Code
NPY003- Message
`np.{}` is deprecated; use `np.{}` instead
NumPy 2.0 includes an overhaul of NumPy's Python API, intended to remove redundant aliases and routines, and establish unambiguous mechanisms for accessing constants, dtypes, and functions. Ruff takes this rule from NumPy-specific rules and made it stable in v0.2.0.
- Code
NPY201- Message
`np.{}` will be removed in NumPy 2.0. {}- Message
`np.{}` will be removed without replacement in NumPy 2.0
Mypy checks that operands support a binary or unary operation, such as + or ~. Indexing operations are so common that they have their own error code index (see below). mypy enables this error code by default.
- Code
operator- Severity
- error
Warn if an @overload variant can never be matched, because an earlier overload has a wider signature. For example, this can happen if the two overloads accept the same parameters and each parameter on the first overload has the same type or a wider type than the corresponding parameter on the second overload. mypy enables this error code by default.
- Code
overload-cannot-match- Severity
- error
Warn if multiple @overload variants overlap in potentially unsafe ways. This guards against the following situation. mypy enables this error code by default.
- Code
overload-overlap- Severity
- error
Mypy checks that an overridden method or attribute is compatible with the base class. A method in a subclass must accept all arguments that the base class method accepts, and the return type must conform to the return type in the base class (Liskov substitution principle). mypy enables this error code by default.
- Code
override- Severity
- error
Using inplace=True encourages mutation rather than immutable data, which is harder to reason about and may cause bugs. It also removes the ability to use the method chaining style for pandas operations. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD002- Message
`inplace=True` should be avoided; it has inconsistent behavior
In the Pandas API, .isna and .isnull are equivalent. For consistency, prefer .isna over .isnull. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD003- Message
`.isna` is preferred to `.isnull`; functionality is equivalent
In the Pandas API, .notna and .notnull are equivalent. For consistency, prefer .notna over .notnull. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD004- Message
`.notna` is preferred to `.notnull`; functionality is equivalent
The .ix method is deprecated as its behavior is ambiguous. Specifically, it's often unclear whether .ix is indexing by label or by ordinal position. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD007- Message
`.ix` is deprecated; use more explicit `.loc` or `.iloc`
The .at method selects a single value from a DataFrame or Series based on a label index, and is slightly faster than using .loc. However, .loc is more idiomatic and versatile, as it can be used to select multiple values at once. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD008- Message
Use `.loc` instead of `.at`. If speed is important, use NumPy.
The .iat method selects a single value from a DataFrame or Series based on an ordinal index, and is slightly faster than using .iloc. However, .iloc is more idiomatic and versatile, as it can be used to select multiple values at once. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD009- Message
Use `.iloc` instead of `.iat`. If speed is important, use NumPy.
Prefer .pivot_table to .pivot or .unstack. .pivot_table is more general and can be used to implement the same behavior as .pivot and .unstack. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD010- Message
`.pivot_table` is preferred to `.pivot` or `.unstack`; provides same functionality
The .values attribute is ambiguous as its return type is unclear. As such, it is no longer recommended by the Pandas documentation. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD011- Message
Use `.to_numpy()` or `.array` instead of `.values`
In the Pandas API, pd.read_csv and pd.read_table are equivalent apart from their default separator: pd.read_csv defaults to a comma (,), while pd.read_table defaults to a tab (\t) as the default separator. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD012- Message
Use `.read_csv` instead of `.read_table` to read CSV files
Prefer .melt to .stack, which has the same functionality but with support for direct column renaming and no dependence on MultiIndex. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD013- Message
`.melt` is preferred to `.stack`; provides same functionality
In Pandas, the .merge method (exposed on, e.g., DataFrame objects) and the pd.merge function (exposed on the Pandas module) are equivalent. Ruff takes this rule from pandas-vet and made it stable in v0.0.188.
- Code
PD015- Message
Use `.merge` method instead of `pd.merge` function. They have equivalent functionality.
.nunique() is computationally inefficient for checking if a Series is constant. Ruff takes this rule from pandas-vet and made it stable in v0.0.279.
- Code
PD101- Message
Using `series.nunique()` for checking that a series is constant is inefficient
Although df is a common variable name for a Pandas DataFrame, it's not a great variable name for production code, as it's non-descriptive and prone to name conflicts. Ruff takes this rule from pandas-vet, and removed it.
- Code
PD901- Message
Avoid using the generic variable name `df` for DataFrames
Using a list() call to eagerly iterate over an already-iterable type (like a tuple, list, or set) is inefficient, as it forces Python to create a new list unnecessarily. Ruff takes this rule from Perflint and made it stable in v0.0.276.
- Code
PERF101- Message
Do not cast an iterable to `list` before iterating over it
If you only need the keys or values of a dictionary, you should use dict.keys() or dict.values() respectively, instead of dict.items(). These specialized methods are more efficient than dict.items(), as they avoid allocating tuples for every item in the dictionary. They also communicate the intent of the code more clearly. Ruff takes this rule from Perflint and made it stable in v0.0.273.
- Code
PERF102- Message
When using only the {} of a dict use the `{}()` method
Exception handling via try-except blocks incurs some performance overhead, regardless of whether an exception is raised. Ruff takes this rule from Perflint and made it stable in v0.0.276.
- Code
PERF203- Message
`try`-`except` within a loop incurs performance overhead
When creating a transformed list from an existing list using a for-loop, prefer a list comprehension. List comprehensions are more readable and more performant. Ruff takes this rule from Perflint and made it stable in v0.0.276.
- Code
PERF401- Message
Use {} to create a transformed list
When populating a list from an iterable with a for loop, prefer list instead. The list call is more readable and more performant. For an existing list, you can also use list.copy instead of list. Ruff takes this rule from Perflint and made it stable in v0.0.276.
- Code
PERF402- Message
Use `list` or `list.copy` to create a copy of a list
When creating or extending a dictionary in a for-loop, prefer a dictionary comprehension. Comprehensions are more readable and more performant. Ruff takes this rule from Perflint and made it stable in 0.5.0.
- Code
PERF403- Message
Use a dictionary comprehension instead of {} for-loop- Message
Use `dict.update` instead of {} for-loop
Mypy reports this error when it limits or skip checks to avoid excessive type checking time. As a result, some errors may go undetected. mypy enables this error code by default.
- Code
performance-limit- Severity
- error
The eval() function is insecure as it enables arbitrary code execution. Ruff takes this rule from pygrep-hooks, and removed it.
- Code
PGH001- Message
No builtin `eval()` allowed
The warn method is deprecated. Use warning instead. Ruff takes this rule from pygrep-hooks, and removed it.
- Code
PGH002- Message
`warn` is deprecated in favor of `warning`
Suppressing all warnings can hide issues in the code. Ruff takes this rule from pygrep-hooks and made it stable in v0.0.187.
- Code
PGH003- Message
Use specific rule codes when ignoring type issues
Suppressing all diagnostics can hide issues in the code. Ruff takes this rule from pygrep-hooks and made it stable in v0.0.200.
- Code
PGH004- Message
Use specific rule codes when using `noqa`- Message
Use specific rule codes when using `ruff: noqa`- Message
Use a colon when specifying `noqa` rule codes
The mock module exposes an assertion API that can be used to verify that mock objects undergo expected interactions. This rule checks for common mistakes when using this API. Ruff takes this rule from pygrep-hooks and made it stable in v0.0.266.
- Code
PGH005- Message
Mock method should be called: `{}`- Message
Non-existent mock method: `{}`
In Python, the pass statement and ellipsis (...) literal serve as placeholders, allowing for syntactically correct empty code blocks. The primary purpose of these nodes is to avoid syntax errors in situations where a statement or expression is syntactically required, but no code needs to be executed. Ruff takes this rule from flake8-pie and made it stable in v0.0.208.
- Code
PIE790- Message
Unnecessary `pass` statement- Message
Unnecessary `...` literal
Defining a field multiple times in a class body is redundant and likely a mistake. Ruff takes this rule from flake8-pie and made it stable in v0.0.208.
- Code
PIE794- Message
Class field `{}` is defined multiple times
Enum values should be unique. Non-unique values are redundant and likely a mistake. Ruff takes this rule from flake8-pie and made it stable in v0.0.224.
- Code
PIE796- Message
Enum contains duplicate value: `{}`
Unpacking a dictionary into another dictionary is redundant. The unpacking operator can be removed, making the code more readable. Ruff takes this rule from flake8-pie and made it stable in v0.0.231.
- Code
PIE800- Message
Unnecessary spread `**`
If the dict keys are valid identifiers, they can be passed as keyword arguments directly, without constructing unnecessary dictionary. This also makes code more type-safe as type checkers often cannot precisely verify dynamic keyword arguments. Ruff takes this rule from flake8-pie and made it stable in v0.0.231.
- Code
PIE804- Message
Unnecessary `dict` kwargs
Using container builtins are more succinct and idiomatic than wrapping the literal in a lambda. Ruff takes this rule from flake8-pie and made it stable in v0.0.208.
- Code
PIE807- Message
Prefer `{}` over useless lambda
range(0, x) is equivalent to range(x), as 0 is the default value for the start argument. Omitting the start argument makes the code more concise and idiomatic. Ruff takes this rule from flake8-pie and made it stable in v0.0.286.
- Code
PIE808- Message
Unnecessary `start` argument in `range`
The startswith and endswith methods accept tuples of prefixes or suffixes respectively. Passing a tuple of prefixes or suffixes is more efficient and readable than calling the method multiple times. Ruff takes this rule from flake8-pie and made it stable in v0.0.243.
- Code
PIE810- Message
Call `{}` once with a `tuple`
PEP 484 recommends the use of the _co and _contra suffixes for covariant and contravariant type parameters, respectively (while invariant type parameters should not have any such suffix). Ruff takes this rule from Pylint and made it stable in v0.0.278.
- Code
PLC0105- Message
`{}` name "{}" does not reflect its {}; consider renaming it to "{}"
By default, Python's generic types are invariant, but can be marked as either covariant or contravariant via the covariant and contravariant keyword arguments. While the API does allow you to mark a type as both covariant and contravariant, this is not supported by the type system, and should be avoided. Ruff takes this rule from Pylint and made it stable in v0.0.278.
- Code
PLC0131- Message
`{}` cannot be both covariant and contravariant- Message
`{}` "{}" cannot be both covariant and contravariant
When defining a TypeVar or a related type parameter, Python allows you to provide a name for the type parameter. According to PEP 484, the name provided to the TypeVar constructor must be equal to the name of the variable to which it is assigned. Ruff takes this rule from Pylint and made it stable in v0.0.277.
- Code
PLC0132- Message
`{}` name `{}` does not match assigned variable name `{}`
In Python, the __slots__ attribute allows you to explicitly define the attributes (instance variables) that a class can have. By default, Python uses a dictionary to store an object's attributes, which incurs some memory overhead. However, when __slots__ is defined, Python uses a more compact internal structure to store the object's attributes, resulting in memory savings. Ruff takes this rule from Pylint and made it stable in v0.0.276.
- Code
PLC0205- Message
Class `__slots__` should be a non-string iterable
Iterating over a dictionary with .items() is semantically clearer and more efficient than extracting the value with the key. Ruff takes this rule from Pylint and made it stable in 0.8.0.
- Code
PLC0206- Message
Extracting value from dictionary without calling `.items()`
Calling str.split() or str.rsplit() without passing maxsplit=1 splits on every delimiter in the string. When accessing only the first or last element of the result, it would be more efficient to split only once. Ruff takes this rule from Pylint and made it stable in 0.15.0.
- Code
PLC0207- Message
String is split more times than necessary
Iterating over a set is less efficient than iterating over a sequence type, such as list or tuple. Ruff takes this rule from Pylint and made it stable in v0.0.271.
- Code
PLC0208- Message
Use a sequence type instead of a `set` when iterating over values
This rule does not apply in __init__.py files. The import alias is redundant and should be removed to avoid confusion. Ruff takes this rule from Pylint and made it stable in v0.0.156.
- Code
PLC0414- Message
Import alias does not rename original package- Message
Required import does not rename original package.
PEP 8 recommends placing imports not only at the top-level of a module, but at the very top of the file, "just after any module comments and docstrings, and before module globals and constants." Ruff takes this rule from Pylint and made it stable in 0.12.0.
- Code
PLC0415- Message
`import` should be at the top-level of a file
Empty sequences are considered false in a boolean context. You can either remove the call to len or compare the length against a scalar. Ruff takes this rule from Pylint and made it stable in 0.10.0.
- Code
PLC1802- Message
`len({})` used as condition without comparison- Message
`len(SEQUENCE)` used as condition without comparison
An empty string is falsy, so it is unnecessary to compare it to "". If the value can be something else Python considers falsy, such as None, 0, or another empty container, then the code is not equivalent. Ruff takes this rule from Pylint. It is in preview.
- Code
PLC1901- Message
`{}` can be simplified to `{}` as an empty string is falsey
The use of non-ASCII characters in variable names can cause confusion and compatibility issues (see: PEP 672). Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLC2401- Message
{} name `{}` contains a non-ASCII character
The use of non-ASCII characters in import statements can cause confusion and compatibility issues (see: PEP 672). Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLC2403- Message
Module alias `{}` contains a non-ASCII character- Message
Module name `{}` contains a non-ASCII character
PEP 8 states that names starting with an underscore are private. Thus, they are not intended to be used outside of the module in which they are defined. Ruff takes this rule from Pylint. It is in preview.
- Code
PLC2701- Message
Private name import `{}` from external module `{}`- Message
Private name import `{}`
Dunder names are not meant to be called explicitly and, in most cases, can be replaced with builtins or operators. Ruff takes this rule from Pylint. It is in preview.
- Code
PLC2801- Message
Unnecessary dunder call to `{}`. {}.- Message
Unnecessary dunder call to `{}`
Calling a lambda expression directly is unnecessary. The expression can be executed inline instead to improve readability. Ruff takes this rule from Pylint and made it stable in v0.0.153.
- Code
PLC3002- Message
Lambda expression called directly. Execute the expression inline instead.
The __init__ method is the constructor for a given Python class, responsible for initializing, rather than creating, new objects. Ruff takes this rule from Pylint and made it stable in v0.0.245.
- Code
PLE0100- Message
`__init__` method is a generator
The __init__ method is the constructor for a given Python class, responsible for initializing, rather than creating, new objects. Ruff takes this rule from Pylint and made it stable in v0.0.248.
- Code
PLE0101- Message
Explicit return in `__init__`
A nonlocal variable is a variable that is defined in the nearest enclosing scope, but not in the global scope, while a global variable is a variable that is defined in the global scope. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLE0115- Message
Name `{}` is both `nonlocal` and `global`
continue statements were not allowed within finally clauses prior to Python 3.8. Using a continue statement within a finally clause can cause a SyntaxError. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLE0116- Message
`continue` not supported inside `finally` clause
nonlocal names must be bound to a name in an outer scope. Violating this rule leads to a SyntaxError at runtime. Ruff takes this rule from Pylint and made it stable in v0.0.174.
- Code
PLE0117- Message
Nonlocal name `{}` found without binding
The global declaration applies to the entire scope. Using a name that's declared as global in a given scope prior to the relevant global declaration is a SyntaxError. Ruff takes this rule from Pylint and made it stable in v0.0.174.
- Code
PLE0118- Message
Name `{}` is used prior to global declaration on {}
When using __slots__, only the specified attributes are allowed. Attempting to assign to an attribute that is not defined in __slots__ will result in an AttributeError at runtime. Ruff takes this rule from Pylint and made it stable in v0.1.15.
- Code
PLE0237- Message
Attribute `{}` is not defined in class's `__slots__`
Including duplicate base classes will raise a TypeError at runtime. Ruff takes this rule from Pylint and made it stable in v0.0.269.
- Code
PLE0241- Message
Duplicate base `{}` for class `{}`
"Special" methods, like __len__, are expected to adhere to a specific, standard function signature. Implementing a "special" method using a non-standard function signature can lead to unexpected and surprising behavior for users of a given class. Ruff takes this rule from Pylint and made it stable in v0.0.263.
- Code
PLE0302- Message
The special method `{}` expects {}, {} {} given
The __len__ method should return a non-negative integer. Returning a different value may cause unexpected behavior. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLE0303- Message
`__len__` does not return a non-negative integer
The __bool__ method should return a bool object. Returning a different type may cause unexpected behavior. Ruff takes this rule from Pylint and made it stable in 0.16.0.
- Code
PLE0304- Message
`__bool__` does not return `bool`
The __index__ method should return an integer. Returning a different type may cause unexpected behavior. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLE0305- Message
`__index__` does not return an integer
The __str__ method should return a str object. Returning a different type may cause unexpected behavior. Ruff takes this rule from Pylint and made it stable in v0.0.271.
- Code
PLE0307- Message
`__str__` does not return `str`
The __bytes__ method should return a bytes object. Returning a different type may cause unexpected behavior. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLE0308- Message
`__bytes__` does not return `bytes`
The __hash__ method should return an integer. Returning a different type may cause unexpected behavior. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLE0309- Message
`__hash__` does not return an integer
In Python, __all__ should contain a sequence of strings that represent the names of all "public" symbols exported by a module. Ruff takes this rule from Pylint and made it stable in v0.0.237.
- Code
PLE0604- Message
Invalid object in `__all__`, must contain only strings
In Python, __all__ should contain a sequence of strings that represent the names of all "public" symbols exported by a module. Ruff takes this rule from Pylint and made it stable in v0.0.237.
- Code
PLE0605- Message
Invalid format for `__all__`, must be `tuple` or `list`
Attempting to access a sequence with an out-of-bounds index will cause an IndexError to be raised at runtime. When the sequence and index are defined statically (e.g., subscripts on list and tuple literals, with integer indexes), such errors can be detected ahead of time. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLE0643- Message
Expression is likely to raise `IndexError`
A bare raise statement without an exception object will re-raise the last exception that was active in the current scope, and is typically used within an exception handler to re-raise the caught exception. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLE0704- Message
Bare `raise` statement is not inside an exception handler
Python does not allow repeated keyword arguments in function calls. If a function is called with the same keyword argument multiple times, the interpreter will raise an exception. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLE1132- Message
Repeated keyword argument: `{}`
When iterating over a dictionary in a for loop, if a dictionary is unpacked without calling .items(), it could lead to a runtime error if the keys are not a tuple of two elements. Ruff takes this rule from Pylint. It is in preview.
- Code
PLE1141- Message
Unpacking a dictionary in iteration without calling `.items()`
Using await outside an async function is a syntax error. Ruff takes this rule from Pylint and made it stable in v0.0.150.
- Code
PLE1142- Message
`await` should be used within an async function
A TypeError will be raised if the statement is run. Ruff takes this rule from Pylint and made it stable in v0.0.252.
- Code
PLE1205- Message
Too many arguments for `logging` format string
A TypeError will be raised if the statement is run. Ruff takes this rule from Pylint and made it stable in v0.0.252.
- Code
PLE1206- Message
Not enough arguments for `logging` format string
An invalid format string character will result in an error at runtime. Ruff takes this rule from Pylint and made it stable in v0.0.283.
- Code
PLE1300- Message
Unsupported format character '{}'
The format string is not checked at compile time, so it is easy to introduce bugs by mistyping the format string. Ruff takes this rule from Pylint and made it stable in v0.0.245.
- Code
PLE1307- Message
Format type does not match argument type
All characters in str.strip calls are removed from both the leading and trailing ends of the string. Including duplicate characters in the call is redundant and often indicative of a mistake. Ruff takes this rule from Pylint and made it stable in v0.0.242.
- Code
PLE1310- Message
String `{}` call contains duplicate characters (did you mean `{}`?)- Message
String `{}` call contains duplicate characters
os.getenv only supports strings as the first argument (key). Ruff takes this rule from Pylint and made it stable in v0.0.255.
- Code
PLE1507- Message
Invalid type for initial `os.getenv` argument; expected `str`
The @singledispatch decorator is intended for use with functions, not methods. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLE1519- Message
`@singledispatch` decorator should not be used on methods
The @singledispatchmethod decorator is intended for use with methods, not functions. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLE1520- Message
`@singledispatchmethod` decorator should not be used on non-method functions
Python doesn't support the use of yield from in async functions, and will raise a SyntaxError in such cases. Ruff takes this rule from Pylint and made it stable in v0.0.271.
- Code
PLE1700- Message
`yield from` statement in async function; use `async for` instead
The interaction between bidirectional formatting characters and the surrounding code can be surprising to those that are unfamiliar with right-to-left writing systems. Ruff takes this rule from Pylint and made it stable in v0.0.244.
- Code
PLE2502- Message
Contains control characters that can permit obfuscated code
Control characters are displayed differently by different text editors and terminals. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLE2510- Message
Invalid unescaped character backspace, use "\b" instead
Control characters are displayed differently by different text editors and terminals. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLE2512- Message
Invalid unescaped character SUB, use "\x1a" instead
Control characters are displayed differently by different text editors and terminals. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLE2513- Message
Invalid unescaped character ESC, use "\x1b" instead
Control characters are displayed differently by different text editors and terminals. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLE2514- Message
Invalid unescaped character NUL, use "\0" instead
This character is rendered invisibly in some text editors and terminals. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLE2515- Message
Invalid unescaped character zero-width-space, use "\u200B" instead
If a set is modified during iteration, it will cause a RuntimeError. Ruff takes this rule from Pylint. It is in preview.
- Code
PLE4703- Message
Iterated set `{}` is modified within the `for` loop
Comparing a name to itself typically results in a truthy value, and is likely a mistake. Ruff takes this rule from Pylint and made it stable in v0.0.273.
- Code
PLR0124- Message
Name compared with itself, consider replacing `{}`- Message
Name compared with itself
Comparing two constants will always resolve to the same value, so the comparison is redundant. Instead, the expression should be replaced with the result of the comparison. Ruff takes this rule from Pylint and made it stable in v0.0.221.
- Code
PLR0133- Message
Two constants compared in a comparison, consider replacing `{} {} {}`
When it comes to consistency and readability, it's preferred to use the decorator. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR0202- Message
Class method defined without decorator
When it comes to consistency and readability, it's preferred to use the decorator. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR0203- Message
Static method defined without decorator
Properties cannot be called with parameters. Ruff takes this rule from Pylint and made it stable in v0.0.153.
- Code
PLR0206- Message
Cannot have defined parameters for properties
Using the from keyword to import the submodule is more concise and readable. Ruff takes this rule from Pylint and made it stable in v0.0.155.
- Code
PLR0402- Message
Use `from {} import {}` in lieu of alias
Classes with many public methods are harder to understand and maintain. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR0904- Message
Too many public methods ({} > {})
Functions or methods with many return statements are harder to understand and maintain, and often indicative of complex logic. Ruff takes this rule from Pylint and made it stable in v0.0.242.
- Code
PLR0911- Message
Too many return statements ({} > {})
Functions or methods with many branches are harder to understand and maintain than functions or methods with fewer branches. Ruff takes this rule from Pylint and made it stable in v0.0.242.
- Code
PLR0912- Message
Too many branches ({} > {})
Functions with many arguments are harder to understand, maintain, and call. Consider refactoring functions with many arguments into smaller functions with fewer arguments, or using objects to group related arguments. Ruff takes this rule from Pylint and made it stable in v0.0.238.
- Code
PLR0913- Message
Too many arguments in function definition ({} > {})
Functions with many local variables are harder to understand and maintain. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR0914- Message
Too many local variables ({} > {})
Functions or methods with many statements are harder to understand and maintain. Ruff takes this rule from Pylint and made it stable in v0.0.240.
- Code
PLR0915- Message
Too many statements ({} > {})
if statements with many Boolean expressions are harder to understand and maintain. Consider assigning the result of the Boolean expression, or any of its sub-expressions, to a variable. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR0916- Message
Too many Boolean expressions ({} > {})
Functions with many arguments are harder to understand, maintain, and call. This is especially true for functions with many positional arguments, as providing arguments positionally is more error-prone and less clear to readers than providing arguments by name. Ruff takes this rule from Pylint and made it stable in 0.16.0.
- Code
PLR0917- Message
Too many positional arguments ({} > {})
Repeated isinstance calls on the same object can be merged into a single call. Ruff takes this rule from Pylint, and removed it.
- Code
PLR1701- Message
Merge `isinstance` calls: `{}`- Message
Merge `isinstance` calls
Functions or methods with too many nested blocks are harder to understand and maintain. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR1702- Message
Too many nested blocks ({} > {})
Redefined variables can cause unexpected behavior because of overridden function parameters. If nested functions are declared, an inner function's body can override an outer function's parameters. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLR1704- Message
Redefining argument with the local name `{}`
Prior to the introduction of the if-expression (ternary) operator in Python 2.5, the only way to express a conditional expression was to use the and and or operators. Ruff takes this rule from Pylint, and removed it.
- Code
PLR1706- Message
Consider using if-else expression
Raising StopIteration in a generator function causes a RuntimeError when the generator is iterated over. Ruff takes this rule from Pylint and made it stable in 0.16.0.
- Code
PLR1708- Message
Explicit `raise StopIteration` in generator
Python implicitly assumes a None return at the end of a function, making it unnecessary to explicitly write return None. Ruff takes this rule from Pylint and made it stable in v0.0.257.
- Code
PLR1711- Message
Useless `return` statement at end of function
Variables can be swapped by using tuple unpacking instead of using a temporary variable. That also makes the intention of the swapping logic more clear. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR1712- Message
Unnecessary temporary variable
To check if a variable is equal to one of many values, it is common to write a series of equality comparisons (e.g., foo == "bar" or foo == "baz"). Ruff takes this rule from Pylint and made it stable in v0.0.279.
- Code
PLR1714- Message
Consider merging multiple comparisons: `{}`. Use a `set` if the elements are hashable.- Message
Consider merging multiple comparisons: `{}`.- Message
Consider merging multiple comparisons. Use a `set` if the elements are hashable.- Message
Consider merging multiple comparisons.
Refactoring the code will improve readability for these cases. Ruff takes this rule from Pylint and made it stable in 0.9.0.
- Code
PLR1716- Message
Contains chained boolean comparison that can be simplified
exit and quit come from the site module, which is typically imported automatically during startup. However, it is not _guaranteed_ to be imported, and so using these functions may result in a NameError at runtime. Generally, these constants are intended to be used in an interactive interpreter, and not in programs. Ruff takes this rule from Pylint and made it stable in v0.0.156.
- Code
PLR1722- Message
Use `sys.exit()` instead of `{}`
An if statement that selects the lesser or greater of two sub-expressions can be replaced with a min() or max() call respectively. Where possible, prefer min() and max(), as they're more concise and readable than the equivalent if statements. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLR1730- Message
Replace `if` statement with `{}`- Message
Replace `if` statement with `{}` call
When iterating over a dict via .items(), the current value is already available alongside its key. Using the key to look up the value is unnecessary. Ruff takes this rule from Pylint and made it stable in 0.12.0.
- Code
PLR1733- Message
Unnecessary lookup of dictionary value by key
When iterating over a list with enumerate, the current item is already available alongside its index. Using the index to look up the item is unnecessary. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLR1736- Message
List index lookup in `enumerate()` loop
The use of "magic" values can make code harder to read and maintain, as readers will have to infer the meaning of the value from the context. Such values are discouraged by PEP 8. Ruff takes this rule from Pylint and made it stable in v0.0.221.
- Code
PLR2004- Message
Magic value used in comparison, consider replacing `{}` with a constant variable
Empty comments don't provide any clarity to the code, and just add clutter. Either add a comment or delete the empty comment. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLR2044- Message
Line with empty comment
If an else block contains a single if statement, it can be collapsed into an elif, thus reducing the indentation level. Ruff takes this rule from Pylint and made it stable in v0.0.253.
- Code
PLR5501- Message
Use `elif` instead of `else` then `if`, to reduce indentation
If the right-hand side of an assignment statement consists of a binary operation in which one operand is the same as the assignment target, it can be rewritten as an augmented assignment. For example, x = x + 1 can be rewritten as x += 1. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR6104- Message
Use `{}` to perform an augmented assignment directly
When testing for membership in a static sequence, prefer a set literal over a list or tuple, as Python optimizes set membership tests. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR6201- Message
Use a set literal when testing for membership
Unused self parameters are usually a sign of a method that could be replaced by a function, class method, or static method. Ruff takes this rule from Pylint. It is in preview.
- Code
PLR6301- Message
Method `{}` could be a function, class method, or static method
When a lambda is used to wrap a function call, and merely propagates the lambda arguments to that function, it can typically be replaced with the function itself, removing a level of indirection. Ruff takes this rule from Pylint and made it stable in 0.15.0.
- Code
PLW0108- Message
Lambda may be unnecessary; consider inlining inner function
When a loop includes an else statement, the code inside the else clause will be executed if the loop terminates "normally" (i.e., without a break). Ruff takes this rule from Pylint and made it stable in v0.0.156.
- Code
PLW0120- Message
`else` clause on loop without a `break` statement; remove the `else` and dedent its contents
Self-assignment of variables is redundant and likely a mistake. Ruff takes this rule from Pylint and made it stable in v0.0.281.
- Code
PLW0127- Message
Self-assignment of variable `{}`
Assigning a variable multiple times in the same assignment is redundant, as the final assignment to the variable is what the value will be. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLW0128- Message
Redeclared variable `{}` in assignment
An assert on a non-empty string literal will always pass, while an assert on an empty string literal will always fail. Ruff takes this rule from Pylint and made it stable in v0.0.258.
- Code
PLW0129- Message
Asserting on an empty string literal will never pass- Message
Asserting on a non-empty string literal will always pass- Message
Asserting on a string literal may have unintended results
While a top-level named expression is syntactically and semantically valid, it's less clear than a regular assignment statement. Named expressions are intended to be used in comprehensions and generator expressions, where assignment statements are not allowed. Ruff takes this rule from Pylint and made it stable in v0.0.270.
- Code
PLW0131- Message
Named expression used without context
It's unnecessary to create an exception without raising it. For example, ValueError("...") on its own will have no effect (unlike raise ValueError("...")) and is likely a mistake. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLW0133- Message
Missing `raise` statement on exception
Comparing against a NaN value can lead to unexpected results. For example, float("NaN") == float("NaN") will return False and, in general, x == float("NaN") will always return False, even if x is NaN. Ruff takes this rule from Pylint and made it stable in 0.12.0.
- Code
PLW0177- Message
Comparing against a NaN value; use `math.isnan` instead- Message
Comparing against a NaN value; use `np.isnan` instead
This rule also applies to __new__ methods, which are implicitly static. PEP 8 recommends the use of self and cls as the first arguments for instance methods and class methods, respectively. Naming the first argument of a static method as self or cls can be misleading, as static methods do not receive an instance or class reference as their first argument. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLW0211- Message
First argument of a static method should not be named `{}`
If a class defines a slot also defined in a base class, the instance variable defined by the base class slot is inaccessible (except by retrieving its descriptor directly from the base class). Ruff takes this rule from Pylint. It is in preview.
- Code
PLW0244- Message
Slot `{}` redefined from base class `{}`
The super() callable can be used inside method definitions to create a proxy object that delegates attribute access to a superclass of the current class. Attempting to access attributes on super itself, however, instead of the object returned by a call to super(), will raise AttributeError. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLW0245- Message
`super` call is missing parentheses
Importing a module from itself is a circular dependency and results in an ImportError exception. Ruff takes this rule from Pylint and made it stable in v0.0.265.
- Code
PLW0406- Message
Module `{}` imports itself
The global keyword allows an inner scope to modify a variable declared in the outer scope. If the variable is not modified within the inner scope, there is no need to use global. Ruff takes this rule from Pylint and made it stable in v0.0.174.
- Code
PLW0602- Message
Using global for `{}` but no assignment is done
Pylint discourages the use of global variables as global mutable state is a common source of bugs and confusing behavior. Ruff takes this rule from Pylint and made it stable in v0.0.253.
- Code
PLW0603- Message
Using the global statement to update `{}` is discouraged
The global keyword is used within functions to indicate that a name refers to a global variable, rather than a local variable. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLW0604- Message
`global` at module level is redundant
The identifiers self and cls are conventional in Python for the first parameter of instance methods and class methods, respectively. Assigning new values to these variables can be confusing for others reading your code; using a different variable name can lead to clearer code. Ruff takes this rule from Pylint and made it stable in 0.6.0.
- Code
PLW0642- Message
Reassigned `{}` variable in {} method
A binary operation will not catch multiple exceptions. Instead, the binary operation will be evaluated first, and the result of _that_ operation will be caught (for an or operation, this is typically the first exception in the list). This is almost never the desired behavior. Ruff takes this rule from Pylint and made it stable in v0.0.258.
- Code
PLW0711- Message
Exception to catch is the result of a binary `and` operation- Message
Exception to catch is the result of a binary `or` operation
Try clauses with many statements make unexpected exceptions harder to detect and debug. Ruff takes this rule from Pylint. It is in preview.
- Code
PLW0717- Message
Try clause contains too many statements ({} > {})
The open function accepts a mode argument that specifies how the file should be opened (e.g., read-only, write-only, append-only, etc.). Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLW1501- Message
`{}` is not a valid mode for `open`
os.environ is not a dict object, but rather, a proxy object. As such, mutating a shallow copy of os.environ will also mutate the original object. Ruff takes this rule from Pylint and made it stable in 0.10.0.
- Code
PLW1507- Message
Shallow copy of `os.environ` via `copy.copy(os.environ)`
If an environment variable is set, os.getenv will return its value as a string. If the environment variable is _not_ set, os.getenv will return None, or the default value if one is provided. Ruff takes this rule from Pylint and made it stable in v0.0.255.
- Code
PLW1508- Message
Invalid type for environment variable default; expected `str` or `None`
The preexec_fn argument is unsafe within threads as it can lead to deadlocks. Furthermore, preexec_fn is targeted for deprecation. Ruff takes this rule from Pylint and made it stable in v0.0.281.
- Code
PLW1509- Message
`preexec_fn` argument is unsafe when using threads
By default, subprocess.run does not check the return code of the process it runs. This can lead to silent failures. Ruff takes this rule from Pylint and made it stable in v0.0.285.
- Code
PLW1510- Message
`subprocess.run` without explicit `check` argument
Using open in text mode without an explicit encoding can lead to non-portable code, with differing behavior across platforms. While readers may assume that UTF-8 is the default encoding, in reality, the default is locale-specific. Ruff takes this rule from Pylint. It is in preview.
- Code
PLW1514- Message
`{}` in text mode without explicit `encoding` argument- Message
`{}` without explicit `encoding` argument
A class that implements __eq__ but not __hash__ will have its hash method implicitly set to None, regardless of if a superclass defines __hash__. This will cause the class to be unhashable, which will in turn cause issues when using instances of the class as keys in a dictionary or members of a set. Ruff takes this rule from Pylint and made it stable in 0.12.0.
- Code
PLW1641- Message
Object does not implement `__hash__` method
Creating a lock (via threading.Lock or similar) in a with statement has no effect, as locks are only relevant when shared between threads. Ruff takes this rule from Pylint and made it stable in 0.5.0.
- Code
PLW2101- Message
Threading lock directly created in `with` statement has no effect
Redefinition of a loop variable inside the loop's body causes its value to differ from the original loop iteration for the remainder of the block, in a way that will likely cause bugs. Ruff takes this rule from Pylint and made it stable in v0.0.252.
- Code
PLW2901- Message
Outer {} variable `{}` overwritten by inner {} target- Message
{} variable `{}` overwritten by {} target
Misspelled or no longer supported dunder name methods may cause your code to not function as expected. Ruff takes this rule from Pylint. It is in preview.
- Code
PLW3201- Message
Dunder method `{}` has no special meaning in Python 3
Nested min and max calls can be flattened into a single call to improve readability. Ruff takes this rule from Pylint and made it stable in v0.0.266.
- Code
PLW3301- Message
Nested `{}` calls can be flattened
If you use --enable-error-code possibly-undefined, mypy generates an error if it cannot verify that a variable will be defined in all execution paths. This includes situations when a variable definition appears in a loop, in a conditional branch, in an except handler, etc. mypy does not enable this error code by default. Use --enable-error-code possibly-undefined to enable it.
- Code
possibly-undefined- Severity
- error
Mypy does not yet support analysis of decorators that precede the property decorator. If the decorator does not preserve the declared type of the property, mypy will not infer the correct type for the declaration. mypy enables this error code by default.
- Code
prop-decorator- Severity
- error
If a @pytest.fixture() doesn't take any arguments, the parentheses are optional. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT001- Message
Use `@pytest.fixture{}` over `@pytest.fixture{}`
For clarity and consistency, prefer using keyword arguments to specify fixture configuration. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT002- Message
Configuration for fixture `{}` specified via positional args, use kwargs
scope="function" can be omitted, as it is the default. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT003- Message
`scope='function'` is implied in `@pytest.fixture()`
By convention, fixtures that don't return a value should be named with a leading underscore, while fixtures that do return a value should not. Ruff takes this rule from flake8-pytest-style, and removed it.
- Code
PT004- Message
Fixture `{}` does not return anything, add leading underscore
By convention, fixtures that don't return a value should be named with a leading underscore, while fixtures that do return a value should not. Ruff takes this rule from flake8-pytest-style, and removed it.
- Code
PT005- Message
Fixture `{}` returns a value, remove leading underscore
The argnames argument of pytest.mark.parametrize takes a string or a sequence of strings. For a single parameter, it's preferable to use a string. For multiple parameters, it's preferable to use the style configured via the lint.flake8-pytest-style.parametrize-names-type setting. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT006- Message
Wrong type passed to first argument of `pytest.mark.parametrize`; expected {}
The argvalues argument of pytest.mark.parametrize takes an iterator of parameter values, which can be provided as lists or tuples. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT007- Message
Wrong values type in `pytest.mark.parametrize` expected `{}`- Message
Wrong values type in `pytest.mark.parametrize` expected `{}` of `{}`
When patching calls, an explicit return_value better conveys the intent than a lambda function, assuming the lambda does not use the arguments passed to it. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT008- Message
Use `return_value=` instead of patching with `lambda`
To make use of pytest's assertion rewriting, a regular assert statement is preferred over unittest's assertion methods. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT009- Message
Use a regular `assert` instead of unittest-style `{}`
pytest.raises expects to receive an expected exception as its first argument. If omitted, the pytest.raises call will fail at runtime. The rule will also accept calls without an expected exception but with match and/or check keyword arguments, which are also valid after pytest version 8.4.0. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT010- Message
Set the expected exception in `pytest.raises()`
pytest.raises(Error) will catch any Error and may catch errors that are unrelated to the code under test. To avoid this, pytest.raises should be called with a match parameter (to constrain the exception message) or a check parameter (to constrain the exception itself). The exception names that require a match or check parameter can be configured via the lint.flake8-pytest-style.raises-require-match-for and lint.flake8-pytest-style.raises-extend-require-match-for settings. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT011- Message
`pytest.raises({})` is too broad, set the `match` parameter or use a more specific exception
When a pytest.raises is used as a context manager and contains multiple statements, it can lead to the test passing when it actually should fail. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT012- Message
`pytest.raises()` block should contain a single simple statement
For consistency, pytest should be imported as import pytest and its members should be accessed in the form of pytest.xxx.yyy for consistency Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT013- Message
Incorrect import of `pytest`; use `import pytest` instead
Duplicate test cases are redundant and should be removed. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.285.
- Code
PT014- Message
Duplicate of test case at index {} in `pytest.mark.parametrize`
pytest.fail conveys the intent more clearly than assert falsy_value. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT015- Message
Assertion always fails, replace with `pytest.fail()`
pytest.fail calls without a message make it harder to understand and debug test failures. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT016- Message
No message passed to `pytest.fail()`
When testing for exceptions, pytest.raises() should be used instead of assert statements in except clauses, as it's more explicit and idiomatic. Further, pytest.raises() will fail if the exception is _not_ raised, unlike the assert statement. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT017- Message
Found assertion on exception `{}` in `except` block, use `pytest.raises()` instead
Composite assertion statements are harder to debug upon failure, as the failure message will not indicate which condition failed. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT018- Message
Assertion should be broken down into multiple parts
In pytest, fixture injection is used to activate fixtures in a test function. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT019- Message
Fixture `{}` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
pytest.yield_fixture is deprecated. pytest.fixture should be used instead. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT020- Message
`@pytest.yield_fixture` is deprecated, use `@pytest.fixture`
pytest offers two ways to perform cleanup in fixture code. The first is sequential (via the yield statement), the second callback-based (via request.addfinalizer). Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT021- Message
Use `yield` instead of `request.addfinalizer`
In pytest fixtures, the yield expression should only be used for fixtures that include teardown code, to clean up the fixture after the test function has finished executing. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT022- Message
No teardown in fixture `{}`, use `return` instead of `yield`
If a @pytest.mark.<marker>() doesn't take any arguments, the parentheses are optional. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT023- Message
Use `@pytest.mark.{}{}` over `@pytest.mark.{}{}`
pytest.mark.asyncio is unnecessary for fixtures. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT024- Message
`pytest.mark.asyncio` is unnecessary for fixtures
The pytest.mark.usefixtures decorator has no effect on pytest fixtures. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT025- Message
`pytest.mark.usefixtures` has no effect on fixtures
A @pytest.mark.usefixtures() decorator that isn't passed any arguments is useless and should be removed. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.208.
- Code
PT026- Message
Useless `pytest.mark.usefixtures` without parameters
To enforce the assertion style recommended by pytest, pytest.raises is preferred over the exception-related assertion methods in unittest, like assertRaises. Ruff takes this rule from flake8-pytest-style and made it stable in v0.0.285.
- Code
PT027- Message
Use `pytest.raises` instead of unittest-style `{}`
Such a parameter will always have the default value during the test regardless of whether a fixture with the same name is defined. Ruff takes this rule from flake8-pytest-style and made it stable in 0.12.0.
- Code
PT028- Message
Test function parameter `{}` has default argument