Reusing a builtin name for the name of a variable increases the difficulty of reading and maintaining the code, and can cause non-obvious errors, as readers may mistake the variable for the builtin and vice versa. Ruff takes this rule from flake8-builtins and made it stable in v0.0.48.
- Code
A001- Message
Variable `{}` is shadowing a Python builtin
Reusing a builtin name for the name of an argument increases the difficulty of reading and maintaining the code, and can cause non-obvious errors, as readers may mistake the argument for the builtin and vice versa. Ruff takes this rule from flake8-builtins and made it stable in v0.0.48.
- Code
A002- Message
Function argument `{}` is shadowing a Python builtin
Reusing a builtin name for the name of an attribute increases the difficulty of reading and maintaining the code, and can cause non-obvious errors, as readers may mistake the attribute for the builtin and vice versa. Ruff takes this rule from flake8-builtins and made it stable in v0.0.48.
- Code
A003- Message
Python builtin is shadowed by class attribute `{}` from {}- Message
Python builtin is shadowed by method `{}` from {}
Reusing a builtin for the name of an import increases the difficulty of reading and maintaining the code, and can cause non-obvious errors, as readers may mistake the variable for the builtin and vice versa. Ruff takes this rule from flake8-builtins and made it stable in 0.8.0.
- Code
A004- Message
Import `{}` is shadowing a Python builtin
Reusing a standard-library module name for the name of a module increases the difficulty of reading and maintaining the code, and can cause non-obvious errors. Readers may mistake the first-party module for the standard-library module and vice versa. Ruff takes this rule from flake8-builtins and made it stable in 0.9.0.
- Code
A005- Message
Module `{}` shadows a Python standard-library module
Reusing a builtin name for the name of a lambda argument increases the difficulty of reading and maintaining the code and can cause non-obvious errors. Readers may mistake the variable for the builtin, and vice versa. Ruff takes this rule from flake8-builtins and made it stable in 0.9.0.
- Code
A006- Message
Lambda argument `{}` is shadowing a Python builtin
Mypy generates an error if you try to instantiate an abstract base class (ABC). An abstract base class is a class with at least one abstract method or attribute. (See also :pyabc module documentation). mypy enables this error code by default.
- Code
abstract- Severity
- error
When initializing an Airflow Operator, for consistency, the variable name should match the task_id value. This makes it easier to follow the flow of the Dag. Ruff takes this rule from Airflow and made it stable in v0.0.271.
- Code
AIR001- Message
Task variable name should match the `task_id`: "{}"
The default value of the schedule parameter on Airflow 2 and schedule_interval on Airflow 1 is timedelta(days=1), which is almost never what a user is looking for. Airflow 3 changed the default value to None, and would break existing Dags using the implicit default. Ruff takes this rule from Airflow and made it stable in 0.13.0.
- Code
AIR002- Message
`DAG` or `@dag` should have an explicit `schedule` argument
Calling Variable.get() at module level or in operator constructor arguments causes a database query every time the Dag file is parsed by the scheduler. This can degrade Dag parsing performance and, in some cases, cause the Dag file to time out before it is fully parsed. Ruff takes this rule from Airflow. It is in preview.
- Code
AIR003- Message
`Variable.get()` outside of a task
When a branch function has at least two return statements and exactly one of them returns a non-empty list, the function is effectively acting as a short-circuit operator. Using @task.short_circuit or ShortCircuitOperator is simpler and more readable in such cases. Ruff takes this rule from Airflow. It is in preview.
- Code
AIR004- Message
`@task.branch` can be replaced with `@task.short_circuit`- Message
`BranchPythonOperator` can be replaced with `ShortCircuitOperator`
Using {{ ti.xcom_pull(task_ids='some_task') }} as a string template to access the output of an upstream task is less readable and more error-prone than using the .output attribute on the task object directly. The .output attribute provides better IDE support and makes task dependencies more explicit. Ruff takes this rule from Airflow. It is in preview.
- Code
AIR201- Message
Use the `.output` attribute on the task object for "{}" instead of `xcom_pull` in a template string
At runtime, Airflow infers multiple_outputs from the return type annotation: if it resolves to a subclass of collections.abc.Mapping, the return value is split into one XCom per key; otherwise it is stored as a single XCom. This couples typing to XCom layout in a non-obvious way — renaming, removing, or refining the return annotation silently changes the Dag's XCom behavior. Ruff takes this rule from Airflow. It is in preview.
- Code
AIR202- Message
`@task`-decorated function relies on `multiple_outputs` inference
Airflow 3.0 removed various deprecated functions, members, and other values. Some have more modern replacements. Others are considered too niche and not worth continued maintenance in Airflow. Ruff takes this rule from Airflow and made it stable in 0.13.0.
- Code
AIR301- Message
`{}` is removed in Airflow 3.0
Airflow 3.0 moved various deprecated functions, members, and other values to its providers. The user needs to install the corresponding provider and replace the original usage with the one in the provider. Ruff takes this rule from Airflow and made it stable in 0.13.0.
- Code
AIR302- Message
`{}` is moved into `{}` provider in Airflow 3.0;
Airflow 3.0 introduces changes to function signatures. Code that worked in Airflow 2.x will raise a runtime error if not updated in Airflow 3.0. Ruff takes this rule from Airflow and made it stable in 0.16.0.
- Code
AIR303- Message
`{}` signature is changed in Airflow 3.0
Using runtime-varying values as arguments to Dag or task constructors causes the serialized Dag hash to change on every parse, creating infinite Dag versions in the dag_version and serialized_dag tables. This leads to unbounded database growth and can eventually cause out-of-memory conditions. Ruff takes this rule from Airflow. It is in preview.
- Code
AIR304- Message
`{}()` produces a value that changes at runtime; using it in a Dag or task argument causes infinite Dag version creation
Airflow 3.0 removed various deprecated functions, members, and other values. Some have more modern replacements. Others are considered too niche and not worth continued maintenance in Airflow. Even though these symbols still work fine on Airflow 3.0, they are expected to be removed in a future version. Where available, users should replace the removed functionality with the new alternatives. Ruff takes this rule from Airflow and made it stable in 0.13.0.
- Code
AIR311- Message
`{}` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
Airflow 3.0 moved various deprecated functions, members, and other values to its providers. Even though these symbols still work fine on Airflow 3.0, they are expected to be removed in a future version. The user is suggested to install the corresponding provider and replace the original usage with the one in the provider. Ruff takes this rule from Airflow and made it stable in 0.13.0.
- Code
AIR312- Message
`{}` is deprecated and moved into `{}` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version.
Airflow 3.1 deprecated or moved various functions, members, and other values. Ruff takes this rule from Airflow. It is in preview.
- Code
AIR321- Message
`{}` is moved in Airflow 3.1
Type annotations are a good way to document the types of function arguments. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any provided arguments match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN001- Message
Missing type annotation for function argument `{}`
Type annotations are a good way to document the types of function arguments. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any provided arguments match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN002- Message
Missing type annotation for `*{}`
Type annotations are a good way to document the types of function arguments. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any provided arguments match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN003- Message
Missing type annotation for `**{}`
Type annotations are a good way to document the types of function arguments. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any provided arguments match expectation. Ruff takes this rule from flake8-annotations, and removed it.
- Code
ANN101- Message
Missing type annotation for `{}` in method
Type annotations are a good way to document the types of function arguments. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any provided arguments match expectation. Ruff takes this rule from flake8-annotations, and removed it.
- Code
ANN102- Message
Missing type annotation for `{}` in classmethod
Type annotations are a good way to document the return types of functions. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any returned values, and the types expected by callers, match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN201- Message
Missing return type annotation for public function `{}`
Type annotations are a good way to document the return types of functions. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any returned values, and the types expected by callers, match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN202- Message
Missing return type annotation for private function `{}`
Type annotations are a good way to document the return types of functions. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any returned values, and the types expected by callers, match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN204- Message
Missing return type annotation for special method `{}`
Type annotations are a good way to document the return types of functions. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any returned values, and the types expected by callers, match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN205- Message
Missing return type annotation for staticmethod `{}`
Type annotations are a good way to document the return types of functions. They also help catch bugs, when used alongside a type checker, by ensuring that the types of any returned values, and the types expected by callers, match expectation. Ruff takes this rule from flake8-annotations and made it stable in v0.0.105.
- Code
ANN206- Message
Missing return type annotation for classmethod `{}`
Any is a special type indicating an unconstrained type. When an expression is annotated with type Any, type checkers will allow all operations on it. Ruff takes this rule from flake8-annotations and made it stable in v0.0.108.
- Code
ANN401- Message
Dynamically typed expressions (typing.Any) are disallowed in `{}`
Sometimes a user may accidentally omit an annotation for a function, and mypy will not check the body of this function (unless one uses --check-untyped-defs or --disallow-untyped-defs). To avoid such situations go unnoticed, mypy will show a note, if there are any type annotations in an unchecked function. mypy enables this error code by default.
- Code
annotation-unchecked- Severity
- note
Mypy checks that argument types in a call match the declared argument types in the signature of the called function (if one exists). mypy enables this error code by default.
- Code
arg-type- Severity
- error
An argument that is defined but not used is likely a mistake, and should be removed to avoid confusion. Ruff takes this rule from flake8-unused-arguments and made it stable in v0.0.168.
- Code
ARG001- Message
Unused function argument: `{}`
An argument that is defined but not used is likely a mistake, and should be removed to avoid confusion. Ruff takes this rule from flake8-unused-arguments and made it stable in v0.0.168.
- Code
ARG002- Message
Unused method argument: `{}`
An argument that is defined but not used is likely a mistake, and should be removed to avoid confusion. Ruff takes this rule from flake8-unused-arguments and made it stable in v0.0.168.
- Code
ARG003- Message
Unused class method argument: `{}`
An argument that is defined but not used is likely a mistake, and should be removed to avoid confusion. Ruff takes this rule from flake8-unused-arguments and made it stable in v0.0.168.
- Code
ARG004- Message
Unused static method argument: `{}`
An argument that is defined but not used is likely a mistake, and should be removed to avoid confusion. Ruff takes this rule from flake8-unused-arguments and made it stable in v0.0.168.
- Code
ARG005- Message
Unused lambda argument: `{}`
The inferred type for an expression passed to assert_type must match the provided type. mypy enables this error code by default.
- Code
assert-type- Severity
- error
Mypy checks that the assigned expression is compatible with the assignment target (or targets). mypy enables this error code by default.
- Code
assignment- Severity
- error
Some asynchronous context managers, such as asyncio.timeout and trio.move_on_after, have no effect unless they contain a checkpoint. The use of such context managers without an await, async with or async for statement is likely a mistake. Ruff takes this rule from flake8-async and made it stable in v0.0.269.
- Code
ASYNC100- Message
A `with {}(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint.
Many of the functions exposed by trio are asynchronous, and must be awaited to take effect. Calling a trio function without an await can lead to RuntimeWarning diagnostics and unexpected behaviour. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC105- Message
Call to `{}` is not immediately awaited
Rather than implementing asynchronous timeout behavior manually, prefer built-in timeout functionality, such as asyncio.timeout, trio.fail_after, or anyio.move_on_after, among others. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC109- Message
Async function definition with a `timeout` parameter
Busy-waiting for a condition in a loop forces a tradeoff between efficiency and latency: shorter sleep times improve responsiveness but waste more CPU cycles, while longer sleep times reduce CPU usage but delay reaction to state changes. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC110- Message
Use `{}.Event` instead of awaiting `{}.sleep` in a `while` loop
trio.sleep(0) is equivalent to calling trio.lowlevel.checkpoint(). However, the latter better conveys the intent of the code. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC115- Message
Use `{}.lowlevel.checkpoint()` instead of `{}.sleep(0)`
Calling sleep() with a delay greater than 24 hours is usually intended to sleep indefinitely. Instead of using a large delay, trio.sleep_forever() or anyio.sleep_forever() better conveys the intent. Ruff takes this rule from flake8-async and made it stable in 0.13.0.
- Code
ASYNC116- Message
`{}.sleep()` with >24 hour interval should usually be `{}.sleep_forever()`
Yielding inside a context manager in an async generator is unsafe because the cleanup of the context manager may be delayed until the generator is closed, at which point await is no longer allowed. This can lead to resource leaks or other bugs. Ruff takes this rule from flake8-async. It is in preview.
- Code
ASYNC119- Message
Yield in context manager in async generator may not trigger cleanup
Blocking an async function via a blocking HTTP call will block the entire event loop, preventing it from executing other tasks while waiting for the HTTP response, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC210- Message
Async functions should not call blocking HTTP methods
Blocking an async function via a blocking HTTP call will block the entire event loop, preventing it from executing other tasks while waiting for the HTTP response, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.15.0.
- Code
ASYNC212- Message
Blocking httpx method {}.{}() in async context, use httpx.AsyncClient
Blocking an async function via a blocking call will block the entire event loop, preventing it from executing other tasks while waiting for the call to complete, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC220- Message
Async functions should not create subprocesses with blocking methods
Blocking an async function via a blocking call will block the entire event loop, preventing it from executing other tasks while waiting for the call to complete, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC221- Message
Async functions should not run processes with blocking methods
Blocking an async function via a blocking call will block the entire event loop, preventing it from executing other tasks while waiting for the call to complete, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC222- Message
Async functions should not wait on processes with blocking methods
Blocking an async function via a blocking call will block the entire event loop, preventing it from executing other tasks while waiting for the call to complete, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC230- Message
Async functions should not open files with blocking methods like `open`
Calling some os.path or pathlib.Path methods in an async function will block the entire event loop, preventing it from executing other tasks while waiting for the operation. This negates the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.15.0.
- Code
ASYNC240- Message
Async functions should not use {} methods, use trio.Path or anyio.path
Blocking an async function via a blocking input call will block the entire event loop, preventing it from executing other tasks while waiting for user input, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.15.0.
- Code
ASYNC250- Message
Blocking call to `input()` in async context
Blocking an async function via a time.sleep call will block the entire event loop, preventing it from executing other tasks while waiting for the time.sleep, negating the benefits of asynchronous programming. Ruff takes this rule from flake8-async and made it stable in 0.5.0.
- Code
ASYNC251- Message
Async functions should not call `time.sleep`
Mypy checks that an attribute is defined in the target class or module when using the dot operator. This applies to both getting and setting an attribute. mypy enables this error code by default.
- Code
attr-defined- Severity
- error
await must be used inside a coroutine. mypy enables this error code by default.
- Code
await-not-async- Severity
- error
Python does not support the unary prefix increment or decrement operator. Writing ++n is equivalent to +(+(n)) and writing --n is equivalent to -(-(n)). In both cases, it is equivalent to n. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.83.
- Code
B002- Message
Python does not support the unary prefix increment operator (`++`)- Message
Python does not support the unary prefix decrement operator (`--`)
In Python, os.environ is a mapping that represents the environment of the current process. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.102.
- Code
B003- Message
Assigning to `os.environ` doesn't clear the environment
Using hasattr is an unreliable mechanism for testing if an object is callable. If obj implements a custom __getattr__, or if its __call__ is itself not callable, you may get misleading results. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.106.
- Code
B004- Message
Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results.
All characters in the call to .strip(), .lstrip(), or .rstrip() are removed from the leading and trailing ends of the string. If the string contains multiple characters, the reader may be misled into thinking that a prefix or suffix is being removed, rather than a set of characters. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.106.
- Code
B005- Message
Using `.strip()` with multi-character strings is misleading
Function defaults are evaluated once, when the function is defined. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.92.
- Code
B006- Message
Do not use mutable data structures for argument defaults
Defining a variable in a loop statement that is never used can confuse readers. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.84.
- Code
B007- Message
Loop control variable `{}` not used within loop body- Message
Loop control variable `{}` may not be used within loop body
Any function call that's used in a default argument will only be performed once, at definition time. The returned value will then be reused by all calls to the function, which can lead to unexpected behaviour. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.102.
- Code
B008- Message
Do not perform function call `{}` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable- Message
Do not perform function call in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
getattr is used to access attributes dynamically. If the attribute is defined as a constant, it is no safer than a typical property access. When possible, prefer property access over getattr calls, as the former is more concise and idiomatic. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.110.
- Code
B009- Message
Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
setattr is used to set attributes dynamically. If the attribute is defined as a constant, it is no safer than a typical property access. When possible, prefer property access over setattr calls, as the former is more concise and idiomatic. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.111.
- Code
B010- Message
Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
Python removes assert statements when running in optimized mode (python -O), making assert False an unreliable means of raising an AssertionError. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.67.
- Code
B011- Message
Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`
The use of break, continue, and return statements in finally blocks can cause exceptions to be silenced. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.116.
- Code
B012- Message
`{}` inside `finally` blocks cause exceptions to be silenced
A tuple with a single element can be more concisely and idiomatically expressed as a single value. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.89.
- Code
B013- Message
A length-one tuple literal is redundant in exception handlers
Including the same exception multiple times in the same handler is redundant, as the first exception will catch the exception, making the second exception unreachable. The same applies to exception hierarchies, as a handler for a parent exception (like Exception) will also catch child exceptions (like ValueError). Ruff takes this rule from flake8-bugbear and made it stable in v0.0.67.
- Code
B014- Message
Exception handler with duplicate exception: `{}`- Message
Exception handler with duplicate exceptions: {}
Useless comparisons have no effect on the program, and are often included by mistake. If the comparison is intended to enforce an invariant, prepend the comparison with an assert. Otherwise, remove it entirely. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.102.
- Code
B015- Message
Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.- Message
Pointless comparison at end of function scope. Did you mean to return the expression result?
raise must be followed by an exception instance or an exception class, and exceptions must be instances of BaseException or a subclass thereof. Raising a literal will raise a TypeError at runtime. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.102.
- Code
B016- Message
Cannot raise a literal. Did you intend to return it or raise an Exception?
These forms catch every Exception, which can lead to tests passing even if, e.g., the code under consideration raises a SyntaxError or IndentationError. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.83.
- Code
B017- Message
Do not assert blind exception: `{}`
Useless expressions have no effect on the program, and are often included by mistake. Assign a useless expression to a variable, or remove it entirely. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.100.
- Code
B018- Message
Found useless expression. Either assign it to a variable or remove it.- Message
Found useless attribute access. Either assign it to a variable or remove it.
Using the functools.lru_cache and functools.cache decorators on methods can lead to memory leaks, as the global cache will retain a reference to the instance, preventing it from being garbage collected. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.114.
- Code
B019- Message
Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
Loop control variables should not override the loop iterable, as this can lead to confusing behavior. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.121.
- Code
B020- Message
Loop control variable `{}` overrides iterable it iterates
Python will interpret the f-string as a joined string, rather than as a docstring. As such, the "docstring" will not be accessible via the __doc__ attribute, nor will it be picked up by any automated documentation tooling. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.116.
- Code
B021- Message
f-string used as docstring. Python will interpret this as a joined string, rather than a docstring.
contextlib.suppress is a context manager that suppresses exceptions. It takes, as arguments, the exceptions to suppress within the enclosed block. If no exceptions are specified, then the context manager won't suppress any exceptions, and is thus redundant. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.118.
- Code
B022- Message
No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant
The loop variable is not bound in the function definition, so it will always have the value it had in the last iteration when the function is called. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.139.
- Code
B023- Message
Function definition does not bind loop variable `{}`
Annotated but unassigned class variables are regarded as abstract. Abstract base classes are used to define interfaces. If an abstract base class has no abstract methods or properties, you may have forgotten to add an abstract method or property to the class, or omitted an @abstractmethod decorator. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.118.
- Code
B024- Message
`{}` is an abstract base class, but it has no abstract methods or properties
Duplicate exception handlers are redundant, as the first handler will catch the exception, making the second handler unreachable. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.67.
- Code
B025- Message
try-except* block with duplicate exception `{}`- Message
try-except block with duplicate exception `{}`
In Python, you can use star-argument unpacking to pass a list or tuple of arguments to a function. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.109.
- Code
B026- Message
Star-arg unpacking after a keyword argument is strongly discouraged
Empty methods in abstract base classes without an abstract decorator may be be indicative of a mistake. If the method is meant to be abstract, add an @abstractmethod decorator to the method. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.118.
- Code
B027- Message
`{}` is an empty method in an abstract base class, but has no abstract decorator
The warnings.warn method uses a stacklevel of 1 by default, which will output a stack frame of the line on which the "warn" method is called. Setting it to a higher number will output a stack frame from higher up the stack. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.257.
- Code
B028- Message
No explicit `stacklevel` keyword argument found
An exception handler that catches an empty tuple will not catch anything, and is indicative of a mistake. Instead, add exceptions to the except clause. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.250.
- Code
B029- Message
Using `except* ():` with an empty tuple does not catch anything; add exceptions to handle- Message
Using `except ():` with an empty tuple does not catch anything; add exceptions to handle
Catching classes that do not inherit from BaseException will raise a TypeError. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.255.
- Code
B030- Message
`except*` handlers should only be exception classes or tuples of exception classes- Message
`except` handlers should only be exception classes or tuples of exception classes
Using the generator more than once will do nothing on the second usage. If that data is needed later, it should be stored as a list. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.260.
- Code
B031- Message
Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage
The use of a colon (:) in lieu of an assignment (=) can be syntactically valid, but is almost certainly a mistake when used in a subscript or attribute assignment. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.250.
- Code
B032- Message
Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)?
In Python, sets are unordered collections of unique elements. Including a duplicate item in a set literal is redundant, as the duplicate item will be replaced with a single item at runtime. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.271.
- Code
B033- Message
Sets should not contain duplicate item `{}`- Message
Sets should not contain duplicate items, but `{}` and `{}` has the same value
Passing count, maxsplit, or flags as positional arguments to re.sub, re.subn, or re.split can lead to confusion, as most methods in the re module accept flags as the third positional argument, while re.sub, re.subn, and re.split have different signatures. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.278.
- Code
B034- Message
`{}` should pass `{}` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions
Using a static key (like a string literal) in a dictionary comprehension is usually a mistake, as it will result in a dictionary with only one key, despite the comprehension iterating over multiple values. Ruff takes this rule from flake8-bugbear and made it stable in v0.2.0.
- Code
B035- Message
Dictionary comprehension uses static key: `{}`- Message
Dictionary comprehension uses static key
The ContextVar default is evaluated once, when the ContextVar is defined. Ruff takes this rule from flake8-bugbear and made it stable in 0.8.0.
- Code
B039- Message
Do not use mutable data structures for `ContextVar` defaults
delattr is used to delete attributes dynamically. If the attribute is defined as a constant, it is no safer than a typical property deletion. When possible, prefer del statements over delattr calls, as the former is more concise and idiomatic. Ruff takes this rule from flake8-bugbear. It is in preview.
- Code
B043- Message
Do not call `delattr` with a constant attribute value. It is not any safer than normal property deletion.
Using return {value} in a generator function was syntactically invalid in Python 2. In Python 3 return {value} _can_ be used in a generator; however, the combination of yield and return can lead to confusing behavior, as the return statement will cause the generator to raise StopIteration with the value provided, rather than returning the value to the caller. Ruff takes this rule from flake8-bugbear. It is in preview.
- Code
B901- Message
Using `yield` and `return {}` in a generator function can lead to confusing behavior
Classes with just an __init__ are possibly better off being a dataclass or a namedtuple, which have less boilerplate. Ruff takes this rule from flake8-bugbear. It is in preview.
- Code
B903- Message
Class could be dataclass or namedtuple
In Python, raise can be used with or without an exception from which the current exception is derived. This is known as exception chaining. When printing the stack trace, chained exceptions are displayed in such a way so as make it easier to trace the exception back to its root cause. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.138.
- Code
B904- Message
Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling- Message
Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling
By default, if the iterables passed to zip are of different lengths, the resulting iterator will be silently truncated to the length of the shortest iterable. This can lead to subtle bugs. Ruff takes this rule from flake8-bugbear and made it stable in v0.0.167.
- Code
B905- Message
`zip()` without an explicit `strict=` parameter
When iterating over an iterable, mutating the iterable can lead to unexpected behavior, like skipping elements or infinite loops. Ruff takes this rule from flake8-bugbear. It is in preview.
- Code
B909- Message
Mutation to loop iterable `{}` during iteration- Message
Mutation to loop iterable during iteration
By default, if the length of the iterable is not divisible by the second argument to itertools.batched, the last batch will be shorter than the rest. Ruff takes this rule from flake8-bugbear and made it stable in 0.10.0.
- Code
B911- Message
`itertools.batched()` without an explicit `strict` parameter
By default, if the iterables passed to map are of different lengths, the resulting iterator will be silently truncated to the length of the shortest iterable. This can lead to subtle bugs. Ruff takes this rule from flake8-bugbear and made it stable in 0.15.0.
- Code
B912- Message
`map()` without an explicit `strict=` parameter
This includes except BaseException and except Exception. Overly broad except clauses can lead to unexpected behavior, such as catching KeyboardInterrupt or SystemExit exceptions that prevent the user from exiting the program. Ruff takes this rule from flake8-blind-except and made it stable in v0.0.127.
- Code
BLE001- Message
Do not catch blind exception: `{}`
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...). pylint calls it invalid-name.
- Code
C0103- Severity
- convention
- Message
{} name "{}" doesn't conform to {}
Used when the name matches bad-names or bad-names-rgxs- (unauthorized names). pylint calls it disallowed-name.
- Code
C0104- Severity
- convention
- Message
Disallowed name "{}"
Emitted when a TypeVar name doesn't reflect its type variance. According to PEP8, it is recommended to add suffixes '_co' and '_contra' to the variables used to declare covariant or contravariant behaviour respectively. Invariant (default) variables do not require a suffix. The message is also emitted when invariant variables do have a suffix. pylint calls it typevar-name-incorrect-variance.
- Code
C0105- Severity
- convention
- Message
Type variable name does not reflect variance{}
Used when a module, function, class or method has an empty docstring (it would be too easy ;). pylint calls it empty-docstring.
- Code
C0112- Severity
- convention
- Message
Empty {} docstring
Used when a module has no docstring. Empty modules do not require a docstring. pylint calls it missing-module-docstring.
- Code
C0114- Severity
- convention
- Message
Missing module docstring
Used when a class has no docstring. Even an empty class must have a docstring. pylint calls it missing-class-docstring.
- Code
C0115- Severity
- convention
- Message
Missing class docstring
Used when a function or method has no docstring. Some special methods like __init__ do not require a docstring. pylint calls it missing-function-docstring.
- Code
C0116- Severity
- convention
- Message
Missing function or method docstring
Used when a boolean expression contains an unneeded negation, e.g. when two negation operators cancel each other out. pylint calls it unnecessary-negation.
- Code
C0117- Severity
- convention
- Message
Consider changing "{}" to "{}"
Used when an expression is compared to singleton values like True, False or None. pylint calls it singleton-comparison.
- Code
C0121- Severity
- convention
- Message
Comparison {} should be {}
The idiomatic way to perform an explicit typecheck in Python is to use isinstance(x, Y) rather than type(x) == Y, type(x) is Y. Though there are unusual situations where these give different results. pylint calls it unidiomatic-typecheck.
- Code
C0123- Severity
- convention
- Message
Use isinstance() rather than type() for a typecheck.
Emitted when both the "covariant" and "contravariant" keyword arguments are set to "True" in a TypeVar. pylint calls it typevar-double-variance.
- Code
C0131- Severity
- convention
- Message
TypeVar cannot be both covariant and contravariant
Emitted when a TypeVar is assigned to a variable that does not match its name argument. pylint calls it typevar-name-mismatch.
- Code
C0132- Severity
- convention
- Message
TypeVar name "{}" does not match assigned variable name "{}"
Emitted when code that iterates with range and len is encountered. Such code can be simplified by using the enumerate builtin. pylint calls it consider-using-enumerate.
- Code
C0200- Severity
- convention
- Message
Consider using enumerate instead of iterating with range and len
Emitted when the keys of a dictionary are iterated through the .keys() method or when .keys() is used for a membership check. It is enough to iterate through the dictionary itself, for key in dictionary. For membership checks, if key in dictionary is faster. pylint calls it consider-iterating-dictionary.
- Code
C0201- Severity
- convention
- Message
Consider iterating the dictionary directly instead of calling .keys()
Used when a class method has a first argument named differently than the value specified in valid-classmethod-first-arg option (default to "cls"), recommended to easily differentiate them from regular instance methods. pylint calls it bad-classmethod-argument.
- Code
C0202- Severity
- convention
- Message
Class method {} should have {} as first argument
Used when a metaclass method has a first argument named differently than the value specified in valid-classmethod-first-arg option (default to "cls"), recommended to easily differentiate them from regular instance methods. pylint calls it bad-mcs-method-argument.
- Code
C0203- Severity
- convention
- Message
Metaclass method {} should have {} as first argument
Used when a metaclass class method has a first argument named differently than the value specified in valid-metaclass-classmethod-first-arg option (default to "mcs"), recommended to easily differentiate them from regular instance methods. pylint calls it bad-mcs-classmethod-argument.
- Code
C0204- Severity
- convention
- Message
Metaclass class method {} should have {} as first argument
Used when a class __slots__ is a simple string, rather than an iterable. pylint calls it single-string-used-for-slots.
- Code
C0205- Severity
- convention
- Message
Class __slots__ should be a non-string iterable
Emitted when iterating over the keys of a dictionary and accessing the value by index lookup. Both the key and value can be accessed by iterating using the .items() method of the dictionary instead. pylint calls it consider-using-dict-items.
- Code
C0206- Severity
- convention
- Message
Consider iterating with .items()
Emitted when accessing only the first or last element of str.split(). The first and last element can be accessed by using str.split(sep, maxsplit=1)[0] or str.rsplit(sep, maxsplit=1)[-1] instead. pylint calls it use-maxsplit-arg.
- Code
C0207- Severity
- convention
- Message
Use {} instead
When iterating over values, sequence types (e.g., lists, tuples, ranges) are more efficient than sets. pylint calls it use-sequence-for-iteration.
- Code
C0208- Severity
- convention
- Message
Use a sequence type when iterating over values
Used when we detect a string that is being formatted with format() or % which could potentially be an f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6. pylint calls it consider-using-f-string.
- Code
C0209- Severity
- convention
- Message
Formatting a regular string which could be an f-string
Used when a line is longer than a given number of characters. pylint calls it line-too-long.
- Code
C0301- Severity
- convention
- Message
Line too long ({}/{})
Used when a module has too many lines, reducing its readability. pylint calls it too-many-lines.
- Code
C0302- Severity
- convention
- Message
Too many lines in module ({}/{})
Used when there is whitespace between the end of a line and the newline. pylint calls it trailing-whitespace.
- Code
C0303- Severity
- convention
- Message
Trailing whitespace
Used when the last line in a file is missing a newline. pylint calls it missing-final-newline.
- Code
C0304- Severity
- convention
- Message
Final newline missing
Used when there are trailing blank lines in a file. pylint calls it trailing-newlines.
- Code
C0305- Severity
- convention
- Message
Trailing newlines
Used when more than one statement is found on the same line. pylint calls it multiple-statements.
- Code
C0321- Severity
- convention
- Message
More than one statement on a single line
Used when a single item in parentheses follows an if, for, or other keyword. pylint calls it superfluous-parens.
- Code
C0325- Severity
- convention
- Message
Unnecessary parens after {} keyword
Used when there are mixed (LF and CRLF) newline signs in a file. pylint calls it mixed-line-endings.
- Code
C0327- Severity
- convention
- Message
Mixed line endings LF and CRLF
Used when there is different newline than expected. pylint calls it unexpected-line-ending-format.
- Code
C0328- Severity
- convention
- Message
Unexpected line ending format. There is '{}' while it should be '{}'.
It is unnecessary to use list() around a generator expression, since there are equivalent comprehensions for these types. Using a comprehension is clearer and more idiomatic. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.61.
- Code
C400- Message
Unnecessary generator (rewrite using `list()`)- Message
Unnecessary generator (rewrite as a list comprehension)
Used when a word in comment is not spelled correctly. pylint calls it wrong-spelling-in-comment.
- Code
C0401- Severity
- convention
- Message
Wrong spelling of a word '{}' in a comment:
It is unnecessary to use set around a generator expression, since there are equivalent comprehensions for these types. Using a comprehension is clearer and more idiomatic. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.61.
- Code
C401- Message
Unnecessary generator (rewrite using `set()`)- Message
Unnecessary generator (rewrite as a set comprehension)
Used when a word in docstring is not spelled correctly. pylint calls it wrong-spelling-in-docstring.
- Code
C0402- Severity
- convention
- Message
Wrong spelling of a word '{}' in a docstring:
It is unnecessary to use dict() around a generator expression, since there are equivalent comprehensions for these types. Using a comprehension is clearer and more idiomatic. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.61.
- Code
C402- Message
Unnecessary generator (rewrite as a dict comprehension)
Used when a word in docstring cannot be checked by enchant. pylint calls it invalid-characters-in-docstring.
- Code
C0403- Severity
- convention
- Message
Invalid characters {} in a docstring
It's unnecessary to use a list comprehension inside a call to set(), since there is an equivalent comprehension for this type. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.58.
- Code
C403- Message
Unnecessary list comprehension (rewrite as a set comprehension)
It's unnecessary to use a list comprehension inside a call to dict(), since there is an equivalent comprehension for this type. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.58.
- Code
C404- Message
Unnecessary list comprehension (rewrite as a dict comprehension)
It's unnecessary to use a list or tuple literal within a call to set(). Instead, the expression can be rewritten as a set literal. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.61.
- Code
C405- Message
Unnecessary {} literal (rewrite as a set literal)
It's unnecessary to use a list or tuple literal within a call to dict(). It can be rewritten as a dict literal ({}). Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.61.
- Code
C406- Message
Unnecessary {} literal (rewrite as a dict literal)
It's unnecessary to call, e.g., dict() as opposed to using an empty literal ({}). The former is slower because the name dict must be looked up in the global scope in case it has been rebound. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.61.
- Code
C408- Message
Unnecessary `{}()` call (rewrite as a literal)
It's unnecessary to use a list or tuple literal within a tuple() call, since there is a literal syntax for these types. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.66.
- Code
C409- Message
Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal)- Message
Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`)
Used when import statement importing multiple modules is detected. pylint calls it multiple-imports.
- Code
C0410- Severity
- convention
- Message
Multiple imports on one line ({})
It's unnecessary to use a list or tuple literal within a list() call, since there is a literal syntax for these types. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.66.
- Code
C410- Message
Unnecessary list literal passed to `list()` (remove the outer call to `list()`)- Message
Unnecessary tuple literal passed to `list()` (rewrite as a single list literal)
Used when PEP8 import order is not respected (standard imports first, then third-party libraries, then local imports). pylint calls it wrong-import-order.
- Code
C0411- Severity
- convention
- Message
{} should be placed before {}
It is redundant to use a list() call around a list comprehension. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.73.
- Code
C411- Message
Unnecessary `list()` call (remove the outer call to `list()`)
Used when imports are not grouped by packages. pylint calls it ungrouped-imports.
- Code
C0412- Severity
- convention
- Message
Imports from package {} are not grouped
Used when code and imports are mixed. pylint calls it wrong-import-position.
- Code
C0413- Severity
- convention
- Message
Import "{}" should be placed at the top of the module
It is unnecessary to use list() around sorted(), as the latter already returns a list. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.73.
- Code
C413- Message
Unnecessary `{}()` call around `sorted()`
Used when an import alias is same as original package, e.g., using import numpy as numpy instead of import numpy as np. pylint calls it useless-import-alias.
- Code
C0414- Severity
- convention
- Message
Import alias does not rename original package
It's unnecessary to double-cast or double-process iterables by wrapping the listed functions within an additional list(), set(), sorted(), or tuple() call. Doing so is redundant and can be confusing for readers. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.70.
- Code
C414- Message
Unnecessary `{}()` call within `{}()`
Used when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file. pylint calls it import-outside-toplevel.
- Code
C0415- Severity
- convention
- Message
Import outside toplevel ({})
It's unnecessary to reverse the order of an iterable when passing it into reversed(), set() or sorted() functions as they will change the order of the elements again. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.64.
- Code
C415- Message
Unnecessary subscript reversal of iterable within `{}()`
It's unnecessary to use a dict/list/set comprehension to build a data structure if the elements are unchanged. Wrap the iterable with dict(), list(), or set() instead. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.73.
- Code
C416- Message
Unnecessary {} comprehension (rewrite using `{}()`)
Using map(func, iterable) when func is a lambda is slower than using a generator expression or a comprehension, as the latter approach avoids the function call overhead, in addition to being more readable. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.74.
- Code
C417- Message
Unnecessary `map()` usage (rewrite using a {})
It's unnecessary to wrap a dict literal or comprehension within a dict() call, since the literal or comprehension syntax already returns a dictionary. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.262.
- Code
C418- Message
Unnecessary dict {} passed to `dict()` (remove the outer call to `dict()`)
Many builtin functions (this rule currently covers any and all in stable, along with min, max, and sum in preview) accept any iterable, including a generator. Constructing a temporary list via list comprehension is unnecessary and wastes memory for large iterables. Ruff takes this rule from flake8-comprehensions and made it stable in v0.0.262.
- Code
C419- Message
Unnecessary list comprehension- Message
Unnecessary set comprehension
It's unnecessary to use a dict comprehension to build a dictionary from an iterable when the value is static. Ruff takes this rule from flake8-comprehensions and made it stable in 0.10.0.
- Code
C420- Message
Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
The McCabe complexity of a function is a measure of the complexity of the control flow graph of the function. It is calculated by adding one to the number of decision points in the function. A decision point is a place in the code where the program has a choice of two or more paths to follow. Ruff takes this rule from mccabe and made it stable in v0.0.127.
- Code
C901- Message
`{}` is too complex ({} > {})
Empty sequences are considered false in a boolean context. You can either remove the call to 'len' (if not x) or compare the length against a scalar (if len(x) > 1). pylint calls it use-implicit-booleaness-not-len.
- Code
C1802- Severity
- convention
- Message
Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty
Empty sequences are considered false in a boolean context. Following this check blindly in weakly typed code base can create hard to debug issues. If the value can be something else that is falsey but not a sequence (for example None, an empty string, or 0) the code will not be equivalent. pylint calls it use-implicit-booleaness-not-comparison.
- Code
C1803- Severity
- convention
- Message
"{}" can be simplified to "{}", if it is strictly a sequence, as an empty {} is falsey
Empty string are considered false in a boolean context. Following this check blindly in weakly typed code base can create hard to debug issues. If the value can be something else that is falsey but not a string (for example None, an empty sequence, or 0) the code will not be equivalent. pylint calls it use-implicit-booleaness-not-comparison-to-string.
- Code
C1804- Severity
- convention
- Message
"{}" can be simplified to "{}", if it is strictly a string, as an empty string is falsey
0 is considered false in a boolean context. Following this check blindly in weakly typed code base can create hard to debug issues. If the value can be something else that is falsey but not an int (for example None, an empty string, or an empty sequence) the code will not be equivalent. pylint calls it use-implicit-booleaness-not-comparison-to-zero.
- Code
C1805- Severity
- convention
- Message
"{}" can be simplified to "{}", if it is strictly an int, as 0 is falsey
Used when the name contains at least one non-ASCII unicode character. See https://peps.python.org/pep-0672/#confusing-features for a background why this could be bad. If your programming guideline defines that you are programming in English, then there should be no need for non ASCII characters in Python Names. If not you can simply disable this check. pylint calls it non-ascii-name.
- Code
C2401- Severity
- convention
- Message
{} name "{}" contains a non-ASCII character, consider renaming it.
Used when the name contains at least one non-ASCII unicode character. See https://peps.python.org/pep-0672/#confusing-features for a background why this could be bad. If your programming guideline defines that you are programming in English, then there should be no need for non ASCII characters in Python Names. If not you can simply disable this check. pylint calls it non-ascii-module-import.
- Code
C2403- Severity
- convention
- Message
{} name "{}" contains a non-ASCII character, use an ASCII-only alias for import.
PEP8 recommends UTF-8 default encoding for Python files. See https://peps.python.org/pep-0008/#source-file-encoding. pylint calls it bad-file-encoding.
- Code
C2503- Severity
- convention
- Message
PEP8 recommends UTF-8 as encoding for Python files
Used when a dunder method is manually called instead of using the corresponding function/method/operator. pylint calls it unnecessary-dunder-call.
- Code
C2801- Severity
- convention
- Message
Unnecessarily calls dunder method {}. {}.
Used when a lambda expression is assigned to variable rather than defining a standard function with the "def" keyword. pylint calls it unnecessary-lambda-assignment.
- Code
C3001- Severity
- convention
- Message
Lambda expression assigned to a variable. Define a function using the "def" keyword instead.
Used when a lambda expression is directly called rather than executing its contents inline. pylint calls it unnecessary-direct-lambda-call.
- Code
C3002- Severity
- convention
- Message
Lambda expression called directly. Execute the expression inline instead.
Mypy expects that the number and names of arguments match the called function. Note that argument type checks have a separate error code arg-type. mypy enables this error code by default.
- Code
call-arg- Severity
- error
When you call an overloaded function, mypy checks that at least one of the signatures of the overload items match the argument types in the call. mypy enables this error code by default.
- Code
call-overload- Severity
- error
The presence of a trailing comma can reduce diff size when parameters or elements are added or removed from function calls, function definitions, literals, etc. Ruff takes this rule from flake8-commas and made it stable in v0.0.223.
- Code
COM812- Message
Trailing comma missing
The presence of a misplaced comma will cause Python to interpret the value as a tuple, which can lead to unexpected behaviour. Ruff takes this rule from flake8-commas and made it stable in v0.0.223.
- Code
COM818- Message
Trailing comma on bare tuple prohibited
Trailing commas are not essential in some cases and can therefore be viewed as unnecessary. Ruff takes this rule from flake8-commas and made it stable in v0.0.223.
- Code
COM819- Message
Trailing comma prohibited
If you use --strict-equality, mypy will generate an error if it thinks that a comparison operation is always true or false. These are often bugs. mypy does not enable this error code by default. Use --enable-error-code comparison-overlap to enable it.
- Code
comparison-overlap- Severity
- error
In some codebases, it's common to have a license header at the top of every file. This rule ensures that the license header is present. Ruff takes this rule from flake8-copyright and made it stable in 0.16.0.
- Code
CPY001- Message
Missing copyright notice at top of file
Public modules should be documented via docstrings to outline their purpose and contents. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D100- Message
Missing docstring in public module
Public classes should be documented via docstrings to outline their purpose and behavior. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D101- Message
Missing docstring in public class
Public methods should be documented via docstrings to outline their purpose and behavior. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D102- Message
Missing docstring in public method
Public functions should be documented via docstrings to outline their purpose and behavior. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D103- Message
Missing docstring in public function
Public packages should be documented via docstrings to outline their purpose and contents. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D104- Message
Missing docstring in public package
Magic methods (methods with names that start and end with double underscores) are used to implement operator overloading and other special behavior. Such methods should be documented via docstrings to outline their behavior. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D105- Message
Missing docstring in magic method
Public classes should be documented via docstrings to outline their purpose and behavior. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D106- Message
Missing docstring in public nested class
Public __init__ methods are used to initialize objects. __init__ methods should be documented via docstrings to describe the method's behavior, arguments, side effects, exceptions, and any other information that may be relevant to the user. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D107- Message
Missing docstring in `__init__`
PEP 257 recommends that docstrings that _can_ fit on one line should be formatted on a single line, for consistency and readability. Ruff takes this rule from pydocstyle and made it stable in v0.0.68.
- Code
D200- Message
One-line docstring should fit on one line
Remove any blank lines between the function definition and its docstring, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D201- Message
No blank lines allowed before function docstring (found {})
Remove any blank lines between the function body and the function docstring, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D202- Message
No blank lines allowed after function docstring (found {})
Use a blank line to separate the docstring from the class definition, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D203- Message
1 blank line required before class docstring
PEP 257 recommends the use of a blank line to separate a class's docstring from its methods. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D204- Message
1 blank line required after class docstring
PEP 257 recommends that multi-line docstrings consist of "a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description." Ruff takes this rule from pydocstyle and made it stable in v0.0.68.
- Code
D205- Message
1 blank line required between summary line and description- Message
1 blank line required between summary line and description (found {})
PEP 8 recommends using spaces over tabs for indentation. Ruff takes this rule from pydocstyle and made it stable in v0.0.75.
- Code
D206- Message
Docstring should be indented with spaces, not tabs
PEP 257 recommends that docstrings be indented to the same level as their opening quotes. Avoid under-indenting docstrings, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.75.
- Code
D207- Message
Docstring is under-indented
PEP 257 recommends that docstrings be indented to the same level as their opening quotes. Avoid over-indenting docstrings, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.75.
- Code
D208- Message
Docstring is over-indented
PEP 257 recommends that the closing quotes of a multi-line docstring be on their own line, for consistency and compatibility with documentation tools that may need to parse the docstring. Ruff takes this rule from pydocstyle and made it stable in v0.0.68.
- Code
D209- Message
Multi-line docstring closing quotes should be on a separate line
Remove surrounding whitespace from the docstring, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.68.
- Code
D210- Message
No whitespaces allowed surrounding docstring text
Avoid introducing any blank lines between a class definition and its docstring, for consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.
- Code
D211- Message
No blank lines allowed before class docstring
PEP 257 recommends that multi-line docstrings consist of "a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description." Ruff takes this rule from pydocstyle and made it stable in v0.0.69.
- Code
D212- Message
Multi-line docstring summary should start at the first line