Programming Search⌘K

Python lints, page 2 of 8

The lint rules of Python, with what each one finds. This page has 1,420 cards.

Checks for docstring summary lines that are not positioned on the second physical line of the docstring. D213

PEP 257 recommends that multi-line docstrings consist of "a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description." Ruff takes this rule from pydocstyle and made it stable in v0.0.69.

Code
D213
Message
Multi-line docstring summary should start at the second line

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for function docstrings that include the function's signature in the summary line. D402

PEP 257 recommends against including a function's signature in its docstring. Instead, consider using type annotations as a form of documentation for the function's parameters and return value. Ruff takes this rule from pydocstyle and made it stable in v0.0.70.

Code
D402
Message
First line should not be the function's signature

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for section underlines in docstrings that are not on the line immediately following the section name. D408

This rule enforces a consistent style for multiline numpy-style docstrings, and helps prevent incorrect syntax in docstrings using reStructuredText. Ruff takes this rule from pydocstyle and made it stable in v0.0.71.

Code
D408
Message
Section underline should be in the line following the section's name ("{}")

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for docstrings in which the first line does not end in a punctuation mark, such as a period, question mark, or exclamation point. D415

The first line of a docstring should end with a period, question mark, or exclamation point, for grammatical correctness and consistency. Ruff takes this rule from pydocstyle and made it stable in v0.0.69.

Code
D415
Message
First line should end with a period, question mark, or exclamation point

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for function docstrings that do not include documentation for all parameters in the function. D417

This rule helps prevent you from leaving Google-style docstrings unfinished or incomplete. Multiline Google-style docstrings should describe all parameters for the function they are documenting. Ruff takes this rule from pydocstyle and made it stable in v0.0.73.

Code
D417
Message
Missing argument description in the docstring for `{}`: `{}`
Message
Missing argument descriptions in the docstring for `{}`: {}

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for @overload function definitions that contain a docstring. D418

The @overload decorator is used to define multiple compatible signatures for a given function, to support type-checking. A series of @overload definitions should be followed by a single non-decorated definition that contains the implementation of the function. Ruff takes this rule from pydocstyle and made it stable in v0.0.71.

Code
D418
Message
Function decorated with `@overload` shouldn't contain a docstring

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for @property method docstrings that start with known verbs (e.g., "returns", "gets", etc). D421

The Google Python style guide recommends that the docstring for a @property data descriptor use the same style as the docstring for an attribute or a function argument (e.g., """The Bigtable path."""), rather than a function-style docstring (e.g., """Returns the Bigtable path."""). Ruff takes this rule from pydocstyle. It is in preview.

Code
D421
Message
Property docstring should not start with a verb ("{}")

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Check that imported or used feature is deprecated. deprecated

If you use --enable-error-code deprecated, mypy generates an error if your code imports a deprecated feature explicitly with a from mod import depr statement or uses a deprecated feature imported otherwise or defined locally. Features are considered deprecated when decorated with warnings.deprecated, as specified in PEP 702. mypy does not enable this error code by default. Use --enable-error-code deprecated to enable it.

Code
deprecated
Severity
error

Source: github.com, mypy.readthedocs.io. JSON record. This entry is a card. Help write this page.

Check dict items. dict-item

When constructing a dictionary using {key: value, ...} or dict(key=value, ...), mypy checks that each key and value is compatible with the dictionary type that is inferred from the surrounding context. mypy enables this error code by default.

Code
dict-item
Severity
error

Source: github.com, mypy.readthedocs.io. JSON record. This entry is a card. Help write this page.

Checks nullable string-based fields (like CharField and TextField) in Django models. DJ001

If a string-based field is nullable, then your model will have two possible representations for "no data": None and the empty string. This can lead to confusion, as clients of the API have to check for both None and the empty string when trying to determine if the field has data. Ruff takes this rule from flake8-django and made it stable in v0.0.246.

Code
DJ001
Message
Avoid using `null=True` on string-based fields such as `{}`

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for the order of Model's inner classes, methods, and fields as per the Django Style Guide. DJ012

The Django Style Guide specifies that the order of Model inner classes, attributes and methods should be as follows: Ruff takes this rule from flake8-django and made it stable in v0.0.258.

Code
DJ012
Message
Order of model's inner classes, methods, and fields does not follow the Django Style Guide: {} should come before {}

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks that Django's @receiver decorator is listed first, prior to any other decorators. DJ013

Django's @receiver decorator is special in that it does not return a wrapped function. Rather, @receiver connects the decorated function to a signal. If any other decorators are listed before @receiver, the decorated function will not be connected to the signal. Ruff takes this rule from flake8-django and made it stable in v0.0.246.

Code
DJ013
Message
`@receiver` decorator must be on top of all the other decorators

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for function docstrings that do not document all explicitly raised exceptions. DOC501

A function should document all exceptions that are directly raised in some circumstances. Failing to document an exception that could be raised can be misleading to users and/or a sign of incomplete documentation. Ruff takes this rule from pydoclint. It is in preview.

Code
DOC501
Message
Raised exception `{}` missing from docstring

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for datetime instantiations that do not specify a timezone. DTZ001

datetime objects are "naive" by default, in that they do not include timezone information. "Naive" objects are easy to understand, but ignore some aspects of reality, which can lead to subtle bugs. Timezone-aware datetime objects are preferred, as they represent a specific moment in time, unlike "naive" objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ001
Message
`datetime.datetime()` called without a `tzinfo` argument
Message
`tzinfo=None` passed to `datetime.datetime()`

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usage of datetime.datetime.today(). DTZ002

datetime objects are "naive" by default, in that they do not include timezone information. "Naive" objects are easy to understand, but ignore some aspects of reality, which can lead to subtle bugs. Timezone-aware datetime objects are preferred, as they represent a specific moment in time, unlike "naive" objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ002
Message
`datetime.datetime.today()` used

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usage of datetime.datetime.utcnow(). DTZ003

Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ003
Message
`datetime.datetime.utcnow()` used

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usage of datetime.datetime.utcfromtimestamp(). DTZ004

Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ004
Message
`datetime.datetime.utcfromtimestamp()` used

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usages of datetime.datetime.now() that do not specify a timezone. DTZ005

Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ005
Message
`datetime.datetime.now()` called without a `tz` argument
Message
`tz=None` passed to `datetime.datetime.now()`

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usage of datetime.datetime.fromtimestamp() that do not specify a timezone. DTZ006

Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ006
Message
`datetime.datetime.fromtimestamp()` called without a `tz` argument
Message
`tz=None` passed to `datetime.datetime.fromtimestamp()`

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for uses of datetime.datetime.strptime() that lead to naive datetime objects. DTZ007

Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ007
Message
Naive datetime constructed using `datetime.datetime.strptime()` without %z
Message
`datetime.datetime.strptime(...).replace(tz=None)` used

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usage of datetime.date.today(). DTZ011

Python date objects are naive, that is, not timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ011
Message
`datetime.date.today()` used

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for usage of datetime.date.fromtimestamp(). DTZ012

Python date objects are naive, that is, not timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other datetime objects. Since this can lead to errors, it is recommended to always use timezone-aware objects. Ruff takes this rule from flake8-datetimez and made it stable in v0.0.188.

Code
DTZ012
Message
`datetime.date.fromtimestamp()` used

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for over-indented code. E117

According to PEP 8, 4 spaces per indentation level should be preferred. Increased indentation can lead to inconsistent formatting, which can hurt readability. Ruff takes this rule from pycodestyle. It is in preview.

Code
E117
Message
Over-indented (comment)
Message
Over-indented

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Checks for lines that exceed the specified maximum character length. E501

Overlong lines can hurt readability. PEP 8, for example, recommends limiting lines to 79 characters. By default, this rule enforces a limit of 88 characters for compatibility with Black and the Ruff formatter, though that limit is configurable via the line-length setting. Ruff takes this rule from pycodestyle and made it stable in v0.0.18.

Code
E501
Message
Line too long ({} > {})

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.

Using variable … before assignment. E0601

Emitted when a local variable is accessed before its assignment took place. Assignments in try blocks are assumed not to have occurred when evaluating associated except/finally blocks. Assignments in except blocks are assumed not to have occurred when evaluating statements outside the block, except when the associated try block contains a return statement. pylint calls it used-before-assignment.

Code
E0601
Severity
error
Message
Using variable {} before assignment

Source: github.com, pylint.readthedocs.io. JSON record. This entry is a card. Help write this page.

The raise statement is not inside an except clause. E0704

Used when a bare raise is not used inside an except clause. This generates an error, since there are no active exceptions to be reraised. An exception to this rule is represented by a bare raise inside a finally clause, which might work, as long as an exception is raised inside the try block, but it is nevertheless a code smell that must not be relied upon. pylint calls it misplaced-bare-raise.

Code
E0704
Severity
error
Message
The raise statement is not inside an except clause

Source: github.com, pylint.readthedocs.io. JSON record. This entry is a card. Help write this page.

Checks for equality comparisons to boolean literals. E712

PEP 8 recommends against using the equality operators == and != to compare values to True or False. Ruff takes this rule from pycodestyle and made it stable in v0.0.28.

Code
E712
Message
Avoid equality comparisons to `True`; use `{}:` for truth checks
Message
Avoid inequality comparisons to `True`; use `not {}:` for false checks
Message
Avoid equality comparisons to `False`; use `not {}:` for false checks
Message
Avoid inequality comparisons to `False`; use `{}:` for truth checks

Source: docs.astral.sh. JSON record. This entry is a card. Help write this page.