Python lints, page 8 of 8
The lint rules of Python, with what each one finds. This page has 1,420 cards.
Nested calls min(1, min(2, 3)) can be rewritten as min(1, 2, 3). pylint calls it nested-min-max.
- Code
W3301- Severity
- warning
- Message
Do not use nested call of '{}'; it's possible to do '{}' instead
Used when there is a chained comparison where one expression is part of two comparisons that belong to different semantic groups ("<" does not mean the same thing as "is", chaining them in "0 < x is None" is probably a mistake). pylint calls it bad-chained-comparison.
- Code
W3601- Severity
- warning
- Message
Suspicious {}-part chained comparison using semantically incompatible operators ({})
Emitted when items are added or removed to a list being iterated through. Doing so can result in unexpected behaviour, that is why it is preferred to use a copy of the list. pylint calls it modified-iterating-list.
- Code
W4701- Severity
- warning
- Message
Iterated list '{}' is being modified inside for loop body, consider iterating through a copy of it instead.
Used when an iterator defined in an outer loop scope is consumed in a nested loop. Because iterators are stateful and exhausted upon consumption, the inner loop will fully consume the iterator during the first iteration of the outer loop, leaving it empty for all subsequent iterations. pylint calls it looping-through-iterator.
- Code
W4801- Severity
- warning
- Message
Iterator '{}' from an outer scope is reused or consumed in a nested loop.
A module marked as deprecated is imported. pylint calls it deprecated-module.
- Code
W4901- Severity
- warning
- Message
Deprecated module {}
The method is marked as deprecated and will be removed in the future. pylint calls it deprecated-method.
- Code
W4902- Severity
- warning
- Message
Using deprecated method {}()
The argument is marked as deprecated and will be removed in the future. pylint calls it deprecated-argument.
- Code
W4903- Severity
- warning
- Message
Using deprecated argument {} of method {}()
The class is marked as deprecated and will be removed in the future. pylint calls it deprecated-class.
- Code
W4904- Severity
- warning
- Message
Using deprecated class {} of module {}
The decorator is marked as deprecated and will be removed in the future. pylint calls it deprecated-decorator.
- Code
W4905- Severity
- warning
- Message
Using deprecated decorator {}()
The attribute is marked as deprecated and will be removed in the future. pylint calls it deprecated-attribute.
- Code
W4906- Severity
- warning
- Message
Using deprecated attribute {}
If the current major or minor version consists of multiple digits, sys.version:3 will truncate the version number (e.g., "3.10" would become "3.1"). This is likely unintended, and can lead to subtle bugs if the version string is used to test against a specific Python version. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT101- Message
`sys.version[:3]` referenced (python3.10), use `sys.version_info`
If the current major or minor version consists of multiple digits, sys.version2 will select the first digit of the minor number only (e.g., "3.10" would evaluate to "1"). This is likely unintended, and can lead to subtle bugs if the version is used to test against a minor version number. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT102- Message
`sys.version[2]` referenced (python3.10), use `sys.version_info`
Comparing sys.version to a string is error-prone and may cause subtle bugs, as the comparison will be performed lexicographically, not semantically. For example, sys.version > "3.9" will evaluate to False when using Python 3.10, as "3.10" is lexicographically "less" than "3.9". Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT103- Message
`sys.version` compared to string (python3.10), use `sys.version_info`
Using sys.version_info0 == 3 to verify that the major version is Python 3 or greater will fail if the major version number is ever incremented (e.g., to Python 4). This is likely unintended, as code that uses this comparison is likely intended to be run on Python 2, but would now run on Python 4 too. Similarly, using sys.version_info0 != 3 to check for Python 2 will also fail if the major version number is incremented. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT201- Message
`sys.version_info[0] == 3` referenced (python4), use `>=`- Message
`sys.version_info[0] != 3` referenced (python4), use `<`
six.PY3 will evaluate to False on Python 4 and greater. This is likely unintended, and may cause code intended to run on Python 2 to run on Python 4 too. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT202- Message
`six.PY3` referenced (python4), use `not six.PY2`
Comparisons based on the current minor version number alone can cause subtle bugs and would likely lead to unintended effects if the Python major version number were ever incremented (e.g., to Python 4). Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT203- Message
`sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple
Comparisons based on the current minor version number alone can cause subtle bugs and would likely lead to unintended effects if the Python major version number were ever incremented (e.g., to Python 4). Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT204- Message
`sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple
If the current major or minor version consists of multiple digits, sys.version0 will select the first digit of the major version number only (e.g., "10.2" would evaluate to "1"). This is likely unintended, and can lead to subtle bugs if the version string is used to test against a major version number. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT301- Message
`sys.version[0]` referenced (python10), use `sys.version_info`
Comparing sys.version to a string is error-prone and may cause subtle bugs, as the comparison will be performed lexicographically, not semantically. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT302- Message
`sys.version` compared to string (python10), use `sys.version_info`
If the major version number consists of more than one digit, this will select the first digit of the major version number only (e.g., "10.0" would evaluate to "1"). This is likely unintended, and can lead to subtle bugs in future versions of Python if the version string is used to test against a specific major version number. Ruff takes this rule from flake8-2020 and made it stable in v0.0.113.
- Code
YTT303- Message
`sys.version[:1]` referenced (python10), use `sys.version_info`