AIR001 stable airflow-variable-name-task-id-mismatch
Checks that the task variable name matches the `task_id` value for Airflow Operators.
AIR002 stable airflow-dag-no-schedule-argument
Checks for a `DAG()` class or `@dag()` decorator without an explicit `schedule` (or `schedule_interval` for Airflow 1) parameter.
AIR003 preview airflow-variable-get-outside-task
Checks for `Variable.get()` calls outside of Airflow task execution context (i.e., outside `@task`-decorated functions and operator `execute()` methods).
AIR301 stable airflow3-removal
Checks for uses of deprecated Airflow functions and values.
AIR302 stable airflow3-moved-to-provider
Checks for uses of Airflow functions and values that have been moved to its providers (e.g., `apache-airflow-providers-fab`).
AIR303 preview airflow3-incompatible-function-signature
Checks for Airflow function calls that will raise a runtime error in Airflow 3.0 due to function signature changes, such as functions that changed to accept only keyword arguments, parameter reordering, or parameter type changes.
AIR304 preview airflow3-dag-dynamic-value
Checks for calls to runtime-varying functions (such as `datetime.now()`) used as arguments in Airflow Dag or task constructors.
AIR311 stable airflow3-suggested-update
Checks for uses of deprecated Airflow functions and values that still have a compatibility layer.
AIR312 stable airflow3-suggested-to-move-to-provider
Checks for uses of Airflow functions and values that have been moved to its providers but still have a compatibility layer (e.g., `apache-airflow-providers-standard`).
AIR321 preview airflow31-moved
Checks for uses of deprecated or moved Airflow functions and values in Airflow 3.1.
FAST001 stable fast-api-redundant-response-model
Checks for FastAPI routes that use the optional `response_model` parameter with the same type as the return type.
FAST002 stable fast-api-non-annotated-dependency
Identifies FastAPI routes with deprecated uses of `Depends` or similar.
FAST003 stable fast-api-unused-path-parameter
Identifies FastAPI routes that declare path parameters in the route path that are not included in the function signature.
YTT103 stable sys-version-cmp-str3
Checks for comparisons that test `sys.version` against string literals, such that the comparison will evaluate to `False` on Python 3.10 or later.
YTT201 stable sys-version-info0-eq3
Checks for equality comparisons against the major version returned by `sys.version_info` (e.g., `sys.version_info[0] == 3` or `sys.version_info[0] != 3`).
YTT203 stable sys-version-info1-cmp-int
Checks for comparisons that test `sys.version_info[1]` against an integer.
YTT204 stable sys-version-info-minor-cmp-int
Checks for comparisons that test `sys.version_info.minor` against an integer.
YTT302 stable sys-version-cmp-str10
Checks for comparisons that test `sys.version` against string literals, such that the comparison would fail if the major version number were ever incremented to Python 10 or higher.
ANN001 stable missing-type-function-argument
Checks that function arguments have type annotations.
ANN002 stable missing-type-args
Checks that function `*args` arguments have type annotations.
ANN003 stable missing-type-kwargs
Checks that function `**kwargs` arguments have type annotations.
ANN101 removed missing-type-self
Checks that instance method `self` arguments have type annotations.
ANN102 removed missing-type-cls
Checks that class method `cls` arguments have type annotations.
ANN201 stable missing-return-type-undocumented-public-function
Checks that public functions and methods have return type annotations.
ANN202 stable missing-return-type-private-function
Checks that private functions and methods have return type annotations.
ANN204 stable missing-return-type-special-method
Checks that "special" methods, like `__init__`, `__new__`, and `__call__`, have return type annotations.
ANN205 stable missing-return-type-static-method
Checks that static methods have return type annotations.
ANN206 stable missing-return-type-class-method
Checks that class methods have return type annotations.
ANN401 stable any-type
Checks that function arguments are annotated with a more specific type than `Any`.
ASYNC100 stable cancel-scope-no-checkpoint
Checks for timeout context managers which do not contain a checkpoint. For the purposes of this check, `yield` is considered a checkpoint, since checkpoints may occur in the caller to which we yield.
ASYNC105 stable trio-sync-call
Checks for calls to trio functions that are not immediately awaited.
ASYNC109 stable async-function-with-timeout
Checks for `async` function definitions with `timeout` parameters.
ASYNC110 stable async-busy-wait
Checks for the use of an async sleep function in a `while` loop.
ASYNC115 stable async-zero-sleep
Checks for uses of `trio.sleep(0)` or `anyio.sleep(0)`.
ASYNC116 stable long-sleep-not-forever
Checks for uses of `trio.sleep()` or `anyio.sleep()` with a delay greater than 24 hours.
ASYNC210 stable blocking-http-call-in-async-function
Checks that async functions do not contain blocking HTTP calls.
ASYNC212 stable blocking-http-call-httpx-in-async-function
Checks that async functions do not use blocking httpx clients.
ASYNC220 stable create-subprocess-in-async-function
Checks that async functions do not create subprocesses with blocking methods.
ASYNC221 stable run-process-in-async-function
Checks that async functions do not run processes with blocking methods.
ASYNC222 stable wait-for-process-in-async-function
Checks that async functions do not wait on processes with blocking methods.
ASYNC230 stable blocking-open-call-in-async-function
Checks that async functions do not open files with blocking methods like `open`.
ASYNC240 stable blocking-path-method-in-async-function
Checks that async functions do not call blocking `os.path` or `pathlib.Path` methods.
ASYNC250 stable blocking-input-in-async-function
Checks that async functions do not contain blocking usage of input from user.
ASYNC251 stable blocking-sleep-in-async-function
Checks that async functions do not call `time.sleep`.
S103 stable bad-file-permissions
Checks for files with overly permissive permissions.
S104 stable hardcoded-bind-all-interfaces
Checks for hardcoded bindings to all network interfaces (`0.0.0.0`).
S105 stable hardcoded-password-string
Checks for potential uses of hardcoded passwords in strings.
S106 stable hardcoded-password-func-arg
Checks for potential uses of hardcoded passwords in function calls.
S107 stable hardcoded-password-default
Checks for potential uses of hardcoded passwords in function argument defaults.
S108 stable hardcoded-temp-file
Checks for the use of hardcoded temporary file or directory paths.
S110 stable try-except-pass
Checks for uses of the `try`-`except`-`pass` pattern.
S112 stable try-except-continue
Checks for uses of the `try`-`except`-`continue` pattern.
S113 stable request-without-timeout
Checks for uses of the Python `requests` or `httpx` module that omit the `timeout` parameter.
S301 stable suspicious-pickle-usage
Checks for calls to `pickle` functions or modules that wrap them.
S302 stable suspicious-marshal-usage
Checks for calls to `marshal` functions.
S303 stable suspicious-insecure-hash-usage
Checks for uses of weak or broken cryptographic hash functions.
S304 stable suspicious-insecure-cipher-usage
Checks for uses of weak or broken cryptographic ciphers.
S305 stable suspicious-insecure-cipher-mode-usage
Checks for uses of weak or broken cryptographic cipher modes.
S307 stable suspicious-eval-usage
Checks for uses of the builtin `eval()` function.
S308 stable suspicious-mark-safe-usage
Checks for uses of calls to `django.utils.safestring.mark_safe`.
S310 stable suspicious-url-open-usage
Checks for instances where URL open functions are used with unexpected schemes.
S311 stable suspicious-non-cryptographic-random-usage
Checks for uses of cryptographically weak pseudo-random number generators.
S312 stable suspicious-telnet-usage
Checks for the use of Telnet-related functions.
S313 stable suspicious-xmlc-element-tree-usage
Checks for uses of insecure XML parsers.
S314 stable suspicious-xml-element-tree-usage
Checks for uses of insecure XML parsers.
S315 stable suspicious-xml-expat-reader-usage
Checks for uses of insecure XML parsers.
S316 stable suspicious-xml-expat-builder-usage
Checks for uses of insecure XML parsers.
S317 stable suspicious-xml-sax-usage
Checks for uses of insecure XML parsers.
S318 stable suspicious-xml-mini-dom-usage
Checks for uses of insecure XML parsers.
S319 stable suspicious-xml-pull-dom-usage
Checks for uses of insecure XML parsers.
S320 removed suspicious-xmle-tree-usage
Checks for uses of insecure XML parsers.
S321 stable suspicious-ftp-lib-usage
Checks for the use of FTP-related functions.
S323 stable suspicious-unverified-context-usage
Checks for uses of `ssl._create_unverified_context`.
S324 stable hashlib-insecure-hash-function
Checks for uses of weak or broken cryptographic hash functions in `hashlib` and `crypt` libraries.
S401 preview suspicious-telnetlib-import
Checks for imports of the `telnetlib` module.
S402 preview suspicious-ftplib-import
Checks for imports of the `ftplib` module.
S403 preview suspicious-pickle-import
Checks for imports of the `pickle`, `cPickle`, `dill`, and `shelve` modules.
S404 preview suspicious-subprocess-import
Checks for imports of the `subprocess` module.
S405 preview suspicious-xml-etree-import
Checks for imports of the `xml.etree.cElementTree` and `xml.etree.ElementTree` modules
S406 preview suspicious-xml-sax-import
Checks for imports of the `xml.sax` module.
S407 preview suspicious-xml-expat-import
Checks for imports of the `xml.dom.expatbuilder` module.
S408 preview suspicious-xml-minidom-import
Checks for imports of the `xml.dom.minidom` module.
S409 preview suspicious-xml-pulldom-import
Checks for imports of the `xml.dom.pulldom` module.
S411 preview suspicious-xmlrpc-import
Checks for imports of the `xmlrpc` module.
S412 preview suspicious-httpoxy-import
Checks for imports of `wsgiref.handlers.CGIHandler` and `twisted.web.twcgi.CGIScript`.
S413 preview suspicious-pycrypto-import
Checks for imports of several unsafe cryptography modules.
S415 preview suspicious-pyghmi-import
Checks for imports of the `pyghmi` module.
S501 stable request-with-no-cert-validation
Checks for HTTPS requests that disable SSL certificate checks.
S502 stable ssl-insecure-version
Checks for function calls with parameters that indicate the use of insecure SSL and TLS protocol versions.
S503 stable ssl-with-bad-defaults
Checks for function definitions with default arguments set to insecure SSL and TLS protocol versions.
S504 stable ssl-with-no-version
Checks for calls to `ssl.wrap_socket()` without an `ssl_version`.
S505 stable weak-cryptographic-key
Checks for uses of cryptographic keys with vulnerable key sizes.
S507 stable ssh-no-host-key-verification
Checks for uses of policies disabling SSH verification in Paramiko.
S509 stable snmp-weak-cryptography
Checks for uses of the SNMPv3 protocol without encryption.
S602 stable subprocess-popen-with-shell-equals-true
Check for method calls that initiate a subprocess with a shell.
S603 stable subprocess-without-shell-equals-true
Check for method calls that initiate a subprocess without a shell.
S604 stable call-with-shell-equals-true
Checks for method calls that set the `shell` parameter to `true` or another truthy value when invoking a subprocess.
S605 stable start-process-with-a-shell
Checks for calls that start a process with a shell, providing guidance on whether the usage is safe or not.
S606 stable start-process-with-no-shell
Checks for functions that start a process without a shell.
S607 stable start-process-with-partial-path
Checks for the starting of a process with a partial executable path.
S608 stable hardcoded-sql-expression
Checks for strings that resemble SQL statements involved in some form string building operation.
S609 stable unix-command-wildcard-injection
Checks for possible wildcard injections in calls to `subprocess.Popen()`.
S610 stable django-extra
Checks for uses of Django's `extra` function where one or more arguments passed are not literal expressions.
S612 stable logging-config-insecure-listen
Checks for insecure `logging.config.listen` calls.
S701 stable jinja2-autoescape-false
Checks for `jinja2` templates that use `autoescape=False`.
S704 stable unsafe-markup-use
Checks for non-literal strings being passed to [`markupsafe.Markup`][markupsafe-markup].
BLE001 stable blind-except
Checks for `except` clauses that catch all exceptions. This includes `except BaseException` and `except Exception`.
FBT001 stable boolean-type-hint-positional-argument
Checks for the use of boolean positional arguments in function definitions, as determined by the presence of a type hint containing `bool` as an evident subtype - e.g. `bool`, `bool | int`, `typing.Optional[bool]`, etc.
FBT002 stable boolean-default-value-positional-argument
Checks for the use of boolean positional arguments in function definitions, as determined by the presence of a boolean default value.
FBT003 stable boolean-positional-value-in-call
Checks for boolean positional arguments in function calls. Some functions are whitelisted by default. To extend the list of allowed calls configure the [`lint.flake8-boolean-trap.extend-allowed-calls`] option.
B002 stable unary-prefix-increment-decrement
Checks for the attempted use of the unary prefix increment (`++`) or decrement operator (`--`).
B003 stable assignment-to-os-environ
Checks for assignments to `os.environ`.
B004 stable unreliable-callable-check
Checks for uses of `hasattr` to test if an object is callable (e.g., `hasattr(obj, "__call__")`).
B005 stable strip-with-multi-characters
Checks for uses of multi-character strings in `.strip()`, `.lstrip()`, and `.rstrip()` calls.
B006 stable mutable-argument-default
Checks for uses of mutable objects as function argument defaults.
B007 stable unused-loop-control-variable
Checks for unused variables in loops (e.g., `for` and `while` statements).
B008 stable function-call-in-default-argument
Checks for function calls in default function arguments.
B009 stable get-attr-with-constant
Checks for uses of `getattr` that take a constant attribute value as an argument (e.g., `getattr(obj, "foo")`).
B010 stable set-attr-with-constant
Checks for uses of `setattr` that take a constant attribute value as an argument (e.g., `setattr(obj, "foo", 42)`).
B012 stable jump-statement-in-finally
Checks for `break`, `continue`, and `return` statements in `finally` blocks.
B013 stable redundant-tuple-in-exception-handler
Checks for single-element tuples in exception handlers (e.g., `except (ValueError,):`). Note: Single-element tuples consisting of a starred expression are allowed.
B014 stable duplicate-handler-exception
Checks for exception handlers that catch duplicate exceptions.
B016 stable raise-literal
Checks for `raise` statements that raise a literal value.
B017 stable assert-raises-exception
Checks for `assertRaises` and `pytest.raises` context managers that catch `Exception` or `BaseException`.
B019 stable cached-instance-method
Checks for uses of the `functools.lru_cache` and `functools.cache` decorators on methods.
B020 stable loop-variable-overrides-iterator
Checks for loop control variables that override the loop iterable.
B021 stable f-string-docstring
Checks for docstrings that are written via f-strings.
B022 stable useless-contextlib-suppress
Checks for `contextlib.suppress` without arguments.
B023 stable function-uses-loop-variable
Checks for function definitions that use a loop variable.
B024 stable abstract-base-class-without-abstract-method
Checks for abstract classes without abstract methods or properties. Annotated but unassigned class variables are regarded as abstract.
B025 stable duplicate-try-block-exception
Checks for `try-except` blocks with duplicate exception handlers.
B026 stable star-arg-unpacking-after-keyword-arg
Checks for function calls that use star-argument unpacking after providing a keyword argument
B027 stable empty-method-without-abstract-decorator
Checks for empty methods in abstract base classes without an abstract decorator.
B028 stable no-explicit-stacklevel
Checks for `warnings.warn` calls without an explicit `stacklevel` keyword argument.
B029 stable except-with-empty-tuple
Checks for exception handlers that catch an empty tuple.
B030 stable except-with-non-exception-classes
Checks for exception handlers that catch non-exception classes.
B031 stable reuse-of-groupby-generator
Checks for multiple usage of the generator returned from `itertools.groupby()`.
B032 stable unintentional-type-annotation
Checks for the unintentional use of type annotations.
B033 stable duplicate-value
Checks for set literals that contain duplicate items.
B034 stable re-sub-positional-args
Checks for calls to `re.sub`, `re.subn`, and `re.split` that pass `count`, `maxsplit`, or `flags` as positional arguments.
B035 stable static-key-dict-comprehension
Checks for dictionary comprehensions that use a static key, like a string literal or a variable defined outside the comprehension.
B039 stable mutable-contextvar-default
Checks for uses of mutable objects as `ContextVar` defaults.
B043 preview del-attr-with-constant
Checks for uses of `delattr` that take a constant attribute value as an argument (e.g., `delattr(obj, "foo")`).
B901 preview return-in-generator
Checks for `return {value}` statements in functions that also contain `yield` or `yield from` statements.
B903 preview class-as-data-structure
Checks for classes that only have a public `__init__` method, without base classes and decorators.
B904 stable raise-without-from-inside-except
Checks for `raise` statements in exception handlers that lack a `from` clause.
B905 stable zip-without-explicit-strict
Checks for `zip` calls without an explicit `strict` parameter when called with two or more iterables, or any starred argument.
B909 preview loop-iterator-mutation
Checks for mutations to an iterable during a loop iteration.
B911 stable batched-without-explicit-strict
Checks for `itertools.batched` calls without an explicit `strict` parameter.
B912 stable map-without-explicit-strict
Checks for `map` calls without an explicit `strict` parameter when called with two or more iterables, or any starred argument. This rule applies to Python 3.14 and later, where `map` accepts a `strict` keyword argument. For details, see: [What’s New in Python 3.14].
A001 stable builtin-variable-shadowing
Checks for variable (and function) assignments that use the same names as builtins.
A002 stable builtin-argument-shadowing
Checks for function arguments that use the same names as builtins.
A003 stable builtin-attribute-shadowing
Checks for class attributes and methods that use the same names as Python builtins.
A004 stable builtin-import-shadowing
Checks for imports that use the same names as builtins.
A005 stable stdlib-module-shadowing
Checks for modules that use the same names as Python standard-library modules.
A006 stable builtin-lambda-argument-shadowing
Checks for lambda arguments that use the same names as Python builtins.
COM812 stable missing-trailing-comma
Checks for the absence of trailing commas.
COM818 stable trailing-comma-on-bare-tuple
Checks for the presence of trailing commas on bare (i.e., unparenthesized) tuples.
COM819 stable prohibited-trailing-comma
Checks for the presence of prohibited trailing commas.
C400 stable unnecessary-generator-list
Checks for unnecessary generators that can be rewritten as list comprehensions (or with `list()` directly).
C401 stable unnecessary-generator-set
Checks for unnecessary generators that can be rewritten as set comprehensions (or with `set()` directly).
C402 stable unnecessary-generator-dict
Checks for unnecessary generators that can be rewritten as dict comprehensions.
C403 stable unnecessary-list-comprehension-set
Checks for unnecessary list comprehensions.
C404 stable unnecessary-list-comprehension-dict
Checks for unnecessary list comprehensions.
C405 stable unnecessary-literal-set
Checks for `set()` calls that take unnecessary list or tuple literals as arguments.
C406 stable unnecessary-literal-dict
Checks for unnecessary list or tuple literals.
C408 stable unnecessary-collection-call
Checks for unnecessary `dict()`, `list()` or `tuple()` calls that can be rewritten as empty literals.
C409 stable unnecessary-literal-within-tuple-call
Checks for `tuple` calls that take unnecessary list or tuple literals as arguments. In [preview], this also includes unnecessary list comprehensions within tuple calls.
C410 stable unnecessary-literal-within-list-call
Checks for `list()` calls that take unnecessary list or tuple literals as arguments.
C411 stable unnecessary-list-call
Checks for unnecessary `list()` calls around list comprehensions.
C413 stable unnecessary-call-around-sorted
Checks for unnecessary `list()` or `reversed()` calls around `sorted()` calls.
C414 stable unnecessary-double-cast-or-process
Checks for unnecessary `list()`, `reversed()`, `set()`, `sorted()`, and `tuple()` call within `list()`, `set()`, `sorted()`, and `tuple()` calls.
C415 stable unnecessary-subscript-reversal
Checks for unnecessary subscript reversal of iterable.
C416 stable unnecessary-comprehension
Checks for unnecessary dict, list, and set comprehension.
C417 stable unnecessary-map
Checks for unnecessary `map()` calls with lambda functions.
C418 stable unnecessary-literal-within-dict-call
Checks for `dict()` calls that take unnecessary dict literals or dict comprehensions as arguments.
C419 stable unnecessary-comprehension-in-call
Checks for unnecessary list or set comprehensions passed to builtin functions that take an iterable. Set comprehensions are only a violation in the case where the builtin function does not care about duplication of elements in the passed iterable.
C420 stable unnecessary-dict-comprehension-for-iterable
Checks for unnecessary dict comprehension when creating a dictionary from an iterable.
CPY001 preview missing-copyright-notice
Checks for the absence of copyright notices within Python files. Note that this check only searches within the first 4096 bytes of the file.
DTZ001 stable call-datetime-without-tzinfo
Checks for `datetime` instantiations that do not specify a timezone.
DTZ002 stable call-datetime-today
Checks for usage of `datetime.datetime.today()`.
DTZ003 stable call-datetime-utcnow
Checks for usage of `datetime.datetime.utcnow()`.
DTZ004 stable call-datetime-utcfromtimestamp
Checks for usage of `datetime.datetime.utcfromtimestamp()`.
DTZ005 stable call-datetime-now-without-tzinfo
Checks for usages of `datetime.datetime.now()` that do not specify a timezone.
DTZ006 stable call-datetime-fromtimestamp
Checks for usage of `datetime.datetime.fromtimestamp()` that do not specify a timezone.
DTZ007 stable call-datetime-strptime-without-zone
Checks for uses of `datetime.datetime.strptime()` that lead to naive datetime objects.
DTZ011 stable call-date-today
Checks for usage of `datetime.date.today()`.
DTZ012 stable call-date-fromtimestamp
Checks for usage of `datetime.date.fromtimestamp()`.
DTZ901 stable datetime-min-max
Checks for uses of `datetime.datetime.min` and `datetime.datetime.max`.
T100 stable debugger
Checks for the presence of debugger calls and imports.
DJ001 stable django-nullable-model-string-field
Checks nullable string-based fields (like `CharField` and `TextField`) in Django models.
DJ003 stable django-locals-in-render-function
Checks for the use of `locals()` in `render` functions.
DJ006 stable django-exclude-with-model-form
Checks for the use of `exclude` in Django `ModelForm` classes.
DJ007 stable django-all-with-model-form
Checks for the use of `fields = "__all__"` in Django `ModelForm` classes.
DJ008 stable django-model-without-dunder-str
Checks that a `__str__` method is defined in Django models.
DJ012 stable django-unordered-body-content-in-model
Checks for the order of Model's inner classes, methods, and fields as per the [Django Style Guide].
DJ013 stable django-non-leading-receiver-decorator
Checks that Django's `@receiver` decorator is listed first, prior to any other decorators.
EM101 stable raw-string-in-exception
Checks for the use of string literals in exception constructors.
EM102 stable f-string-in-exception
Checks for the use of f-strings in exception constructors.
EM103 stable dot-format-in-exception
Checks for the use of `.format` calls on string literals in exception constructors.
EXE001 stable shebang-not-executable
Checks for a shebang directive in a file that is not executable.
EXE002 stable shebang-missing-executable-file
Checks for executable `.py` files that do not have a shebang.
EXE003 stable shebang-missing-python
Checks for a shebang directive in `.py` files that does not contain `python`, `pytest`, or `uv run`.
EXE004 stable shebang-leading-whitespace
Checks for whitespace before a shebang directive.
EXE005 stable shebang-not-first-line
Checks for a shebang directive that is not at the beginning of the file.
FA100 stable future-rewritable-type-annotation
Checks for missing `from __future__ import annotations` imports upon detecting type annotations that can be written more succinctly under PEP 563.
FA102 stable future-required-type-annotation
Checks for uses of PEP 585- and PEP 604-style type annotations in Python modules that lack the required `from __future__ import annotations` import for compatibility with older Python versions.
INT001 stable f-string-in-get-text-func-call
Checks for f-strings in `gettext` function calls.
INT002 stable format-in-get-text-func-call
Checks for `str.format` calls in `gettext` function calls.
INT003 stable printf-in-get-text-func-call
Checks for printf-style formatted strings in `gettext` function calls.
ISC001 stable single-line-implicit-string-concatenation
Checks for implicitly concatenated strings on a single line.
ISC002 stable multi-line-implicit-string-concatenation
Checks for implicitly concatenated strings that span multiple lines.
ISC003 stable explicit-string-concatenation
Checks for string literals that are explicitly concatenated (using the `+` operator).
ISC004 preview implicit-string-concatenation-in-collection-literal
Checks for implicitly concatenated strings inside list, tuple, and set literals.
ICN001 stable unconventional-import-alias
Checks for imports that are typically imported using a common convention, like `import pandas as pd`, and enforces that convention.
ICN002 stable banned-import-alias
Checks for imports that use non-standard naming conventions, like `import tensorflow.keras.backend as K`.
ICN003 stable banned-import-from
Checks for member imports that should instead be accessed by importing the module.
LOG001 stable direct-logger-instantiation
Checks for direct instantiation of `logging.Logger`, as opposed to using `logging.getLogger()`.
LOG002 stable invalid-get-logger-argument
Checks for any usage of `__cached__` and `__file__` as an argument to `logging.getLogger()`.
LOG004 preview log-exception-outside-except-handler
Checks for `.exception()` logging calls outside of exception handlers.
LOG007 stable exception-without-exc-info
Checks for uses of `logging.exception()` with `exc_info` set to `False`.
LOG014 stable exc-info-outside-except-handler
Checks for logging calls with `exc_info=` outside exception handlers.
LOG015 stable root-logger-call
Checks for usages of the following `logging` top-level functions: `debug`, `info`, `warn`, `warning`, `error`, `critical`, `log`, `exception`.
G001 stable logging-string-format
Checks for uses of `str.format` to format logging messages.
G002 stable logging-percent-format
Checks for uses of `printf`-style format strings to format logging messages.
G003 stable logging-string-concat
Checks for uses string concatenation via the `+` operator to format logging messages.
G004 stable logging-f-string
Checks for uses of f-strings to format logging messages.
G010 stable logging-warn
Checks for uses of `logging.warn` and `logging.Logger.warn`.
G101 stable logging-extra-attr-clash
Checks for `extra` keywords in logging statements that clash with `LogRecord` attributes.
G201 stable logging-exc-info
Checks for uses of `logging.error` that pass `exc_info=True`.
G202 stable logging-redundant-exc-info
Checks for redundant `exc_info` keyword arguments in logging statements.
INP001 stable implicit-namespace-package
Checks for packages that are missing an `__init__.py` file.
PIE790 stable unnecessary-placeholder
Checks for unnecessary `pass` statements and ellipsis (`...`) literals in functions, classes, and other blocks.
PIE794 stable duplicate-class-field-definition
Checks for duplicate field definitions in classes.
PIE800 stable unnecessary-spread
Checks for unnecessary dictionary unpacking operators (`**`).
PIE807 stable reimplemented-container-builtin
Checks for lambdas that can be replaced with the `list` or `dict` builtins.
PIE808 stable unnecessary-range-start
Checks for `range` calls with an unnecessary `start` argument.
PIE810 stable multiple-starts-ends-with
Checks for `startswith` or `endswith` calls on the same value with different prefixes or suffixes.
PYI001 stable unprefixed-type-param
Checks that type `TypeVar`s, `ParamSpec`s, and `TypeVarTuple`s in stubs have names prefixed with `_`.
PYI002 stable complex-if-statement-in-stub
Checks for `if` statements with complex conditionals in stubs.
PYI003 stable unrecognized-version-info-check
Checks for problematic `sys.version_info`-related conditions in stubs.
PYI004 stable patch-version-comparison
Checks for Python version comparisons in stubs that compare against patch versions (e.g., Python 3.8.3) instead of major and minor versions (e.g., Python 3.8).
PYI005 stable wrong-tuple-length-version-comparison
Checks for Python version comparisons that compare against a tuple of the wrong length.
PYI006 stable bad-version-info-comparison
Checks for uses of comparators other than `<` and `>=` for `sys.version_info` checks. All other comparators, such as `>`, `<=`, and `==`, are banned.
PYI007 stable unrecognized-platform-check
Check for unrecognized `sys.platform` checks. Platform checks should be simple string comparisons. **Note**: this rule is only enabled in `.pyi` stub files.
PYI008 stable unrecognized-platform-name
Check for unrecognized platform names in `sys.platform` checks. **Note**: this rule is only enabled in `.pyi` stub files.
PYI009 stable pass-statement-stub-body
Checks for `pass` statements in empty stub bodies.
PYI011 stable typed-argument-default-in-stub
Checks for typed function arguments in stubs with complex default values.
PYI012 stable pass-in-class-body
Checks for the presence of the `pass` statement in non-empty class bodies in `.pyi` files.
PYI013 stable ellipsis-in-non-empty-class-body
Removes ellipses (`...`) in otherwise non-empty class bodies.
PYI014 stable argument-default-in-stub
Checks for untyped function arguments in stubs with default values that are not "simple" /// (i.e., `int`, `float`, `complex`, `bytes`, `str`, `bool`, `None`, `...`, or simple container literals).
PYI015 stable assignment-default-in-stub
Checks for assignments in stubs with default values that are not "simple" (i.e., `int`, `float`, `complex`, `bytes`, `str`, `bool`, `None`, `...`, or simple container literals).
PYI017 stable complex-assignment-in-stub
Checks for assignments with multiple or non-name targets in stub files.
PYI018 stable unused-private-type-var
Checks for the presence of unused private `TypeVar`, `ParamSpec` or `TypeVarTuple` declarations.
PYI019 stable custom-type-var-for-self
Checks for methods that use custom [`TypeVar`s][typing_TypeVar] in their annotations when they could use [`Self`][Self] instead.
PYI020 stable quoted-annotation-in-stub
Checks for quoted type annotations in stub (`.pyi`) files, which should be avoided.
PYI021 stable docstring-in-stub
Checks for the presence of docstrings in stub files.
PYI024 stable collections-named-tuple
Checks for uses of `collections.namedtuple` in stub files.
PYI025 stable unaliased-collections-abc-set-import
Checks for `from collections.abc import Set` imports that do not alias `Set` to `AbstractSet`.
PYI026 stable type-alias-without-annotation
Checks for type alias definitions that are not annotated with `typing.TypeAlias`.
PYI029 stable str-or-repr-defined-in-stub
Checks for redundant definitions of `__str__` or `__repr__` in stubs.
PYI030 stable unnecessary-literal-union
Checks for the presence of multiple literal types in a union.
PYI032 stable any-eq-ne-annotation
Checks for `__eq__` and `__ne__` implementations that use `typing.Any` as the type annotation for their second parameter.
PYI033 stable type-comment-in-stub
Checks for the use of type comments (e.g., `x = 1 # type: int`) in stub files.
PYI034 stable non-self-return-type
Checks for methods that are annotated with a fixed return type which should instead be returning `Self`.
PYI035 stable unassigned-special-variable-in-stub
Checks that `__all__`, `__match_args__`, and `__slots__` variables are assigned to values when defined in stub files.
PYI036 stable bad-exit-annotation
Checks for incorrect function signatures on `__exit__` and `__aexit__` methods.
PYI041 stable redundant-numeric-union
Checks for parameter annotations that contain redundant unions between builtin numeric types (e.g., `int | float`).
PYI042 stable snake-case-type-alias
Checks for type aliases that do not use the CamelCase naming convention.
PYI043 stable t-suffixed-type-alias
Checks for private type alias definitions suffixed with 'T'.
PYI044 stable future-annotations-in-stub
Checks for the presence of the `from __future__ import annotations` import statement in stub files.
PYI045 stable iter-method-return-iterable
Checks for `__iter__` methods in stubs that return `Iterable[T]` instead of an `Iterator[T]`.
PYI046 stable unused-private-protocol
Checks for the presence of unused private `typing.Protocol` definitions.
PYI047 stable unused-private-type-alias
Checks for the presence of unused private type aliases.
PYI048 stable stub-body-multiple-statements
Checks for functions in stub (`.pyi`) files that contain multiple statements.
PYI049 stable unused-private-typed-dict
Checks for the presence of unused private `typing.TypedDict` definitions.
PYI050 stable no-return-argument-annotation-in-stub
Checks for uses of `typing.NoReturn` (and `typing_extensions.NoReturn`) for parameter annotations.
PYI051 stable redundant-literal-union
Checks for redundant unions between a `Literal` and a builtin supertype of that `Literal`.
PYI052 stable unannotated-assignment-in-stub
Checks for unannotated assignments in stub (`.pyi`) files.
PYI053 stable string-or-bytes-too-long
Checks for the use of string and bytes literals longer than 50 characters in stub (`.pyi`) files.
PYI054 stable numeric-literal-too-long
Checks for numeric literals with a string representation longer than ten characters.
PYI055 stable unnecessary-type-union
Checks for the presence of multiple `type`s in a union.
PYI056 stable unsupported-method-call-on-all
Checks that `append`, `extend` and `remove` methods are not called on `__all__`.
PYI057 stable byte-string-usage
Checks for uses of `typing.ByteString` or `collections.abc.ByteString`.
PYI058 stable generator-return-from-iter-method
Checks for simple `__iter__` methods that return `Generator`, and for simple `__aiter__` methods that return `AsyncGenerator`.
PYI059 stable generic-not-last-base-class
Checks for classes inheriting from `typing.Generic[]` where `Generic[]` is not the last base class in the bases tuple.
PYI061 stable redundant-none-literal
Checks for redundant `Literal[None]` annotations.
PYI062 stable duplicate-literal-member
Checks for duplicate members in a `typing.Literal[]` slice.
PYI063 stable pep484-style-positional-only-parameter
Checks for the presence of [PEP 484]-style positional-only parameters.
PYI064 stable redundant-final-literal
Checks for redundant `Final[Literal[...]]` annotations.
PYI066 stable bad-version-info-order
Checks for code that branches on `sys.version_info` comparisons where branches corresponding to older Python versions come before branches corresponding to newer Python versions.
PT001 stable pytest-fixture-incorrect-parentheses-style
Checks for argument-free `@pytest.fixture()` decorators with or without parentheses, depending on the [`lint.flake8-pytest-style.fixture-parentheses`] setting.
PT002 stable pytest-fixture-positional-args
Checks for `pytest.fixture` calls with positional arguments.
PT003 stable pytest-extraneous-scope-function
Checks for `pytest.fixture` calls with `scope="function"`.
PT004 stable pytest-missing-fixture-name-underscore
Checks for `pytest` fixtures that do not return a value, but are not named with a leading underscore.
PT005 stable pytest-incorrect-fixture-name-underscore
Checks for `pytest` fixtures that return a value, but are named with a leading underscore.
PT006 stable pytest-parametrize-names-wrong-type
Checks for the type of parameter names passed to `pytest.mark.parametrize`.
PT007 stable pytest-parametrize-values-wrong-type
Checks for the type of parameter values passed to `pytest.mark.parametrize`.
PT008 stable pytest-patch-with-lambda
Checks for mocked calls that use a dummy `lambda` function instead of `return_value`.
PT009 stable pytest-unittest-assertion
Checks for uses of assertion methods from the `unittest` module.
PT010 stable pytest-raises-without-exception
Checks for `pytest.raises` calls without an expected exception.
PT011 stable pytest-raises-too-broad
Checks for `pytest.raises` calls without a `match` or `check` parameter.
PT012 stable pytest-raises-with-multiple-statements
Checks for `pytest.raises` context managers with multiple statements. This rule allows `pytest.raises` bodies to contain `for` loops with empty bodies (e.g., `pass` or `...` statements), to test iterator behavior.
PT013 stable pytest-incorrect-pytest-import
Checks for incorrect import of pytest.
PT014 stable pytest-duplicate-parametrize-test-cases
Checks for duplicate test cases in `pytest.mark.parametrize`.
PT015 stable pytest-assert-always-false
Checks for `assert` statements whose test expression is a falsy value.
PT016 stable pytest-fail-without-message
Checks for `pytest.fail` calls without a message.
PT017 stable pytest-assert-in-except
Checks for `assert` statements in `except` clauses.
PT018 stable pytest-composite-assertion
Checks for assertions that combine multiple independent conditions.
PT019 stable pytest-fixture-param-without-value
Checks for `pytest` test functions that should be decorated with `@pytest.mark.usefixtures`.
PT020 stable pytest-deprecated-yield-fixture
Checks for `pytest.yield_fixture` usage.
PT021 stable pytest-fixture-finalizer-callback
Checks for unnecessary `request.addfinalizer` usages in `pytest` fixtures.
PT022 stable pytest-useless-yield-fixture
Checks for unnecessary `yield` expressions in `pytest` fixtures.
PT023 stable pytest-incorrect-mark-parentheses-style
Checks for argument-free `@pytest.mark.<marker>()` decorators with or without parentheses, depending on the [`lint.flake8-pytest-style.mark-parentheses`] setting. The rule defaults to removing unnecessary parentheses, to match the documentation of the official pytest projects.
PT024 stable pytest-unnecessary-asyncio-mark-on-fixture
Checks for unnecessary `@pytest.mark.asyncio` decorators applied to fixtures.
PT025 stable pytest-erroneous-use-fixtures-on-fixture
Checks for `pytest.mark.usefixtures` decorators applied to `pytest` fixtures.
PT026 stable pytest-use-fixtures-without-parameters
Checks for `@pytest.mark.usefixtures()` decorators that aren't passed any arguments.
PT027 stable pytest-unittest-raises-assertion
Checks for uses of exception-related assertion methods from the `unittest` module.
PT028 stable pytest-parameter-with-default-argument
Checks for parameters of test functions with default arguments.
PT029 preview pytest-warns-without-warning
Checks for `pytest.warns` calls without an expected warning.
PT030 stable pytest-warns-too-broad
Checks for `pytest.warns` calls without a `match` parameter.
PT031 stable pytest-warns-with-multiple-statements
Checks for `pytest.warns` context managers with multiple statements. This rule allows `pytest.warns` bodies to contain `for` loops with empty bodies (e.g., `pass` or `...` statements), to test iterator behavior.
Q000 stable bad-quotes-inline-string
Checks for inline strings that use single quotes or double quotes, depending on the value of the [`lint.flake8-quotes.inline-quotes`] option.
Q001 stable bad-quotes-multiline-string
Checks for multiline strings that use single quotes or double quotes, depending on the value of the [`lint.flake8-quotes.multiline-quotes`] setting.
Q002 stable bad-quotes-docstring
Checks for docstrings that use single quotes or double quotes, depending on the value of the [`lint.flake8-quotes.docstring-quotes`] setting.
Q003 stable avoidable-escaped-quote
Checks for strings that include escaped quotes, and suggests changing the quote style to avoid the need to escape them.
Q004 stable unnecessary-escaped-quote
Checks for strings that include unnecessarily escaped quotes.
RSE102 stable unnecessary-paren-on-raise-exception
Checks for unnecessary parentheses on raised exceptions.
RET501 stable unnecessary-return-none
Checks for the presence of a `return None` statement when `None` is the only possible return value.
RET502 stable implicit-return-value
Checks for the presence of a `return` statement with no explicit value, for functions that return non-`None` values elsewhere.
RET503 stable implicit-return
Checks for missing explicit `return` statements at the end of functions that can return non-`None` values.
RET504 stable unnecessary-assign
Checks for variable assignments that immediately precede a `return` of the assigned variable.
RET505 stable superfluous-else-return
Checks for `else` statements with a `return` statement in the preceding `if` block.
RET506 stable superfluous-else-raise
Checks for `else` statements with a `raise` statement in the preceding `if` block.
RET507 stable superfluous-else-continue
Checks for `else` statements with a `continue` statement in the preceding `if` block.
RET508 stable superfluous-else-break
Checks for `else` statements with a `break` statement in the preceding `if` block.
SLF001 stable private-member-access
Checks for accesses on "private" class members.
SIM101 stable duplicate-isinstance-call
Checks for multiple `isinstance` calls on the same target.
SIM102 stable collapsible-if
Checks for nested `if` statements that can be collapsed into a single `if` statement.
SIM103 stable needless-bool
Checks for `if` statements that can be replaced with `bool`.
SIM105 stable suppressible-exception
Checks for `try`-`except`-`pass` blocks that can be replaced with the `contextlib.suppress` context manager.
SIM107 stable return-in-try-except-finally
Checks for `return` statements in `try`-`except` and `finally` blocks.
SIM108 stable if-else-block-instead-of-if-exp
Check for `if`-`else`-blocks that can be replaced with a ternary or binary operator. The lint is suppressed if the suggested replacement would exceed the maximum line length configured in [pycodestyle.max-line-length].
SIM109 stable compare-with-tuple
Checks for boolean expressions that contain multiple equality comparisons to the same value.
SIM110 stable reimplemented-builtin
Checks for `for` loops that can be replaced with a builtin function, like `any` or `all`.
SIM112 stable uncapitalized-environment-variables
Check for environment variables that are not capitalized.
SIM113 stable enumerate-for-loop
Checks for `for` loops with explicit loop-index variables that can be replaced with `enumerate()`. In [preview], this rule checks for index variables initialized with any integer rather than only a literal zero.
SIM114 stable if-with-same-arms
Checks for `if` branches with identical arm bodies.
SIM115 stable open-file-with-context-handler
Checks for cases where files are opened (e.g., using the builtin `open()` function) without using a context manager.
SIM116 stable if-else-block-instead-of-dict-lookup
Checks for three or more consecutive if-statements with direct returns
SIM117 stable multiple-with-statements
Checks for the unnecessary nesting of multiple consecutive context managers.
SIM118 stable in-dict-keys
Checks for key-existence checks against `dict.keys()` calls.
SIM208 stable double-negation
Checks for double negations (i.e., multiple `not` operators).
SIM210 stable if-expr-with-true-false
Checks for `if` expressions that can be replaced with `bool()` calls.
SIM211 stable if-expr-with-false-true
Checks for `if` expressions that can be replaced by negating a given condition.
SIM212 stable if-expr-with-twisted-arms
Checks for `if` expressions that check against a negated condition.
SIM220 stable expr-and-not-expr
Checks for `and` expressions that include both an expression and its negation.
SIM221 stable expr-or-not-expr
Checks for `or` expressions that include both an expression and its negation.
SIM222 stable expr-or-true
Checks for `or` expressions that contain truthy values.
SIM223 stable expr-and-false
Checks for `and` expressions that contain falsey values.
SIM300 stable yoda-conditions
Checks for conditions that position a constant on the left-hand side of the comparison operator, rather than the right-hand side.
SIM401 stable if-else-block-instead-of-dict-get
Checks for `if` statements that can be replaced with `dict.get` calls.
SIM905 stable split-static-string
Checks for static `str.split` calls that can be replaced with list literals.
SIM910 stable dict-get-with-none-default
Checks for `dict.get()` calls that pass `None` as the default value.
SIM911 stable zip-dict-keys-and-values
Checks for use of `zip()` to iterate over keys and values of a dictionary at once.
SLOT000 stable no-slots-in-str-subclass
Checks for subclasses of `str` that lack a `__slots__` definition.
SLOT001 stable no-slots-in-tuple-subclass
Checks for subclasses of `tuple` that lack a `__slots__` definition.
SLOT002 stable no-slots-in-namedtuple-subclass
Checks for subclasses of `collections.namedtuple` or `typing.NamedTuple` that lack a `__slots__` definition.
TID253 stable banned-module-level-imports
Checks for module-level imports that should instead be imported lazily (e.g., within a function definition, or an `if TYPE_CHECKING:` block, or some other nested context).
TID254 preview lazy-import-mismatch
Enforces the configured lazy-import policy in contexts where `lazy import` is legal.
TD001 stable invalid-todo-tag
Checks that a TODO comment is labelled with "TODO".
TD002 stable missing-todo-author
Checks that a TODO comment includes an author.
TD003 stable missing-todo-link
Checks that a TODO comment is associated with a link to a relevant issue or ticket.
TD004 stable missing-todo-colon
Checks that a "TODO" tag is followed by a colon.
TD005 stable missing-todo-description
Checks that a "TODO" tag contains a description of the issue following the tag itself.
TD006 stable invalid-todo-capitalization
Checks that a "TODO" tag is properly capitalized (i.e., that the tag is uppercase).
TD007 stable missing-space-after-todo-colon
Checks that the colon after a "TODO" tag is followed by a space.
TC001 stable typing-only-first-party-import
Checks for first-party imports that are only used for type annotations, but aren't defined in a type-checking block.
TC002 stable typing-only-third-party-import
Checks for third-party imports that are only used for type annotations, but aren't defined in a type-checking block.
TC003 stable typing-only-standard-library-import
Checks for standard library imports that are only used for type annotations, but aren't defined in a type-checking block.
TC004 stable runtime-import-in-type-checking-block
Checks for imports that are required at runtime but are only defined in type-checking blocks.
TC005 stable empty-type-checking-block
Checks for an empty type-checking block.
TC006 stable runtime-cast-value
Checks for unquoted type expressions in `typing.cast()` calls.
TC007 stable unquoted-type-alias
Checks if [PEP 613] explicit type aliases contain references to symbols that are not available at runtime.
TC008 preview quoted-type-alias
Checks for unnecessary quotes in [PEP 613] explicit type aliases and [PEP 695] type statements.
TC010 stable runtime-string-union
Checks for the presence of string literals in `X | Y`-style union types.
ARG001 stable unused-function-argument
Checks for the presence of unused arguments in function definitions.
ARG002 stable unused-method-argument
Checks for the presence of unused arguments in instance method definitions.
ARG003 stable unused-class-method-argument
Checks for the presence of unused arguments in class method definitions.
ARG004 stable unused-static-method-argument
Checks for the presence of unused arguments in static method definitions.
ARG005 stable unused-lambda-argument
Checks for the presence of unused arguments in lambda expression definitions.
PTH109 stable os-getcwd
Checks for uses of `os.getcwd` and `os.getcwdb`.
PTH111 stable os-path-expanduser
Checks for uses of `os.path.expanduser`.
PTH201 stable path-constructor-current-directory
Checks for `pathlib.Path` objects that are initialized with the current directory.
PTH207 stable glob
Checks for the use of `glob.glob()` and `glob.iglob()`.
PTH210 stable invalid-pathlib-with-suffix
Checks for `pathlib.Path.with_suffix()` calls where the given suffix does not have a leading dot or the given suffix is a single dot `"."` and the Python version is less than 3.14.
FLY002 stable static-join-to-f-string
Checks for `str.join` calls that can be replaced with f-strings.
I001 stable unsorted-imports
De-duplicates, groups, and sorts imports based on the provided `isort` settings.
I002 stable missing-required-import
Adds any required imports, as specified by the user, to the top of the file.
NPY001 stable numpy-deprecated-type-alias
Checks for deprecated NumPy type aliases.
NPY002 stable numpy-legacy-random
Checks for the use of legacy `np.random` function calls.
NPY003 stable numpy-deprecated-function
Checks for uses of deprecated NumPy functions.
NPY201 stable numpy2-deprecation
Checks for uses of NumPy functions and constants that were removed from the main namespace in NumPy 2.0.
N801 stable invalid-class-name
Checks for class names that do not follow the `CamelCase` convention.
N802 stable invalid-function-name
Checks for functions names that do not follow the `snake_case` naming convention.
N803 stable invalid-argument-name
Checks for argument names that do not follow the `snake_case` convention.
N804 stable invalid-first-argument-name-for-class-method
Checks for class methods that use a name other than `cls` for their first argument. The method `__new__` is exempted from this check and the corresponding violation is caught by [`bad-staticmethod-argument`][PLW0211].
N805 stable invalid-first-argument-name-for-method
Checks for instance methods that use a name other than `self` for their first argument.
N806 stable non-lowercase-variable-in-function
Checks for the use of non-lowercase variable names in functions.
N807 stable dunder-function-name
Checks for functions with "dunder" names (that is, names with two leading and trailing underscores) that are not documented.
N811 stable constant-imported-as-non-constant
Checks for constant imports that are aliased to non-constant-style names.
N812 stable lowercase-imported-as-non-lowercase
Checks for lowercase imports that are aliased to non-lowercase names.
N813 stable camelcase-imported-as-lowercase
Checks for `CamelCase` imports that are aliased to lowercase names.
N814 stable camelcase-imported-as-constant
Checks for `CamelCase` imports that are aliased to constant-style names.
N815 stable mixed-case-variable-in-class-scope
Checks for class variable names that follow the `mixedCase` convention.
N816 stable mixed-case-variable-in-global-scope
Checks for global variable names that follow the `mixedCase` convention.
N817 stable camelcase-imported-as-acronym
Checks for `CamelCase` imports that are aliased as acronyms.
N818 stable error-suffix-on-exception-name
Checks for custom exception definitions that omit the `Error` suffix.
N999 stable invalid-module-name
Checks for module names that do not follow the `snake_case` naming convention or are otherwise invalid.
PD002 stable pandas-use-of-inplace-argument
Checks for `inplace=True` usages in `pandas` function and method calls.
PD003 stable pandas-use-of-dot-is-null
Checks for uses of `.isnull` on Pandas objects.
PD004 stable pandas-use-of-dot-not-null
Checks for uses of `.notnull` on Pandas objects.
PD010 stable pandas-use-of-dot-pivot-or-unstack
Checks for uses of `.pivot` or `.unstack` on Pandas objects.
PD011 stable pandas-use-of-dot-values
Checks for uses of `.values` on Pandas Series and Index objects.
PD012 stable pandas-use-of-dot-read-table
Checks for uses of `pd.read_table` to read CSV files.
PD013 stable pandas-use-of-dot-stack
Checks for uses of `.stack` on Pandas objects.
PD015 stable pandas-use-of-pd-merge
Checks for uses of `pd.merge` on Pandas objects.
PD101 stable pandas-nunique-constant-series-check
Check for uses of `.nunique()` to check if a Pandas Series is constant (i.e., contains only one unique value).
PD901 removed pandas-df-variable-name
Checks for assignments to the variable `df`.
PERF101 stable unnecessary-list-cast
Checks for explicit casts to `list` on for-loop iterables.
PERF102 stable incorrect-dict-iterator
Checks for uses of `dict.items()` that discard either the key or the value when iterating over the dictionary.
PERF203 stable try-except-in-loop
Checks for uses of except handling via `try`-`except` within `for` and `while` loops.
PERF401 stable manual-list-comprehension
Checks for `for` loops that can be replaced by a list comprehension.
PERF402 stable manual-list-copy
Checks for `for` loops that can be replaced by a making a copy of a list.
PERF403 stable manual-dict-comprehension
Checks for `for` loops that can be replaced by a dictionary comprehension.
E101 stable mixed-spaces-and-tabs
Checks for mixed tabs and spaces in indentation.
E111 preview indentation-with-invalid-multiple
Checks for indentation with a non-multiple of 4 spaces.
E112 preview no-indented-block
Checks for indented blocks that are lacking indentation.
E114 preview indentation-with-invalid-multiple-comment
Checks for indentation of comments with a non-multiple of 4 spaces.
E115 preview no-indented-block-comment
Checks for comments in a code blocks that are lacking indentation.
E116 preview unexpected-indentation-comment
Checks for unexpected indentation of comment.
E201 preview whitespace-after-open-bracket
Checks for the use of extraneous whitespace after "(", "[" or "{".
E202 preview whitespace-before-close-bracket
Checks for the use of extraneous whitespace before ")", "]" or "}".
E203 preview whitespace-before-punctuation
Checks for the use of extraneous whitespace before ",", ";" or ":".
E204 preview whitespace-after-decorator
Checks for trailing whitespace after a decorator's opening `@`.
E211 preview whitespace-before-parameters
Checks for extraneous whitespace immediately preceding an open parenthesis or bracket.
E221 preview multiple-spaces-before-operator
Checks for extraneous whitespace before an operator.
E222 preview multiple-spaces-after-operator
Checks for extraneous whitespace after an operator.
E223 preview tab-before-operator
Checks for extraneous tabs before an operator.
E225 preview missing-whitespace-around-operator
Checks for missing whitespace around all operators.
E226 preview missing-whitespace-around-arithmetic-operator
Checks for missing whitespace arithmetic operators.
E227 preview missing-whitespace-around-bitwise-or-shift-operator
Checks for missing whitespace around bitwise and shift operators.
E228 preview missing-whitespace-around-modulo-operator
Checks for missing whitespace around the modulo operator.
E231 preview missing-whitespace
Checks for missing whitespace after `,`, `;`, and `:`.
E241 preview multiple-spaces-after-comma
Checks for extraneous whitespace after a comma.
E251 preview unexpected-spaces-around-keyword-parameter-equals
Checks for missing whitespace around the equals sign in an unannotated function keyword parameter.
E252 preview missing-whitespace-around-parameter-equals
Checks for missing whitespace around the equals sign in an annotated function keyword parameter.
E261 preview too-few-spaces-before-inline-comment
Checks if inline comments are separated by at least two spaces.
E262 preview no-space-after-inline-comment
Checks if one space is used after inline comments.
E265 preview no-space-after-block-comment
Checks for block comments that lack a single space after the leading `#` character.
E266 preview multiple-leading-hashes-for-block-comment
Checks for block comments that start with multiple leading `#` characters.
E271 preview multiple-spaces-after-keyword
Checks for extraneous whitespace after keywords.
E272 preview multiple-spaces-before-keyword
Checks for extraneous whitespace before keywords.
E275 preview missing-whitespace-after-keyword
Checks for missing whitespace after keywords.
E301 preview blank-line-between-methods
Checks for missing blank lines between methods of a class.
E302 preview blank-lines-top-level
Checks for missing blank lines between top level functions and classes.
E304 preview blank-line-after-decorator
Checks for extraneous blank line(s) after function decorators.
E305 preview blank-lines-after-function-or-class
Checks for missing blank lines after the end of function or class.
E306 preview blank-lines-before-nested-definition
Checks for 1 blank line between nested function or class definitions.
E401 stable multiple-imports-on-one-line
Check for multiple imports on one line.
E402 stable module-import-not-at-top-of-file
Checks for imports that are not at the top of the file.
E501 stable line-too-long
Checks for lines that exceed the specified maximum character length.
E502 preview redundant-backslash
Checks for redundant backslashes between brackets.
E701 stable multiple-statements-on-one-line-colon
Checks for compound statements (multiple statements on the same line).
E702 stable multiple-statements-on-one-line-semicolon
Checks for multiline statements on one line.
E703 stable useless-semicolon
Checks for statements that end with an unnecessary semicolon.
E711 stable none-comparison
Checks for comparisons to `None` which are not using the `is` operator.
E712 stable true-false-comparison
Checks for equality comparisons to boolean literals.
E713 stable not-in-test
Checks for membership tests using `not {element} in {collection}`.
E714 stable not-is-test
Checks for identity comparisons using `not {foo} is {bar}`.
E721 stable type-comparison
Checks for object type comparisons using `==` and other comparison operators.
E722 stable bare-except
Checks for bare `except` catches in `try`-`except` statements.
E731 stable lambda-assignment
Checks for lambda expressions which are assigned to a variable.
E741 stable ambiguous-variable-name
Checks for the use of the characters 'l', 'O', or 'I' as variable names. Note: This rule is automatically disabled for all stub files (files with `.pyi` extensions). The rule has little relevance for authors of stubs: a well-written stub should aim to faithfully represent the interface of the equivalent .py file as it exists at runtime, including any ambiguously named variables in the runtime module.
E742 stable ambiguous-class-name
Checks for the use of the characters 'l', 'O', or 'I' as class names.
E743 stable ambiguous-function-name
Checks for the use of the characters 'l', 'O', or 'I' as function names.
E902 stable io-error
This is not a regular diagnostic; instead, it's raised when a file cannot be read from disk.
W292 stable missing-newline-at-end-of-file
Checks for files missing a new line at the end of the file.
W293 stable blank-line-with-whitespace
Checks for superfluous whitespace in blank lines.
W391 preview too-many-newlines-at-end-of-file
Checks for files with multiple trailing blank lines. In the case of notebooks, this check is applied to each cell separately.
W505 stable doc-line-too-long
Checks for doc lines that exceed the specified maximum character length.
DOC102 preview docstring-extraneous-parameter
Checks for function docstrings that include parameters which are not in the function signature.
DOC201 preview docstring-missing-returns
Checks for functions with `return` statements that do not have "Returns" sections in their docstrings.
DOC202 preview docstring-extraneous-returns
Checks for function docstrings with unnecessary "Returns" sections.
DOC402 preview docstring-missing-yields
Checks for functions with `yield` statements that do not have "Yields" sections in their docstrings.
DOC403 preview docstring-extraneous-yields
Checks for function docstrings with unnecessary "Yields" sections.
DOC501 preview docstring-missing-exception
Checks for function docstrings that do not document all explicitly raised exceptions.
DOC502 preview docstring-extraneous-exception
Checks for function docstrings that state that exceptions could be raised even though they are not directly raised in the function body.
D100 stable undocumented-public-module
Checks for undocumented public module definitions.
D101 stable undocumented-public-class
Checks for undocumented public class definitions.
D102 stable undocumented-public-method
Checks for undocumented public method definitions.
D103 stable undocumented-public-function
Checks for undocumented public function definitions.
D104 stable undocumented-public-package
Checks for undocumented public package definitions.
D105 stable undocumented-magic-method
Checks for undocumented magic method definitions.
D106 stable undocumented-public-nested-class
Checks for undocumented public class definitions, for nested classes.
D107 stable undocumented-public-init
Checks for public `__init__` method definitions that are missing docstrings.
D200 stable unnecessary-multiline-docstring
Checks for single-line docstrings that are broken across multiple lines.
D201 stable blank-line-before-function
Checks for docstrings on functions that are separated by one or more blank lines from the function definition.
D202 stable blank-line-after-function
Checks for docstrings on functions that are separated by one or more blank lines from the function body.
D203 stable incorrect-blank-line-before-class
Checks for docstrings on class definitions that are not preceded by a blank line.
D204 stable incorrect-blank-line-after-class
Checks for class methods that are not separated from the class's docstring by a blank line.
D205 stable missing-blank-line-after-summary
Checks for docstring summary lines that are not separated from the docstring description by one blank line.
D206 stable docstring-tab-indentation
Checks for docstrings that are indented with tabs.
D209 stable new-line-after-last-paragraph
Checks for multi-line docstrings whose closing quotes are not on their own line.
D210 stable surrounding-whitespace
Checks for surrounding whitespace in docstrings.
D211 stable blank-line-before-class
Checks for docstrings on class definitions that are preceded by a blank line.
D212 stable multi-line-summary-first-line
Checks for docstring summary lines that are not positioned on the first physical line of the docstring.
D213 stable multi-line-summary-second-line
Checks for docstring summary lines that are not positioned on the second physical line of the docstring.
D214 stable overindented-section
Checks for over-indented sections in docstrings.
D215 stable overindented-section-underline
Checks for over-indented section underlines in docstrings.
D300 stable triple-single-quotes
Checks for docstrings that don't use `"""triple double quotes"""`.
D301 stable escape-sequence-in-docstring
Checks for docstrings that include backslashes, but are not defined as raw string literals.
D400 stable missing-trailing-period
Checks for docstrings in which the first line does not end in a period.
D401 stable non-imperative-mood
Checks for docstring first lines that are not in an imperative mood.
D402 stable signature-in-docstring
Checks for function docstrings that include the function's signature in the summary line.
D403 stable first-word-uncapitalized
Checks for docstrings that do not start with a capital letter.
D404 stable docstring-starts-with-this
Checks for docstrings that start with `This`.
D405 stable non-capitalized-section-name
Checks for section headers in docstrings that do not begin with capital letters.
D406 stable missing-new-line-after-section-name
Checks for section headers in docstrings that are followed by non-newline characters.
D407 stable missing-dashed-underline-after-section
Checks for section headers in docstrings that are not followed by underlines.
D408 stable missing-section-underline-after-name
Checks for section underlines in docstrings that are not on the line immediately following the section name.
D409 stable mismatched-section-underline-length
Checks for section underlines in docstrings that do not match the length of the corresponding section header.
D410 stable no-blank-line-after-section
Checks for docstring sections that are not separated by a single blank line.
D411 stable no-blank-line-before-section
Checks for docstring sections that are not separated by a blank line.
D412 stable blank-lines-between-header-and-content
Checks for docstring sections that contain blank lines between a section header and a section body.
D413 stable missing-blank-line-after-last-section
Checks for missing blank lines after the last section of a multiline docstring.
D415 stable missing-terminal-punctuation
Checks for docstrings in which the first line does not end in a punctuation mark, such as a period, question mark, or exclamation point.
D416 stable missing-section-name-colon
Checks for docstring section headers that do not end with a colon.
D417 stable undocumented-param
Checks for function docstrings that do not include documentation for all parameters in the function.
D418 stable overload-with-docstring
Checks for `@overload` function definitions that contain a docstring.
D420 preview incorrect-section-order
Checks for docstring sections that appear out of order.
F402 stable import-shadowed-by-loop-var
Checks for import bindings that are shadowed by loop variables.
F403 stable undefined-local-with-import-star
Checks for the use of wildcard imports.
F404 stable late-future-import
Checks for `__future__` imports that are not located at the beginning of a file.
F405 stable undefined-local-with-import-star-usage
Checks for names that might be undefined, but may also be defined in a wildcard import.
F406 stable undefined-local-with-nested-import-star-usage
Check for the use of wildcard imports outside of the module namespace.
F407 stable future-feature-not-defined
Checks for `__future__` imports that are not defined in the current Python version.
F501 stable percent-format-invalid-format
Checks for invalid `printf`-style format strings.
F502 stable percent-format-expected-mapping
Checks for named placeholders in `printf`-style format strings without mapping-type values.
F503 stable percent-format-expected-sequence
Checks for uses of mapping-type values in `printf`-style format strings without named placeholders.
F504 stable percent-format-extra-named-arguments
Checks for unused mapping keys in `printf`-style format strings.
F505 stable percent-format-missing-argument
Checks for named placeholders in `printf`-style format strings that are not present in the provided mapping.
F506 stable percent-format-mixed-positional-and-named
Checks for `printf`-style format strings that have mixed positional and named placeholders.
F507 stable percent-format-positional-count-mismatch
Checks for `printf`-style format strings that have a mismatch between the number of positional placeholders and the number of substitution values.
F508 stable percent-format-star-requires-sequence
Checks for `printf`-style format strings that use the `*` specifier with non-tuple values.
F509 stable percent-format-unsupported-format-character
Checks for `printf`-style format strings with invalid format characters.
F521 stable string-dot-format-invalid-format
Checks for `str.format` calls with invalid format strings.
F522 stable string-dot-format-extra-named-arguments
Checks for `str.format` calls with unused keyword arguments.
F523 stable string-dot-format-extra-positional-arguments
Checks for `str.format` calls with unused positional arguments.
F524 stable string-dot-format-missing-arguments
Checks for `str.format` calls with placeholders that are missing arguments.
F525 stable string-dot-format-mixing-automatic
Checks for `str.format` calls that mix automatic and manual numbering.
F541 stable f-string-missing-placeholders
Checks for f-strings that do not contain any placeholder expressions.
F601 stable multi-value-repeated-key-literal
Checks for dictionary literals that associate multiple values with the same key.
F602 stable multi-value-repeated-key-variable
Checks for dictionary keys that are repeated with different values.
F621 stable expressions-in-star-assignment
Checks for the use of too many expressions in starred assignment statements.
F622 stable multiple-starred-expressions
Checks for the use of multiple starred expressions in assignment statements.
F631 stable assert-tuple
Checks for `assert` statements that use non-empty tuples as test conditions.
F632 stable is-literal
Checks for `is` and `is not` comparisons against literals, like integers, strings, or lists.
F633 stable invalid-print-syntax
Checks for `print` statements that use the `>>` syntax.
F634 stable if-tuple
Checks for `if` statements that use non-empty tuples as test conditions.
F702 stable continue-outside-loop
Checks for `continue` statements outside of loops.
F704 stable yield-outside-function
Checks for `yield`, `yield from`, and `await` usages outside of functions.
F706 stable return-outside-function
Checks for `return` statements outside of functions.
F707 stable default-except-not-last
Checks for `except` blocks that handle all exceptions, but are not the last `except` block in a `try` statement.
F722 stable forward-annotation-syntax-error
Checks for forward annotations that include invalid syntax.
F811 stable redefined-while-unused
Checks for variable definitions that redefine (or "shadow") unused variables.
F841 stable unused-variable
Checks for the presence of unused variables in function scopes.
F842 stable unused-annotation
Checks for local variables that are annotated but never used.
F901 stable raise-not-implemented
Checks for `raise` statements that raise `NotImplemented`.
PGH002 removed deprecated-log-warn
Check for usages of the deprecated `warn` method from the `logging` module.
PGH003 stable blanket-type-ignore
Check for `type: ignore` annotations that suppress all type warnings, as opposed to targeting specific type warnings.
PGH004 stable blanket-noqa
Check for `noqa` annotations that suppress all diagnostics, as opposed to targeting specific diagnostics.
PGH005 stable invalid-mock-access
Checks for common mistakes when using mock objects.
PLC0105 stable type-name-incorrect-variance
Checks for type names that do not match the variance of their associated type parameter.
PLC0131 stable type-bivariance
Checks for `TypeVar` and `ParamSpec` definitions in which the type is both covariant and contravariant.
PLC0132 stable type-param-name-mismatch
Checks for `TypeVar`, `TypeVarTuple`, `ParamSpec`, and `NewType` definitions in which the name of the type parameter does not match the name of the variable to which it is assigned.
PLC0205 stable single-string-slots
Checks for single strings assigned to `__slots__`.
PLC0206 stable dict-index-missing-items
Checks for dictionary iterations that extract the dictionary value via explicit indexing, instead of using `.items()`.
PLC0207 stable missing-maxsplit-arg
Checks for access to the first or last element of `str.split()` or `str.rsplit()` without a `maxsplit=1` argument.
PLC0208 stable iteration-over-set
Checks for iteration over a `set` literal in which each element is a literal.
PLC0414 stable useless-import-alias
Checks for import aliases that do not rename the original package. This rule does not apply in `__init__.py` files.
PLC0415 stable import-outside-top-level
Checks for `import` statements outside of a module's top-level scope, such as within a function or class definition.
PLC1802 stable len-test
Checks for `len` calls on sequences in a boolean test context.
PLC2401 stable non-ascii-name
Checks for the use of non-ASCII characters in variable names.
PLC2403 stable non-ascii-import-name
Checks for the use of non-ASCII characters in import statements.
PLC2701 preview import-private-name
Checks for import statements that import a private name (a name starting with an underscore `_`) from another module.
PLC2801 preview unnecessary-dunder-call
Checks for explicit use of dunder methods, like `__str__` and `__add__`.
PLC3002 stable unnecessary-direct-lambda-call
Checks for unnecessary direct calls to lambda expressions.
PLE0100 stable yield-in-init
Checks for `__init__` methods that are turned into generators by the inclusion of `yield` or `yield from` expressions.
PLE0115 stable nonlocal-and-global
Checks for variables which are both declared as both `nonlocal` and `global`.
PLE0116 stable continue-in-finally
Checks for `continue` statements inside `finally`
PLE0117 stable nonlocal-without-binding
Checks for `nonlocal` names without bindings.
PLE0118 stable load-before-global-declaration
Checks for uses of names that are declared as `global` prior to the relevant `global` declaration.
PLE0237 stable non-slot-assignment
Checks for assignments to attributes that are not defined in `__slots__`.
PLE0241 stable duplicate-bases
Checks for duplicate base classes in class definitions.
PLE0302 stable unexpected-special-method-signature
Checks for "special" methods that have an unexpected method signature.
PLE0303 stable invalid-length-return-type
Checks for `__len__` implementations that return values that are not non-negative integers.
PLE0304 preview invalid-bool-return-type
Checks for `__bool__` implementations that return a type other than `bool`.
PLE0305 stable invalid-index-return-type
Checks for `__index__` implementations that return non-integer values.
PLE0307 stable invalid-str-return-type
Checks for `__str__` implementations that return a type other than `str`.
PLE0308 stable invalid-bytes-return-type
Checks for `__bytes__` implementations that return types other than `bytes`.
PLE0309 stable invalid-hash-return-type
Checks for `__hash__` implementations that return non-integer values.
PLE0604 stable invalid-all-object
Checks for the inclusion of invalid objects in `__all__`.
PLE0643 stable potential-index-error
Checks for hard-coded sequence accesses that are known to be out of bounds.
PLE0704 stable misplaced-bare-raise
Checks for bare `raise` statements outside of exception handlers.
PLE1132 stable repeated-keyword-argument
Checks for repeated keyword arguments in function calls.
PLE1141 preview dict-iter-missing-items
Checks for dictionary unpacking in a for loop without calling `.items()`.
PLE1142 stable await-outside-async
Checks for uses of `await` outside `async` functions.
PLE1205 stable logging-too-many-args
Checks for too many positional arguments for a `logging` format string.
PLE1206 stable logging-too-few-args
Checks for too few positional arguments for a `logging` format string.
PLE1300 stable bad-string-format-character
Checks for unsupported format types in format strings.
PLE1307 stable bad-string-format-type
Checks for mismatched argument types in "old-style" format strings.
PLE1507 stable invalid-envvar-value
Checks for `os.getenv` calls with an invalid `key` argument.
PLE1519 stable singledispatch-method
Checks for methods decorated with `@singledispatch`.
PLE1520 stable singledispatchmethod-function
Checks for non-method functions decorated with `@singledispatchmethod`.
PLE1700 stable yield-from-in-async-function
Checks for uses of `yield from` in async functions.
PLE2502 stable bidirectional-unicode
Checks for bidirectional formatting characters.
PLE2510 stable invalid-character-backspace
Checks for strings that contain the control character `BS`.
PLE2512 stable invalid-character-sub
Checks for strings that contain the raw control character `SUB`.
PLE2513 stable invalid-character-esc
Checks for strings that contain the raw control character `ESC`.
PLE2514 stable invalid-character-nul
Checks for strings that contain the raw control character `NUL` (0 byte).
PLE2515 stable invalid-character-zero-width-space
Checks for strings that contain the zero width space character.
PLE4703 preview modified-iterating-set
Checks for loops in which a `set` is modified during iteration.
PLR0124 stable comparison-with-itself
Checks for operations that compare a name to itself.
PLR0202 preview no-classmethod-decorator
Checks for the use of a classmethod being made without the decorator.
PLR0203 preview no-staticmethod-decorator
Checks for the use of a staticmethod being made without the decorator.
PLR0206 stable property-with-parameters
Checks for property definitions that accept function parameters.
PLR0402 stable manual-from-import
Checks for submodule imports that are aliased to the submodule name.
PLR0904 preview too-many-public-methods
Checks for classes with too many public methods By default, this rule allows up to 20 public methods, as configured by the [`lint.pylint.max-public-methods`] option.
PLR0911 stable too-many-return-statements
Checks for functions or methods with too many return statements. By default, this rule allows up to six return statements, as configured by the [`lint.pylint.max-returns`] option.
PLR0912 stable too-many-branches
Checks for functions or methods with too many branches, including (nested) `if`, `elif`, and `else` branches, `for` loops, `try`-`except` clauses, and `match` and `case` statements. By default, this rule allows up to 12 branches. This can be configured using the [`lint.pylint.max-branches`] option.
PLR0913 stable too-many-arguments
Checks for function definitions that include too many arguments. By default, this rule allows up to five arguments, as configured by the [`lint.pylint.max-args`] option. This rule exempts methods decorated with [`@typing.override`][override]. Changing the signature of a subclass method may cause type checkers to complain about a violation of the Liskov Substitution Principle if it means that the method now incompatibly overrides a method defined on a superclass. Explicitly decorating an overriding method with `@override` signals to Ruff that the method is intended to override a superclass method and that a type checker will enforce that it does so; Ruff therefore knows that it should not enforce rules about methods having too many arguments.
PLR0914 preview too-many-locals
Checks for functions that include too many local variables. By default, this rule allows up to fifteen locals, as configured by the [`lint.pylint.max-locals`] option.
PLR0915 stable too-many-statements
Checks for functions or methods with too many statements. By default, this rule allows up to 50 statements, as configured by the [`lint.pylint.max-statements`] option.
PLR0916 preview too-many-boolean-expressions
Checks for too many Boolean expressions in an `if` statement. By default, this rule allows up to 5 expressions. This can be configured using the [`lint.pylint.max-bool-expr`] option.
PLR0917 preview too-many-positional-arguments
Checks for function definitions that include too many positional arguments. By default, this rule allows up to five arguments, as configured by the [`lint.pylint.max-positional-args`] option.
PLR1701 removed repeated-isinstance-calls
Checks for repeated `isinstance` calls on the same object.
PLR1702 preview too-many-nested-blocks
Checks for functions or methods with too many nested blocks. By default, this rule allows up to five nested blocks. This can be configured using the [`lint.pylint.max-nested-blocks`] option.
PLR1704 stable redefined-argument-from-local
Checks for variables defined in `for`, `try`, `with` statements that redefine function parameters.
PLR1706 stable and-or-ternary
Checks for uses of the known pre-Python 2.5 ternary syntax.
PLR1708 preview stop-iteration-return
Checks for explicit `raise StopIteration` in generator functions.
PLR1711 stable useless-return
Checks for functions that end with an unnecessary `return` or `return None`, and contain no other `return` statements.
PLR1712 preview swap-with-temporary-variable
Checks for code that swaps two variables using a temporary variable.
PLR1714 stable repeated-equality-comparison
Checks for repeated equality comparisons that can be rewritten as a membership test. This rule will try to determine if the values are hashable and the fix will use a `set` if they are. If unable to determine, the fix will use a `tuple` and suggest the use of a `set`.
PLR1716 stable boolean-chained-comparison
Check for chained boolean operations that can be simplified.
PLR1730 stable if-stmt-min-max
Checks for `if` statements that can be replaced with `min()` or `max()` calls.
PLR1733 stable unnecessary-dict-index-lookup
Checks for key-based dict accesses during `.items()` iterations.
PLR1736 stable unnecessary-list-index-lookup
Checks for index-based list accesses during `enumerate` iterations.
PLR2004 stable magic-value-comparison
Checks for the use of unnamed numerical constants ("magic") values in comparisons.
PLR2044 stable empty-comment
Checks for a # symbol appearing on a line not followed by an actual comment.
PLR5501 stable collapsible-else-if
Checks for `else` blocks that consist of a single `if` statement.
PLR6104 preview non-augmented-assignment
Checks for assignments that can be replaced with augmented assignment statements.
PLR6201 preview literal-membership
Checks for membership tests on `list` and `tuple` literals.
PLR6301 preview no-self-use
Checks for the presence of unused `self` parameter in methods definitions.
PLW0108 stable unnecessary-lambda
Checks for `lambda` definitions that consist of a single function call with the same arguments as the `lambda` itself.
PLW0120 stable useless-else-on-loop
Checks for `else` clauses on loops without a `break` statement.
PLW0128 stable redeclared-assigned-name
Checks for declared assignments to the same variable multiple times in the same assignment.
PLW0129 stable assert-on-string-literal
Checks for `assert` statements that use a string literal as the first argument.
PLW0131 stable named-expr-without-context
Checks for uses of named expressions (e.g., `a := 42`) that can be replaced by regular assignment statements (e.g., `a = 42`).
PLW0133 stable useless-exception-statement
Checks for an exception that is not raised.
PLW0211 stable bad-staticmethod-argument
Checks for static methods that use `self` or `cls` as their first argument. This rule also applies to `__new__` methods, which are implicitly static.
PLW0244 preview redefined-slots-in-subclass
Checks for a re-defined slot in a subclass.
PLW0245 stable super-without-brackets
Detects attempts to use `super` without parentheses.
PLW0406 stable import-self
Checks for import statements that import the current module.
PLW0602 stable global-variable-not-assigned
Checks for `global` variables that are not assigned a value in the current scope.
PLW0603 stable global-statement
Checks for the use of `global` statements to update identifiers.
PLW0604 stable global-at-module-level
Checks for uses of the `global` keyword at the module level.
PLW0642 stable self-or-cls-assignment
Checks for assignment of `self` and `cls` in instance and class methods respectively. This check also applies to `__new__` even though this is technically a static method.
PLW0711 stable binary-op-exception
Checks for `except` clauses that attempt to catch multiple exceptions with a binary operation (`and` or `or`).
PLW1508 stable invalid-envvar-default
Checks for `os.getenv` calls with invalid default values.
PLW1509 stable subprocess-popen-preexec-fn
Checks for uses of `subprocess.Popen` with a `preexec_fn` argument.
PLW1510 stable subprocess-run-without-check
Checks for uses of `subprocess.run` without an explicit `check` argument.
PLW1514 preview unspecified-encoding
Checks for uses of `open` and related calls without an explicit `encoding` argument.
PLW1641 stable eq-without-hash
Checks for classes that implement `__eq__` but not `__hash__`.
PLW2101 stable useless-with-lock
Checks for lock objects that are created and immediately discarded in `with` statements.
PLW2901 stable redefined-loop-name
Checks for variables defined in `for` loops and `with` statements that get overwritten within the body, for example by another `for` loop or `with` statement or by direct assignment.
PLW3201 preview bad-dunder-method-name
Checks for dunder methods that have no special meaning in Python 3.
UP001 stable useless-metaclass-type
Checks for the use of `__metaclass__ = type` in class definitions.
UP003 stable type-of-primitive
Checks for uses of `type` that take a primitive as an argument.
UP004 stable useless-object-inheritance
Checks for classes that inherit from `object`.
UP005 stable deprecated-unittest-alias
Checks for uses of deprecated methods from the `unittest` module.
UP006 stable non-pep585-annotation
Checks for the use of generics that can be replaced with standard library variants based on [PEP 585].
UP007 stable non-pep604-annotation-union
Check for type annotations that can be rewritten based on [PEP 604] syntax.
UP008 stable super-call-with-parameters
Checks for `super` calls that pass redundant arguments.
UP009 stable utf8-encoding-declaration
Checks for unnecessary UTF-8 encoding declarations.
UP010 stable unnecessary-future-import
Checks for unnecessary `__future__` imports.
UP011 stable lru-cache-without-parameters
Checks for unnecessary parentheses on `functools.lru_cache` decorators.
UP012 stable unnecessary-encode-utf8
Checks for unnecessary calls to `encode` as UTF-8.
UP013 stable convert-typed-dict-functional-to-class
Checks for `TypedDict` declarations that use functional syntax.
UP014 stable convert-named-tuple-functional-to-class
Checks for `NamedTuple` declarations that use functional syntax.
UP018 stable native-literals
Checks for unnecessary calls to `str`, `bytes`, `int`, `float`, `bool`, and `complex`.
UP019 stable typing-text-str-alias
Checks for uses of `typing.Text`. In preview mode, also checks for `typing_extensions.Text`.
UP021 stable replace-universal-newlines
Checks for uses of `subprocess.run` that set the `universal_newlines` keyword argument.
UP022 stable replace-stdout-stderr
Checks for uses of `subprocess.run` that send `stdout` and `stderr` to a pipe.
UP023 stable deprecated-c-element-tree
Checks for uses of the `xml.etree.cElementTree` module.
UP025 stable unicode-kind-prefix
Checks for uses of the Unicode kind prefix (`u`) in strings.
UP026 stable deprecated-mock-import
Checks for imports of the `mock` module that should be replaced with `unittest.mock`.
UP027 removed unpacked-list-comprehension
Checks for list comprehensions that are immediately unpacked.
UP028 stable yield-in-for-loop
Checks for `for` loops that can be replaced with `yield from` expressions.
UP029 stable unnecessary-builtin-import
Checks for unnecessary imports of builtins.
UP030 stable format-literals
Checks for unnecessary positional indices in format strings.
UP031 stable printf-string-formatting
Checks for `printf`-style string formatting, and offers to replace it with `str.format` calls.
UP032 stable f-string
Checks for `str.format` calls that can be replaced with f-strings.
UP033 stable lru-cache-with-maxsize-none
Checks for uses of `functools.lru_cache` that set `maxsize=None`.
UP035 stable deprecated-import
Checks for uses of deprecated imports based on the minimum supported Python version.
UP036 stable outdated-version-block
Checks for conditional blocks gated on `sys.version_info` comparisons that are outdated for the minimum supported Python version.
UP037 stable quoted-annotation
Checks for the presence of unnecessary quotes in type annotations.
UP038 removed non-pep604-isinstance
Checks for uses of `isinstance` and `issubclass` that take a tuple of types for comparison.
UP039 stable unnecessary-class-parentheses
Checks for class definitions that include unnecessary parentheses after the class name.
UP040 stable non-pep695-type-alias
Checks for use of `TypeAlias` annotations and `TypeAliasType` assignments for declaring type aliases.
UP041 stable timeout-error-alias
Checks for uses of exceptions that alias `TimeoutError`.
UP042 stable replace-str-enum
Checks for classes that inherit from both `str` and `enum.Enum`.
UP043 stable unnecessary-default-type-args
Checks for unnecessary default type arguments for `Generator` and `AsyncGenerator` on Python 3.13+.
UP044 stable non-pep646-unpack
Checks for uses of `Unpack[]` on Python 3.11 and above, and suggests using `*` instead.
UP045 stable non-pep604-annotation-optional
Check for `typing.Optional` annotations that can be rewritten based on [PEP 604] syntax.
UP046 stable non-pep695-generic-class
Checks for use of standalone type variables and parameter specifications in generic classes.
UP047 stable non-pep695-generic-function
Checks for use of standalone type variables and parameter specifications in generic functions.
UP049 stable private-type-parameter
Checks for use of [PEP 695] type parameters with leading underscores in generic classes and functions.
UP050 stable useless-class-metaclass-type
Checks for `metaclass=type` in class definitions.
FURB101 preview read-whole-file
Checks for uses of `open` and `read` that can be replaced by `pathlib` methods, like `Path.read_text` and `Path.read_bytes`.
FURB103 preview write-whole-file
Checks for uses of `open` and `write` that can be replaced by `pathlib` methods, like `Path.write_text` and `Path.write_bytes`.
FURB105 stable print-empty-string
Checks for `print` calls with unnecessary empty strings as positional arguments and unnecessary `sep` keyword arguments.
FURB110 stable if-exp-instead-of-or-operator
Checks for ternary `if` expressions that can be replaced with the `or` operator.
FURB116 stable f-string-number-format
Checks for uses of `bin(...)[2:]` (or `hex`, or `oct`) to convert an integer into a string.
FURB118 preview reimplemented-operator
Checks for lambda expressions and function definitions that can be replaced with a function from the `operator` module.
FURB129 stable readlines-in-for
Checks for uses of `readlines()` when iterating over a file line-by-line.
FURB131 preview delete-full-slice
Checks for `del` statements that delete the entire slice of a list or dictionary.
FURB132 stable check-and-remove-from-set
Checks for uses of `set.remove` that can be replaced with `set.discard`.
FURB136 stable if-expr-min-max
Checks for `if` expressions that can be replaced with `min()` or `max()` calls.
FURB140 preview reimplemented-starmap
Checks for generator expressions, list and set comprehensions that can be replaced with `itertools.starmap`.
FURB142 preview for-loop-set-mutations
Checks for code that updates a set with the contents of an iterable by using a `for` loop to call `.add()` or `.discard()` on each element separately.
FURB148 preview unnecessary-enumerate
Checks for uses of `enumerate` that discard either the index or the value when iterating over a sequence.
FURB152 preview math-constant
Checks for literals that are similar to constants in `math` module.
FURB154 preview repeated-global
Checks for consecutive `global` (or `nonlocal`) statements.
FURB156 preview hardcoded-string-charset
Checks for uses of hardcoded charsets, which are defined in Python string module.
FURB157 stable verbose-decimal-constructor
Checks for unnecessary string literal or float casts in `Decimal` constructors.
FURB161 stable bit-count
Checks for uses of `bin(...).count("1")` to perform a population count.
FURB162 stable fromisoformat-replace-z
Checks for `datetime.fromisoformat()` calls where the only argument is an inline replacement of `Z` with a zero offset timezone.
FURB163 stable redundant-log-base
Checks for `math.log` calls with a redundant base.
FURB164 preview unnecessary-from-float
Checks for unnecessary `from_float` and `from_decimal` usages to construct `Decimal` and `Fraction` instances.
FURB166 stable int-on-sliced-str
Checks for uses of `int` with an explicit base in which a string expression is stripped of its leading prefix (i.e., `0b`, `0o`, or `0x`).
FURB167 stable regex-flag-alias
Checks for the use of shorthand aliases for regular expression flags (e.g., `re.I` instead of `re.IGNORECASE`).
FURB168 stable isinstance-type-none
Checks for uses of `isinstance` that check if an object is of type `None`.
FURB169 stable type-none-comparison
Checks for uses of `type` that compare the type of an object to the type of `None`.
FURB171 stable single-item-membership-test
Checks for membership tests against single-item containers.
FURB177 stable implicit-cwd
Checks for current-directory lookups using `Path().resolve()`.
FURB180 preview meta-class-abc-meta
Checks for uses of `metaclass=abc.ABCMeta` to define abstract base classes (ABCs).
FURB181 stable hashlib-digest-hex
Checks for the use of `.digest().hex()` on a hashlib hash, like `sha512`.
FURB187 stable list-reverse-copy
Checks for list reversals that can be performed in-place in lieu of creating a new list.
FURB188 stable slice-to-remove-prefix-or-suffix
Checks for code that could be written more idiomatically using [`str.removeprefix()`](https://docs.python.org/3/library/stdtypes.html#str.removeprefix) or [`str.removesuffix()`](https://docs.python.org/3/library/stdtypes.html#str.removesuffix). Specifically, the rule flags code that conditionally removes a prefix or suffix using a slice operation following an `if` test that uses `str.startswith()` or `str.endswith()`. The rule is only applied if your project targets Python 3.9 or later.
FURB192 preview sorted-min-max
Checks for uses of `sorted()` to retrieve the minimum or maximum value in a sequence.
RUF001 stable ambiguous-unicode-character-string
Checks for ambiguous Unicode characters in strings.
RUF002 stable ambiguous-unicode-character-docstring
Checks for ambiguous Unicode characters in docstrings.
RUF003 stable ambiguous-unicode-character-comment
Checks for ambiguous Unicode characters in comments.
RUF005 stable collection-literal-concatenation
Checks for uses of the `+` operator to concatenate collections.
RUF006 stable asyncio-dangling-task
Checks for `asyncio.create_task` and `asyncio.ensure_future` calls that do not store a reference to the returned result.
RUF007 stable zip-instead-of-pairwise
Checks for use of `zip()` to iterate over successive pairs of elements.
RUF008 stable mutable-dataclass-default
Checks for mutable default values in dataclass attributes.
RUF009 stable function-call-in-dataclass-default-argument
Checks for function calls in dataclass attribute defaults.
RUF010 stable explicit-f-string-type-conversion
Checks for uses of `str()`, `repr()`, and `ascii()` as explicit type conversions within f-strings.
RUF011 removed ruff-static-key-dict-comprehension
Checks for dictionary comprehensions that use a static key, like a string literal or a variable defined outside the comprehension.
RUF012 stable mutable-class-default
Checks for mutable default values in class attributes.
RUF013 stable implicit-optional
Checks for the use of implicit `Optional` in type annotations when the default parameter value is `None`. If [`lint.future-annotations`] is set to `true`, `from __future__ import annotations` will be added if doing so would allow using the `|` operator on a Python version before 3.10.
RUF015 stable unnecessary-iterable-allocation-for-first-element
Checks the following constructs, all of which can be replaced by `next(iter(...))`: - `list(...)[0]` - `tuple(...)[0]` - `list(i for i in ...)[0]` - `[i for i in ...][0]` - `list(...).pop(0)`
RUF016 stable invalid-index-type
Checks for indexed access to lists, strings, tuples, bytes, and comprehensions using a type other than an integer or slice.
RUF017 stable quadratic-list-summation
Checks for the use of `sum()` to flatten lists of lists, which has quadratic complexity.
RUF018 stable assignment-in-assert
Checks for named assignment expressions (e.g., `x := 0`) in `assert` statements.
RUF019 stable unnecessary-key-check
Checks for unnecessary key checks prior to accessing a dictionary.
RUF020 stable never-union
Checks for uses of `typing.NoReturn` and `typing.Never` in union types.
RUF021 stable parenthesize-chained-operators
Checks for chained operators where adding parentheses could improve the clarity of the code.
RUF022 stable unsorted-dunder-all
Checks for `__all__` definitions that are not ordered according to an "isort-style" sort. An isort-style sort orders items first according to their casing: SCREAMING_SNAKE_CASE names (conventionally used for global constants) come first, followed by CamelCase names (conventionally used for classes), followed by anything else. Within each category, a [natural sort](https://en.wikipedia.org/wiki/Natural_sort_order) is used to order the elements.
RUF023 stable unsorted-dunder-slots
Checks for `__slots__` definitions that are not ordered according to a [natural sort](https://en.wikipedia.org/wiki/Natural_sort_order).
RUF024 stable mutable-fromkeys-value
Checks for mutable objects passed as a value argument to `dict.fromkeys`.
RUF026 stable default-factory-kwarg
Checks for incorrect usages of `default_factory` as a keyword argument when initializing a `defaultdict`.
RUF027 preview missing-f-string-syntax
Searches for strings that look like they were meant to be f-strings, but are missing an `f` prefix.
RUF028 stable invalid-formatter-suppression-comment
Checks for formatter suppression comments that are ineffective or incompatible with Ruff's formatter.
RUF029 preview unused-async
Checks for functions declared `async` that do not await or otherwise use features requiring the function to be declared `async`.
RUF030 stable assert-with-print-message
Checks for uses of `assert expression, print(message)`.
RUF031 preview incorrectly-parenthesized-tuple-in-subscript
Checks for consistent style regarding whether nonempty tuples in subscripts are parenthesized. The exact nature of this violation depends on the setting [`lint.ruff.parenthesize-tuple-in-subscript`]. By default, the use of parentheses is considered a violation. This rule is not applied inside "typing contexts" (type annotations, type aliases and subscripted class bases), as these have their own specific conventions around them.
RUF032 stable decimal-from-float-literal
Checks for `Decimal` calls passing a float literal.
RUF033 stable post-init-default
Checks for `__post_init__` dataclass methods with parameter defaults.
RUF034 stable useless-if-else
Checks for useless `if`-`else` conditions with identical arms.
RUF035 removed ruff-unsafe-markup-use
Checks for non-literal strings being passed to [`markupsafe.Markup`][markupsafe-markup].
RUF036 preview none-not-at-end-of-union
Checks for type annotations where `None` is not at the end of an union.
RUF037 stable unnecessary-empty-iterable-within-deque-call
Checks for use of `collections.deque` with an empty iterable as the first argument.
RUF038 preview redundant-bool-literal
Checks for `Literal[True, False]` type annotations.
RUF039 preview unraw-re-pattern
Reports the following `re` and `regex` calls when their first arguments are not raw strings: - For `regex` and `re`: `compile`, `findall`, `finditer`, `fullmatch`, `match`, `search`, `split`, `sub`, `subn`. - `regex`-specific: `splititer`, `subf`, `subfn`, `template`.
RUF040 stable invalid-assert-message-literal-argument
Checks for invalid use of literals in assert message arguments.
RUF041 stable unnecessary-nested-literal
Checks for unnecessary nested `Literal`.
RUF043 stable pytest-raises-ambiguous-pattern
Checks for non-raw literal string arguments passed to the `match` parameter of `pytest.raises()` where the string contains at least one unescaped regex metacharacter.
RUF045 preview implicit-class-var-in-dataclass
Checks for implicit class variables in dataclasses. Variables matching the [`lint.dummy-variable-rgx`] are excluded from this rule.
RUF046 stable unnecessary-cast-to-int
Checks for `int` conversions of values that are already integers.
RUF047 preview needless-else
Checks for `else` clauses that only contains `pass` and `...` statements.
RUF048 stable map-int-version-parsing
Checks for calls of the form `map(int, __version__.split("."))`.
RUF049 stable dataclass-enum
Checks for enum classes which are also decorated with `@dataclass`.
RUF050 preview unnecessary-if
Checks for `if` statements (without `elif` or `else` branches) where the body contains only `pass` or `...`
RUF051 stable if-key-in-dict-del
Checks for `if key in dictionary: del dictionary[key]`.
RUF052 preview used-dummy-variable
Checks for "dummy variables" (variables that are named as if to indicate they are unused) that are in fact used. By default, "dummy variables" are any variables with names that start with leading underscores. However, this is customisable using the [`lint.dummy-variable-rgx`] setting).
RUF053 stable class-with-mixed-type-vars
Checks for classes that have [PEP 695] [type parameter lists] while also inheriting from `typing.Generic` or `typing_extensions.Generic`.
RUF054 preview indented-form-feed
Checks for form feed characters preceded by either a space or a tab.
RUF055 preview unnecessary-regular-expression
Checks for uses of the `re` module that can be replaced with builtin `str` methods.
RUF056 preview falsy-dict-get-fallback
Checks for `dict.get(key, falsy_value)` calls in boolean test positions.
RUF057 stable unnecessary-round
Checks for `round()` calls that have no effect on the input.
RUF058 stable starmap-zip
Checks for `itertools.starmap` calls where the second argument is a `zip` call.
RUF059 stable unused-unpacked-variable
Checks for the presence of unused variables in unpacked assignments.
RUF060 stable in-empty-collection
Checks for membership tests on empty collections (such as `list`, `tuple`, `set`, or `dict`).
RUF061 stable legacy-form-pytest-raises
Checks for non-context-manager use of `pytest.raises`, `pytest.warns`, and `pytest.deprecated_call`.
RUF063 preview access-annotations-from-class-dict
Checks for uses of `foo.__dict__.get("__annotations__")` or `foo.__dict__["__annotations__"]` on Python 3.10+ and Python < 3.10 when [typing-extensions](https://docs.astral.sh/ruff/settings/#lint_typing-extensions) is enabled.
RUF064 stable non-octal-permissions
Checks for standard library functions which take a numeric `mode` argument where a non-octal integer literal is passed.
RUF065 preview logging-eager-conversion
Checks for eager string conversion of arguments to `logging` calls.
RUF066 preview property-without-return
Detects class `@property` methods that does not have a `return` statement.
RUF067 preview non-empty-init-module
Detects the presence of code in `__init__.py` files.
RUF068 preview duplicate-entry-in-dunder-all
Detects duplicate elements in `__all__` definitions.
RUF069 preview float-equality-comparison
Checks for comparisons between floating-point values using `==` or `!=`.
RUF070 preview unnecessary-assign-before-yield
Checks for variable assignments that immediately precede a `yield` (or `yield from`) of the assigned variable, where the variable is not referenced anywhere else.
RUF071 preview os-path-commonprefix
Checks for uses of `os.path.commonprefix`.
RUF072 preview useless-finally
Checks for `finally` clauses that only contain `pass` or `...` statements
RUF073 preview f-string-percent-format
Checks for uses of the `%` operator on f-strings.
RUF100 stable unused-noqa
Checks for `noqa` directives that are no longer applicable.
RUF101 stable redirected-noqa
Checks for `noqa` directives that use redirected rule codes.
RUF102 stable invalid-rule-code
Checks for `noqa` codes that are invalid.
RUF103 stable invalid-suppression-comment
Checks for invalid suppression comments
RUF104 stable unmatched-suppression-comment
Checks for unmatched range suppression comments
RUF200 stable invalid-pyproject-toml
Checks for any pyproject.toml that does not conform to the schema from the relevant PEPs.
TRY002 stable raise-vanilla-class
Checks for code that raises `Exception` or `BaseException` directly.
TRY003 stable raise-vanilla-args
Checks for long exception messages that are not defined in the exception class itself.
TRY004 stable type-check-without-type-error
Checks for type checks that do not raise `TypeError`.
TRY200 removed reraise-no-cause
Checks for exceptions that are re-raised without specifying the cause via the `from` keyword.
TRY201 stable verbose-raise
Checks for needless exception names in `raise` statements.
TRY203 stable useless-try-except
Checks for immediate uses of `raise` within exception handlers.
TRY300 stable try-consider-else
Checks for `return` statements in `try` blocks.
TRY301 stable raise-within-try
Checks for `raise` statements within `try` blocks. The only `raise`s caught are those that throw exceptions caught by the `try` statement itself.
TRY400 stable error-instead-of-exception
Checks for uses of `logging.error` instead of `logging.exception` when logging an exception.
TRY401 stable verbose-log-message
Checks for excessive logging of exception objects.