logging.exception logs the exception and the traceback, while logging.error only logs the exception. The former is more appropriate when logging an exception, as the traceback is often useful for debugging. Ruff takes this rule from tryceratops and made it stable in v0.0.236.
- Code
TRY400- Message
Use `logging.exception` instead of `logging.error`
When logging exceptions via logging.exception, the exception object is logged automatically. Including the exception object in the log message is redundant and can lead to excessive logging. Ruff takes this rule from tryceratops and made it stable in v0.0.250.
- Code
TRY401- Message
Redundant exception object included in `logging.exception` call
Mypy always allows instantiating (calling) type objects typed as type[t], even if it is not known that t is non-abstract, since it is a common pattern to create functions that act as object factories (custom constructors). Therefore, to prevent issues described in the above section, when an abstract type object is passed where type[t] is expected, mypy will give an error. mypy enables this error code by default.
- Code
type-abstract- Severity
- error
If you use --disallow-any-generics, mypy requires that each generic type has values for each type argument. For example, the types list or dict would be rejected. mypy does not enable this error code by default. Use --enable-error-code type-arg to enable it.
- Code
type-arg- Severity
- error
Mypy checks that value of a type variable is compatible with a value restriction or the upper bound type. mypy enables this error code by default.
- Code
type-var- Severity
- error
When constructing a TypedDict object, mypy checks that each key and value is compatible with the TypedDict type that is inferred from the surrounding context. mypy enables this error code by default.
- Code
typeddict-item- Severity
- error
mypy enables this error code by default.
- Code
typeddict-readonly-mutated- Severity
- error
When constructing a TypedDict object, mypy checks whether the definition contains unknown keys, to catch invalid keys and misspellings. On the other hand, mypy will not generate an error when a previously constructed TypedDict value with extra keys is passed to a function as an argument, since TypedDict values support structural subtyping ("static duck typing") and the keys are assumed to have been validated at the point of construction. mypy enables this error code by default.
- Code
typeddict-unknown-key- Severity
- error
Mypy used to have reveal_type as a special builtin that only existed during type-checking. In runtime it fails with expected NameError, which can cause real problem in production, hidden from mypy. mypy does not enable this error code by default. Use --enable-error-code unimported-reveal to enable it.
- Code
unimported-reveal- Severity
- error
If you access the attribute of a value with a union type, mypy checks that the attribute is defined for *every* type in that union. Otherwise the operation can fail at runtime. mypy enables this error code by default.
- Code
union-attr- Severity
- error
If you use --warn-unreachable, mypy generates an error if it thinks that a statement or expression will never be executed. In most cases, this is due to incorrect control flow or conditional checks that are accidentally always true or false. mypy does not enable this error code by default. Use --enable-error-code unreachable to enable it.
- Code
unreachable- Severity
- error
If enabled with --disallow-untyped-decorators mypy generates an error if a typed function is wrapped by an untyped decorator (as this would effectively remove the benefits of typing the function). mypy does not enable this error code by default. Use --enable-error-code untyped-decorator to enable it.
- Code
untyped-decorator- Severity
- error
If you use --enable-error-code unused-awaitable, mypy generates an error if you don't use a returned value that defines __await__. mypy does not enable this error code by default. Use --enable-error-code unused-awaitable to enable it.
- Code
unused-awaitable- Severity
- error
Mypy ensures that return values of async def functions are not ignored, as this is usually a programming error, as the coroutine won't be executed at the call site. mypy enables this error code by default.
- Code
unused-coroutine- Severity
- error
If you use --enable-error-code unused-ignore, or --warn-unused-ignores mypy generates an error if you don't use a # type: ignore comment, i.e. if there is a comment, but there would be no error generated by mypy on this line anyway. mypy does not enable this error code by default. Use --enable-error-code unused-ignore to enable it.
- Code
unused-ignore- Severity
- error
Since Python 3, __metaclass__ = type is implied and can thus be omitted. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP001- Message
`__metaclass__ = type` is implied
type() returns the type of a given object. A type of a primitive can always be known in advance and accessed directly, which is more concise and explicit than using type(). Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP003- Message
Use `{}` instead of `type(...)`
Since Python 3, all classes inherit from object by default, so object can be omitted from the list of base classes. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP004- Message
Class `{}` inherits from `object`
The unittest module has deprecated aliases for some of its methods. The deprecated aliases were removed in Python 3.12. Instead of aliases, use their non-deprecated counterparts. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP005- Message
`{}` is deprecated, use `{}`
PEP 585 enabled collections in the Python standard library (like list) to be used as generics directly, instead of importing analogous members from the typing module (like typing.List). Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP006- Message
Use `{}` instead of `{}` for type annotation
PEP 604 introduced a new syntax for union type annotations based on the | operator. This syntax is more concise and readable than the previous typing.Union and typing.Optional syntaxes. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP007- Message
Use `X | Y` for type annotations
In Python 3, super can be invoked without any arguments when: (1) the first argument is __class__, and (2) the second argument is equivalent to the first argument of the enclosing method. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP008- Message
Use `super()` instead of `super(__class__, self)`
PEP 3120 makes UTF-8 the default encoding, so a UTF-8 encoding declaration is unnecessary. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP009- Message
UTF-8 encoding declaration is unnecessary
The __future__ module is used to enable features that are not yet available in the current Python version. If a feature is already available in the minimum supported Python version, importing it from __future__ is unnecessary and should be removed to avoid confusion. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP010- Message
Unnecessary `__future__` import `{}` for target Python version- Message
Unnecessary `__future__` imports {} for target Python version
Since Python 3.8, functools.lru_cache can be used as a decorator without trailing parentheses, as long as no arguments are passed to it. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP011- Message
Unnecessary parentheses to `functools.lru_cache`
UTF-8 is the default encoding in Python, so there is no need to call encode when UTF-8 is the desired encoding. Instead, use a bytes literal. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP012- Message
Unnecessary call to `encode` as UTF-8- Message
Unnecessary UTF-8 `encoding` argument to `encode`
TypedDict types can be defined either through a functional syntax (Foo = TypedDict(...)) or a class syntax (class Foo(TypedDict): ...). Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP013- Message
Convert `{}` from `TypedDict` functional to class syntax
NamedTuple subclasses can be defined either through a functional syntax (Foo = NamedTuple(...)) or a class syntax (class Foo(NamedTuple): ...). Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP014- Message
Convert `{}` from `NamedTuple` functional to class syntax
Redundant open mode arguments are unnecessary and should be removed to avoid confusion. Ruff takes this rule from pyupgrade and made it stable in v0.0.155.
- Code
UP015- Message
Unnecessary mode argument- Message
Unnecessary modes, use `{}`
As of Python 3.11, datetime.UTC is an alias for datetime.timezone.utc. The alias is more readable and generally preferred over the full path. Ruff takes this rule from pyupgrade and made it stable in v0.0.192.
- Code
UP017- Message
Use `datetime.UTC` alias
The mentioned constructors can be replaced with their respective literal forms, which are more readable and idiomatic. Ruff takes this rule from pyupgrade and made it stable in v0.0.193.
- Code
UP018- Message
Unnecessary `{}` call (rewrite as a literal)
typing.Text is an alias for str, and only exists for Python 2 compatibility. As of Python 3.11, typing.Text is deprecated. Use str instead. Ruff takes this rule from pyupgrade and made it stable in v0.0.195.
- Code
UP019- Message
`{}.Text` is deprecated, use `str`
In Python 3, io.open is an alias for open. Prefer using open directly, as it is more idiomatic. Ruff takes this rule from pyupgrade and made it stable in v0.0.196.
- Code
UP020- Message
Use builtin `open`
As of Python 3.7, the universal_newlines keyword argument has been renamed to text, and now exists for backwards compatibility. The universal_newlines keyword argument may be removed in a future version of Python. Prefer text, which is more explicit and readable. Ruff takes this rule from pyupgrade and made it stable in v0.0.196.
- Code
UP021- Message
`universal_newlines` is deprecated, use `text`
As of Python 3.7, subprocess.run has a capture_output keyword argument that can be set to True to capture stdout and stderr outputs. This is equivalent to setting stdout and stderr to subprocess.PIPE, but is more explicit and readable. Ruff takes this rule from pyupgrade and made it stable in v0.0.199.
- Code
UP022- Message
Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE`
In Python 3.3, xml.etree.cElementTree was deprecated in favor of xml.etree.ElementTree. Ruff takes this rule from pyupgrade and made it stable in v0.0.199.
- Code
UP023- Message
`cElementTree` is deprecated, use `ElementTree`
OSError is the builtin error type used for exceptions that relate to the operating system. Ruff takes this rule from pyupgrade and made it stable in v0.0.206.
- Code
UP024- Message
Replace aliased errors with `OSError`
In Python 3, all strings are Unicode by default. The Unicode kind prefix is unnecessary and should be removed to avoid confusion. Ruff takes this rule from pyupgrade and made it stable in v0.0.201.
- Code
UP025- Message
Remove unicode literals from strings
Since Python 3.3, mock has been a part of the standard library as unittest.mock. The mock package is deprecated; use unittest.mock instead. Ruff takes this rule from pyupgrade and made it stable in v0.0.206.
- Code
UP026- Message
`mock` is deprecated, use `unittest.mock`
There is no reason to use a list comprehension if the result is immediately unpacked. Instead, use a generator expression, which avoids allocating an intermediary list. Ruff takes this rule from pyupgrade, and removed it.
- Code
UP027- Message
Replace unpacked list comprehension with a generator expression
If a for loop only contains a yield statement, it can be replaced with a yield from expression, which is more concise and idiomatic. Ruff takes this rule from pyupgrade and made it stable in v0.0.210.
- Code
UP028- Message
Replace `yield` over `for` loop with `yield from`
These shims existed to access Python 3 builtins from code that also ran on Python 2. On Python 3-only code, the imports are redundant. Ruff takes this rule from pyupgrade and made it stable in v0.0.211.
- Code
UP029- Message
Unnecessary builtin import: `{}`- Message
Unnecessary builtin imports: {}
In Python 3.1 and later, format strings can use implicit positional references. For example, "{0}, {1}".format("Hello", "World") can be rewritten as "{}, {}".format("Hello", "World"). Ruff takes this rule from pyupgrade and made it stable in v0.0.218.
- Code
UP030- Message
Use implicit references for positional format fields
printf-style string formatting has a number of quirks, and leads to less readable code than using str.format calls or f-strings. In general, prefer the newer str.format and f-strings constructs over printf-style string formatting. Ruff takes this rule from pyupgrade and made it stable in v0.0.229.
- Code
UP031- Message
Use format specifiers instead of percent format
f-strings are more readable and generally preferred over str.format calls. Ruff takes this rule from pyupgrade and made it stable in v0.0.224.
- Code
UP032- Message
Use f-string instead of `format` call
Since Python 3.9, functools.cache can be used as a drop-in replacement for functools.lru_cache(maxsize=None). When possible, prefer functools.cache as it is more readable and idiomatic. Ruff takes this rule from pyupgrade and made it stable in v0.0.225.
- Code
UP033- Message
Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)`
Extraneous parentheses are redundant, and can be removed to improve readability while retaining identical semantics. Ruff takes this rule from pyupgrade and made it stable in v0.0.228.
- Code
UP034- Message
Avoid extraneous parentheses
Deprecated imports may be removed in future versions of Python, and should be replaced with their new equivalents. Ruff takes this rule from pyupgrade and made it stable in v0.0.239.
- Code
UP035- Message
Import from `{}` instead: {}- Message
`{}.{}` is deprecated, use `{}` instead
In Python, code can be conditionally executed based on the active Python version by comparing against the sys.version_info tuple. Ruff takes this rule from pyupgrade and made it stable in v0.0.240.
- Code
UP036- Message
Version block is outdated for minimum Python version- Message
Version specifier is invalid
In Python, type annotations can be quoted to avoid forward references. Ruff takes this rule from pyupgrade and made it stable in v0.0.242.
- Code
UP037- Message
Remove quotes from type annotation
Since Python 3.10, isinstance and issubclass can be passed a |-separated union of types, which is consistent with the union operator introduced in PEP 604. Ruff takes this rule from pyupgrade, and removed it.
- Code
UP038- Message
Use `X | Y` in `{}` call instead of `(X, Y)`
If a class definition doesn't have any bases, the parentheses are unnecessary. Ruff takes this rule from pyupgrade and made it stable in v0.0.273.
- Code
UP039- Message
Unnecessary parentheses after class definition
The type keyword was introduced in Python 3.12 by PEP 695 for defining type aliases. The type keyword is easier to read and provides cleaner support for generics. Ruff takes this rule from pyupgrade and made it stable in v0.0.283.
- Code
UP040- Message
Type alias `{}` uses {} instead of the `type` keyword
TimeoutError is the builtin error type used for exceptions when a system function timed out at the system level. Ruff takes this rule from pyupgrade and made it stable in v0.2.0.
- Code
UP041- Message
Replace aliased errors with `TimeoutError`
Python 3.11 introduced enum.StrEnum, which is preferred over inheriting from both str and enum.Enum. Ruff takes this rule from pyupgrade and made it stable in 0.15.0.
- Code
UP042- Message
Class {} inherits from both `str` and `enum.Enum`
Python 3.13 introduced the ability for type parameters to specify default values. Following this change, several standard-library classes were updated to add default values for some of their type parameters. For example, Generatorint is now equivalent to Generatorint, None, None, as the second and third type parameters of Generator now default to None. Ruff takes this rule from pyupgrade and made it stable in 0.8.0.
- Code
UP043- Message
Unnecessary default type arguments
PEP 646 introduced a new syntax for unpacking sequences based on the * operator. This syntax is more concise and readable than the previous Unpack[] syntax. Ruff takes this rule from pyupgrade and made it stable in 0.10.0.
- Code
UP044- Message
Use `*` for unpacking
PEP 604 introduced a new syntax for union type annotations based on the | operator. This syntax is more concise and readable than the previous typing.Optional syntax. Ruff takes this rule from pyupgrade and made it stable in 0.12.0.
- Code
UP045- Message
Use `X | None` for type annotations
Special type parameter syntax was introduced in Python 3.12 by PEP 695 for defining generic classes. This syntax is easier to read and provides cleaner support for generics. Ruff takes this rule from pyupgrade and made it stable in 0.12.0.
- Code
UP046- Message
Generic class `{}` uses `Generic` subclass instead of type parameters
Special type parameter syntax was introduced in Python 3.12 by PEP 695 for defining generic functions. This syntax is easier to read and provides cleaner support for generics. Ruff takes this rule from pyupgrade and made it stable in 0.12.0.
- Code
UP047- Message
Generic function `{}` should use type parameters
while 1: is a Python 2 idiom, where True was a global that could be rebound and so had to be loaded and tested on every iteration. In Python 3 True is a keyword, so both spellings compile to the same bytecode and while True: is clearer about the loop being infinite. Ruff takes this rule from pyupgrade. It is in preview.
- Code
UP048- Message
Use `while True:` instead of `while 1:`
PEP 695 type parameters are already restricted in scope to the class or function in which they appear, so leading underscores just hurt readability without the usual privacy benefits. Ruff takes this rule from pyupgrade and made it stable in 0.12.0.
- Code
UP049- Message
Generic {} uses private type parameters
Since Python 3, the default metaclass is type, so specifying it explicitly is redundant. Ruff takes this rule from pyupgrade and made it stable in 0.13.0.
- Code
UP050- Message
Class `{}` uses `metaclass=type`, which is redundant
These have been deprecated since Python 3.3 and are expected to be removed in a future version of Python. Ruff takes this rule from pyupgrade. It is in preview.
- Code
UP051- Message
Use `@{}` and `@abstractmethod` instead of `{}`
Mypy will generate an error if a name is used before it's defined. While the name-defined check will catch issues with names that are undefined, it will not flag if a variable is used and then defined later in the scope. used-before-def check will catch such cases. mypy enables this error code by default.
- Code
used-before-def- Severity
- error
The target of a :pytyping.NewType definition must be a class type. It can't be a union type, Any, or various other special types. mypy enables this error code by default.
- Code
valid-newtype- Severity
- error
Mypy checks that each type annotation and any expression that represents a type is a valid type. Examples of valid types include classes, union types, callable types, type aliases, and literal types. mypy enables this error code by default.
- Code
valid-type- Severity
- error
In some cases mypy can't infer the type of a variable without an explicit annotation. Mypy treats this as an error. mypy enables this error code by default.
- Code
var-annotated- Severity
- error
Used when there is some code behind a "return" or "raise" statement, which will never be accessed. pylint calls it unreachable.
- Code
W0101- Severity
- warning
- Message
Unreachable code
Used when a mutable value as list or dictionary is detected in a default value for an argument. pylint calls it dangerous-default-value.
- Code
W0102- Severity
- warning
- Message
Dangerous default value {} as argument
Used when a statement doesn't have (or at least seems to) any effect. pylint calls it pointless-statement.
- Code
W0104- Severity
- warning
- Message
Statement seems to have no effect
Used when a string is used as a statement (which of course has no effect). This is a particular case of W0104 with its own message so you can easily disable it if you're using those strings as documentation, instead of comments. pylint calls it pointless-string-statement.
- Code
W0105- Severity
- warning
- Message
String statement has no effect
Used when an expression that is not a function call is assigned to nothing. Probably something else was intended. pylint calls it expression-not-assigned.
- Code
W0106- Severity
- warning
- Message
Expression "{}" is assigned to nothing
Used when a "pass" statement can be removed without affecting the behaviour of the code. pylint calls it unnecessary-pass.
- Code
W0107- Severity
- warning
- Message
Unnecessary pass statement
Used when the body of a lambda expression is a function call on the same argument list as the lambda itself; such lambda expressions are in all but a few cases replaceable with the function being called in the body of the lambda. pylint calls it unnecessary-lambda.
- Code
W0108- Severity
- warning
- Message
Lambda may not be necessary
Used when a dictionary expression binds the same key multiple times. pylint calls it duplicate-key.
- Code
W0109- Severity
- warning
- Message
Duplicate key {} in dictionary
Loops should only have an else clause if they can exit early with a break statement, otherwise the statements under else should be on the same scope as the loop itself. pylint calls it useless-else-on-loop.
- Code
W0120- Severity
- warning
- Message
Else clause on loop without a break statement, remove the else and de-indent all the code inside it
Raised when the 'exec' statement is used. It's dangerous to use this function for a user input, and it's also slower than actual code in general. This doesn't mean you should never use it, but you should consider alternatives first and restrict the functions available. pylint calls it exec-used.
- Code
W0122- Severity
- warning
- Message
Use of exec
Used when you use the "eval" function, to discourage its usage. Consider using ast.literal_eval for safely evaluating strings containing Python expressions from untrusted sources. pylint calls it eval-used.
- Code
W0123- Severity
- warning
- Message
Use of eval
Emitted when a with statement component returns multiple values and uses name binding with as only for a part of those values, as in with ctx() as a, b. This can be misleading, since it's not clear if the context manager returns a tuple or if the node without a name binding is another context manager. pylint calls it confusing-with-statement.
- Code
W0124- Severity
- warning
- Message
Following "as" with another context manager looks like a tuple.
Emitted when a conditional statement (If or ternary if) uses a constant value for its test. This might not be what the user intended to do. pylint calls it using-constant-test.
- Code
W0125- Severity
- warning
- Message
Using a conditional statement with a constant value
Emitted when a conditional statement (If or ternary if) seems to wrongly call a function due to missing parentheses. pylint calls it missing-parentheses-for-call-in-test.
- Code
W0126- Severity
- warning
- Message
Using a conditional statement with potentially wrong function or method call due to missing parentheses
Emitted when we detect that a variable is assigned to itself. pylint calls it self-assigning-variable.
- Code
W0127- Severity
- warning
- Message
Assigning the same variable {} to itself
Emitted when we detect that a variable was redeclared in the same assignment. pylint calls it redeclared-assigned-name.
- Code
W0128- Severity
- warning
- Message
Redeclared variable {} in assignment
Used when an assert statement has a string literal as its first argument, which will cause the assert to always pass. pylint calls it assert-on-string-literal.
- Code
W0129- Severity
- warning
- Message
Assert statement has a string literal as its first argument. The assert will {} fail.
This message is emitted when a set contains the same value two or more times. pylint calls it duplicate-value.
- Code
W0130- Severity
- warning
- Message
Duplicate value {} in set
Emitted if named expression is used to do a regular assignment outside a context like if, for, while, or a comprehension. pylint calls it named-expr-without-context.
- Code
W0131- Severity
- warning
- Message
Named expression used without context
Used when an exception is created without being assigned, raised or returned for subsequent use elsewhere. pylint calls it pointless-exception-statement.
- Code
W0133- Severity
- warning
- Message
Exception statement has no effect
Emitted when a 'return' statement is found in a 'finally' block. This will overwrite the return value of a function and should be avoided. pylint calls it return-in-finally.
- Code
W0134- Severity
- warning
- Message
'return' shadowed by the 'finally' clause.
Used when a contextmanager is used inside a generator function and the cleanup is not handled. pylint calls it contextmanager-generator-missing-cleanup.
- Code
W0135- Severity
- warning
- Message
The context used in function {} will not be exited.
Emitted when the continue keyword is found inside a finally clause. This will raise a SyntaxWarning starting in Python 3.14. pylint calls it continue-in-finally.
- Code
W0136- Severity
- warning
- Message
'continue' discouraged inside 'finally' clause
Emitted when the break keyword is found inside a finally clause. This will raise a SyntaxWarning starting in Python 3.14. pylint calls it break-in-finally.
- Code
W0137- Severity
- warning
- Message
'break' discouraged inside 'finally' clause
This message is emitted when pylint detects that a comparison with a callable was made, which might suggest that some parenthesis were omitted, resulting in potential unwanted behaviour. pylint calls it comparison-with-callable.
- Code
W0143- Severity
- warning
- Message
Comparing against a callable, did you omit the parenthesis?
Used when a break or a return statement is found inside the finally clause of a try...finally block: the exceptions raised in the try clause will be silently swallowed instead of being re-raised. pylint calls it lost-exception.
- Code
W0150- Severity
- warning
- Message
{} statement in finally block may swallow exception
Used when an expression is compared to NaN values like math.nan, numpy.nan or float('nan'). pylint calls it nan-comparison.
- Code
W0177- Severity
- warning
- Message
Comparison {} should be {}
According to PEP 8, spaces are preferred over tabs (unless used to remain consistent with code that is already indented with tabs). Ruff takes this rule from pycodestyle and made it stable in v0.0.254.
- Code
W191- Message
Indentation contains tabs
A call of assert on a tuple will always evaluate to true if the tuple is not empty, and will always evaluate to false if it is. pylint calls it assert-on-tuple.
- Code
W0199- Severity
- warning
- Message
Assert called on a populated tuple. Did you mean 'assert x,y'?
Used when an instance attribute is defined outside the __init__ method. pylint calls it attribute-defined-outside-init.
- Code
W0201- Severity
- warning
- Message
Attribute {} defined outside __init__
Used when a static method has "self" or a value specified in valid-classmethod-first-arg option or valid-metaclass-classmethod-first-arg option as first argument. pylint calls it bad-staticmethod-argument.
- Code
W0211- Severity
- warning
- Message
Static method with {} as first argument
Used when a protected member (i.e. class member with a name beginning with an underscore) is accessed outside the class or a descendant of the class where it's defined. pylint calls it protected-access.
- Code
W0212- Severity
- warning
- Message
Access to a protected member {} of a client class
Used when multiple integer values declared within an enum.IntFlag class share a common bit position. pylint calls it implicit-flag-alias.
- Code
W0213- Severity
- warning
- Message
Flag member {} shares bit positions with {}
Used when a method has a different number of arguments than in the implemented interface or in an overridden method. Extra arguments with default values are ignored. pylint calls it arguments-differ.
- Code
W0221- Severity
- warning
- Message
{} {} {} method
Used when a method signature is different than in the implemented interface or in an overridden method. pylint calls it signature-differs.
- Code
W0222- Severity
- warning
- Message
Signature differs from {} {} method
Used when an abstract method (i.e. raise NotImplementedError) is not overridden in concrete class. pylint calls it abstract-method.
- Code
W0223- Severity
- warning
- Message
Method {} is abstract in class {} but is not overridden in child class {}
Used when an ancestor class method has an __init__ method which is not called by a derived class. pylint calls it super-init-not-called.
- Code
W0231- Severity
- warning
- Message
__init__ method from base class {} is not called
Used when an __init__ method is called on a class which is not in the direct ancestors for the analysed class. pylint calls it non-parent-init-called.
- Code
W0233- Severity
- warning
- Message
__init__ method from a non direct base class {} is called
Used when we detect that a method was overridden in a way that does not match its base class which could result in potential bugs at runtime. pylint calls it invalid-overridden-method.
- Code
W0236- Severity
- warning
- Message
Method {} was expected to be {}, found it instead as {}
Used when a method parameter has a different name than in the implemented interface or in an overridden method. pylint calls it arguments-renamed.
- Code
W0237- Severity
- warning
- Message
{} {} {} method
Emitted when a private member of a class is defined but not used. pylint calls it unused-private-member.
- Code
W0238- Severity
- warning
- Message
Unused private member `{}.{}`
Used when a method decorated with typing.final has been overridden. pylint calls it overridden-final-method.
- Code
W0239- Severity
- warning
- Message
Method {} overrides a method decorated with typing.final which is defined in class {}
Used when a class decorated with typing.final has been subclassed. pylint calls it subclassed-final-class.
- Code
W0240- Severity
- warning
- Message
Class {} is a subclass of a class decorated with typing.final: {}
Used when a slot is re-defined in a subclass. pylint calls it redefined-slots-in-subclass.
- Code
W0244- Severity
- warning
- Message
Redefined slots {} in subclass
Used when a call to super does not have brackets and thus is not an actual call and does not work as expected. pylint calls it super-without-brackets.
- Code
W0245- Severity
- warning
- Message
Super call without brackets
Used whenever we can detect that an overridden method is useless, relying on parent or super() delegation to do the same thing as another method from the MRO. pylint calls it useless-parent-delegation.
- Code
W0246- Severity
- warning
- Message
Useless parent or super() delegation in method {}
According to PEP 8, "avoid trailing whitespace anywhere. Because it’s usually invisible, it can be confusing" Ruff takes this rule from pycodestyle and made it stable in v0.0.253.
- Code
W291- Message
Trailing whitespace
Trailing blank lines in a file are superfluous. Ruff takes this rule from pycodestyle and made it stable in v0.0.61.
- Code
W292- Message
No newline at end of file
According to PEP 8, "avoid trailing whitespace anywhere. Because it’s usually invisible, it can be confusing" Ruff takes this rule from pycodestyle and made it stable in v0.0.253.
- Code
W293- Message
Blank line contains whitespace
Used when a statement is ended by a semi-colon (";"), which isn't necessary (that's python, not C ;). pylint calls it unnecessary-semicolon.
- Code
W0301- Severity
- warning
- Message
Unnecessary semicolon
Used when an unexpected number of indentation's tabulations or spaces has been found. pylint calls it bad-indentation.
- Code
W0311- Severity
- warning
- Message
Bad indentation. Found {} {}, expected {}
Trailing blank lines in a file are superfluous. Ruff takes this rule from pycodestyle. It is in preview.
- Code
W391- Message
Too many newlines at end of {}- Message
Extra newline at end of {}
Used when from module import * is detected. pylint calls it wildcard-import.
- Code
W0401- Severity
- warning
- Message
Wildcard import {}
Used when a module is imported more than once. pylint calls it reimported.
- Code
W0404- Severity
- warning
- Message
Reimport {} (imported line {})
Used when a module is importing itself. pylint calls it import-self.
- Code
W0406- Severity
- warning
- Message
Module import itself
Used when a module imported has a preferred replacement module. pylint calls it preferred-module.
- Code
W0407- Severity
- warning
- Message
Prefer importing {} instead of {}
Python 2.5 and greater require __future__ import to be the first non docstring statement in the module. pylint calls it misplaced-future.
- Code
W0410- Severity
- warning
- Message
__future__ import is not the first non docstring statement
Used when a module is aliased with a name that shadows another import. pylint calls it shadowed-import.
- Code
W0416- Severity
- warning
- Message
Shadowed {} (imported line {})
For flowing long blocks of text (docstrings or comments), overlong lines can hurt readability. PEP 8, for example, recommends that such lines be limited to 72 characters, while this rule enforces the limit specified by the lint.pycodestyle.max-doc-length setting. (If no value is provided, this rule will be ignored, even if it's added to your --select list.) Ruff takes this rule from pycodestyle and made it stable in v0.0.219.
- Code
W505- Message
Doc line too long ({} > {})
Used when a variable is defined through the "global" statement but the variable is not defined in the module scope. pylint calls it global-variable-undefined.
- Code
W0601- Severity
- warning
- Message
Global variable {} undefined at the module level
When a variable defined in the global scope is modified in an inner scope, the 'global' keyword is required in the inner scope only if there is an assignment operation done in the inner scope. pylint calls it global-variable-not-assigned.
- Code
W0602- Severity
- warning
- Message
Using global for {} but no assignment is done
Used when you use the "global" statement to update a global variable. Pylint discourages its usage. That doesn't mean you cannot use it!. pylint calls it global-statement.
- Code
W0603- Severity
- warning
- Message
Using the global statement
Used when you use the "global" statement at the module level since it has no effect. pylint calls it global-at-module-level.
- Code
W0604- Severity
- warning
- Message
Using the global statement at the module level
Invalid escape sequences are deprecated in Python 3.6. Ruff takes this rule from pycodestyle and made it stable in v0.0.85.
- Code
W605- Message
Invalid escape sequence: `\{}`
Used when an imported module or variable is not used. pylint calls it unused-import.
- Code
W0611- Severity
- warning
- Message
Unused {}
Used when a variable is defined but not used. pylint calls it unused-variable.
- Code
W0612- Severity
- warning
- Message
Unused variable {}
Used when a function or method argument is not used. pylint calls it unused-argument.
- Code
W0613- Severity
- warning
- Message
Unused argument {}
Used when an imported module or variable is not used from a 'from X import *' style import. pylint calls it unused-wildcard-import.
- Code
W0614- Severity
- warning
- Message
Unused import(s) {} from wildcard import of {}
Used when a variable's name hides a name defined in an outer scope or except handler. pylint calls it redefined-outer-name.
- Code
W0621- Severity
- warning
- Message
Redefining name {} from outer scope (line {})
Used when a variable or function override a built-in. pylint calls it redefined-builtin.
- Code
W0622- Severity
- warning
- Message
Redefining built-in {}
Used when a loop variable (i.e. defined by a for loop or a list comprehension or a generator expression) is used outside the loop. pylint calls it undefined-loop-variable.
- Code
W0631- Severity
- warning
- Message
Using possibly undefined loop variable {}
Used when there is an unbalanced tuple unpacking in assignment. pylint calls it unbalanced-tuple-unpacking.
- Code
W0632- Severity
- warning
- Message
Possible unbalanced tuple unpacking with sequence {}: left side has {} label{}, right side has {} value{}
A variable used in a closure is defined in a loop. This will result in all closures using the same value for the closed-over variable. pylint calls it cell-var-from-loop.
- Code
W0640- Severity
- warning
- Message
Cell variable {} defined in loop
Used when a variable is defined but might not be used. The possibility comes from the fact that locals() might be used, which could consume or not the said variable. pylint calls it possibly-unused-variable.
- Code
W0641- Severity
- warning
- Message
Possibly unused variable {}
Invalid assignment to self or cls in instance or class method respectively. pylint calls it self-cls-assignment.
- Code
W0642- Severity
- warning
- Message
Invalid assignment to {} in method
Used when there is an unbalanced dict unpacking in assignment or for loop. pylint calls it unbalanced-dict-unpacking.
- Code
W0644- Severity
- warning
- Message
Possible unbalanced dict unpacking with {}: left side has {} label{}, right side has {} value{}
A bare except: clause will catch SystemExit and KeyboardInterrupt exceptions, making it harder to interrupt a program with Control-C, and can disguise other problems. If you want to catch all exceptions that signal program errors, use except Exception: (bare except is equivalent to except BaseException:). pylint calls it bare-except.
- Code
W0702- Severity
- warning
- Message
No exception type(s) specified
Used when an except catches a type that was already caught by a previous handler. pylint calls it duplicate-except.
- Code
W0705- Severity
- warning
- Message
Catching previously caught exception type {}
Used when an except handler uses raise as its first or only operator. This is useless because it raises back the exception immediately. Remove the raise operator or the entire try-except-raise block!. pylint calls it try-except-raise.
- Code
W0706- Severity
- warning
- Message
The except handler raises immediately
Python's exception chaining shows the traceback of the current exception, but also of the original exception. When you raise a new exception after another exception was caught it's likely that the second exception is a friendly re-wrapping of the first exception. In such cases raise from provides a better link between the two tracebacks in the final error. pylint calls it raise-missing-from.
- Code
W0707- Severity
- warning
- Message
Consider explicitly re-raising using {}'{} from {}'
Used when the exception to catch is of the form "except A or B:". If intending to catch multiple, rewrite as "except (A, B):". pylint calls it binary-op-exception.
- Code
W0711- Severity
- warning
- Message
Exception to catch is the result of a binary "{}" operation
Used when passing multiple arguments to an exception constructor, the first of them a string literal containing what appears to be placeholders intended for formatting. pylint calls it raising-format-tuple.
- Code
W0715- Severity
- warning
- Message
Exception arguments suggest string formatting might be intended
Used when an operation is done against an exception, but the operation is not valid for the exception in question. Usually emitted when having binary operations between exceptions in except handlers. pylint calls it wrong-exception-operation.
- Code
W0716- Severity
- warning
- Message
Invalid exception operation. {}
If you use a naked except Exception: clause, you might end up catching exceptions other than the ones you expect to catch. This can hide bugs or make it harder to debug programs when unrelated errors are hidden. pylint calls it broad-exception-caught.
- Code
W0718- Severity
- warning
- Message
Catching too general exception {}
Raising exceptions that are too generic force you to catch exceptions generically too. It will force you to use a naked except Exception: clause. You might then end up catching exceptions other than the ones you expect to catch. This can hide bugs or make it harder to debug programs when unrelated errors are hidden. pylint calls it broad-exception-raised.
- Code
W0719- Severity
- warning
- Message
Raising too general exception: {}
When defining a keyword argument before variable positional arguments, one can end up in having multiple values passed for the aforementioned parameter in case the method is called with keyword arguments. pylint calls it keyword-arg-before-vararg.
- Code
W1113- Severity
- warning
- Message
Keyword argument before variable positional arguments list in the definition of {} function
Emitted when the caller's argument names fully match the parameter names in the function signature but do not have the same order. pylint calls it arguments-out-of-order.
- Code
W1114- Severity
- warning
- Message
Positional arguments appear to be out of order
Emitted when a non-string value is assigned to __name__. pylint calls it non-str-assignment-to-dunder-name.
- Code
W1115- Severity
- warning
- Message
Non-string value assigned to __name__
Emitted when the second argument of an isinstance call is not a type. pylint calls it isinstance-second-argument-not-valid-type.
- Code
W1116- Severity
- warning
- Message
Second argument of isinstance is not a type
Emitted when a function is called with a keyword argument that has the same name as a positional-only parameter and the function contains a keyword variadic parameter dict. pylint calls it kwarg-superseded-by-positional-arg.
- Code
W1117- Severity
- warning
- Message
{} will be included in {} since a positional-only parameter with this name already exists
Used when a logging statement has a call form of "logging.<logging method>(format_string % (format_args...))". Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-fstring-interpolation is disabled then you can use fstring formatting. If logging-format-interpolation is disabled then you can use str.format. pylint calls it logging-not-lazy.
- Code
W1201- Severity
- warning
- Message
Use {} formatting in logging functions
Used when a logging statement has a call form of "logging.<logging method>(format_string.format(format_args...))". Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-fstring-interpolation is disabled then you can use fstring formatting. If logging-not-lazy is disabled then you can use % formatting as normal. pylint calls it logging-format-interpolation.
- Code
W1202- Severity
- warning
- Message
Use {} formatting in logging functions
Used when a logging statement has a call form of "logging.<logging method>(f"...")".Use another type of string formatting instead. You can use % formatting but leave interpolation to the logging function by passing the parameters as arguments. If logging-format-interpolation is disabled then you can use str.format. If logging-not-lazy is disabled then you can use % formatting as normal. pylint calls it logging-fstring-interpolation.
- Code
W1203- Severity
- warning
- Message
Use {} formatting in logging functions
Used when a format string that uses named conversion specifiers is used with a dictionary whose keys are not all strings. pylint calls it bad-format-string-key.
- Code
W1300- Severity
- warning
- Message
Format string dictionary key should be a string, not {}
Used when a format string that uses named conversion specifiers is used with a dictionary that contains keys not required by the format string. pylint calls it unused-format-string-key.
- Code
W1301- Severity
- warning
- Message
Unused key {} in format string dictionary
Used when a PEP 3101 format string is invalid. pylint calls it bad-format-string.
- Code
W1302- Severity
- warning
- Message
Invalid format string
Used when a PEP 3101 format string that uses named fields doesn't receive one or more required keywords. pylint calls it missing-format-argument-key.
- Code
W1303- Severity
- warning
- Message
Missing keyword argument {} for format string
Used when a PEP 3101 format string that uses named fields is used with an argument that is not required by the format string. pylint calls it unused-format-string-argument.
- Code
W1304- Severity
- warning
- Message
Unused format argument {}
Used when a PEP 3101 format string contains both automatic field numbering (e.g. '{}') and manual field specification (e.g. '{0}'). pylint calls it format-combined-specification.
- Code
W1305- Severity
- warning
- Message
Format string contains both automatic field numbering and manual field specification
Used when a PEP 3101 format string uses an attribute specifier ({0.length}), but the argument passed for formatting doesn't have that attribute. pylint calls it missing-format-attribute.
- Code
W1306- Severity
- warning
- Message
Missing format attribute {} in format specifier {}
Used when a PEP 3101 format string uses a lookup specifier ({a[1]}), but the argument passed for formatting doesn't contain or doesn't have that key as an attribute. pylint calls it invalid-format-index.
- Code
W1307- Severity
- warning
- Message
Using invalid lookup key {} in format specifier {}
Used when we detect that a string formatting is repeating an argument instead of using named string arguments. pylint calls it duplicate-string-formatting-argument.
- Code
W1308- Severity
- warning
- Message
Duplicate string formatting argument {}, consider passing as named argument
Used when we detect an f-string that does not use any interpolation variables, in which case it can be either a normal string or a bug in the code. pylint calls it f-string-without-interpolation.
- Code
W1309- Severity
- warning
- Message
Using an f-string that does not have any interpolated variables
Used when we detect a string that does not have any interpolation variables, in which case it can be either a normal string without formatting or a bug in the code. pylint calls it format-string-without-interpolation.
- Code
W1310- Severity
- warning
- Message
Using formatting for a string that does not have any interpolated variables
Used when a backslash is in a literal string but not as an escape. pylint calls it anomalous-backslash-in-string.
- Code
W1401- Severity
- warning
- Message
Anomalous backslash in string: '{}'. String constant might be missing an r prefix.
Used when an escape like \\u is encountered in a byte string where it has no effect. pylint calls it anomalous-unicode-escape-in-string.
- Code
W1402- Severity
- warning
- Message
Anomalous Unicode escape in byte string: '{}'. String constant might be missing an r or u prefix.
String literals are implicitly concatenated in a literal iterable definition : maybe a comma is missing ?. pylint calls it implicit-str-concat.
- Code
W1404- Severity
- warning
- Message
Implicit string concatenation found in {}
Quote delimiters are not used consistently throughout a module (with allowances made for avoiding unnecessary escaping). pylint calls it inconsistent-quotes.
- Code
W1405- Severity
- warning
- Message
Quote delimiter {} is inconsistent with the rest of the file
Used when we detect a string with a u prefix. These prefixes were necessary in Python 2 to indicate a string was Unicode, but since Python 3.0 strings are Unicode by default. pylint calls it redundant-u-string-prefix.
- Code
W1406- Severity
- warning
- Message
The u prefix for strings is no longer necessary in Python >=3.0
Python supports: r, w, a[, x] modes with b, +, and U (only with r) options. See https://docs.python.org/3/library/functions.html#open. pylint calls it bad-open-mode.
- Code
W1501- Severity
- warning
- Message
"{}" is not a valid mode for open.
Using datetime.time in a boolean context can hide subtle bugs when the time they represent matches midnight UTC. This behaviour was fixed in Python 3.5. See https://bugs.python.org/issue13936 for reference. This message can't be emitted when using Python >= 3.5. pylint calls it boolean-datetime.
- Code
W1502- Severity
- warning
- Message
Using datetime.time in a boolean context.
The first argument of assertTrue and assertFalse is a condition. If a constant is passed as parameter, that condition will be always true. In this case a warning should be emitted. The same applies to assertEqual and assertNotEqual when both compared values are constants. pylint calls it redundant-unittest-assert.
- Code
W1503- Severity
- warning
- Message
Redundant use of {} with constant value {}
The warning is emitted when a threading.Thread class is instantiated without the target function being passed as a kwarg or as a second argument. By default, the first parameter is the group param, not the target param. pylint calls it bad-thread-instantiation.
- Code
W1506- Severity
- warning
- Message
threading.Thread needs the target function
Os.environ is not a dict object but proxy object, so shallow copy has still effects on original object. See https://bugs.python.org/issue15373 for reference. pylint calls it shallow-copy-environ.
- Code
W1507- Severity
- warning
- Message
Using copy.copy(os.environ). Use os.environ.copy() instead.
Env manipulation functions return None or str values. Supplying anything different as a default may cause bugs. See https://docs.python.org/3/library/os.html#os.getenv. pylint calls it invalid-envvar-default.
- Code
W1508- Severity
- warning
- Message
{} default type is {}. Expected str or None.
The preexec_fn parameter is not safe to use in the presence of threads in your application. The child process could deadlock before exec is called. If you must use it, keep it trivial! Minimize the number of libraries you call into. See https://docs.python.org/3/library/subprocess.html#popen-constructor. pylint calls it subprocess-popen-preexec-fn.
- Code
W1509- Severity
- warning
- Message
Using preexec_fn keyword which may be unsafe in the presence of threads
The check keyword is set to False by default. It means the process launched by subprocess.run can exit with a non-zero exit code and fail silently. It's better to set it explicitly to make clear what the error-handling behavior is. pylint calls it subprocess-run-check.
- Code
W1510- Severity
- warning
- Message
'subprocess.run' used without explicitly defining the value for 'check'.
It is better to specify an encoding when opening documents. Using the system default implicitly can create problems on other operating systems. See https://peps.python.org/pep-0597/ This message can't be emitted when using Python >= 3.15. pylint calls it unspecified-encoding.
- Code
W1514- Severity
- warning
- Message
Using open without explicitly specifying an encoding
Calls to breakpoint(), sys.breakpointhook() and pdb.set_trace() should be removed from code that is not actively being debugged. pylint calls it forgotten-debug-statement.
- Code
W1515- Severity
- warning
- Message
Leaving functions creating breakpoints in production code is not recommended
By decorating a method with lru_cache or cache the 'self' argument will be linked to the function and therefore never garbage collected. Unless your instance will never need to be garbage collected (singleton) it is recommended to refactor code to avoid this pattern or add a maxsize to the cache. The default value for maxsize is 128. pylint calls it method-cache-max-size-none.
- Code
W1518- Severity
- warning
- Message
'lru_cache(maxsize=None)' or 'cache' will keep all method args alive indefinitely, including 'self'
Used when a new lock instance is created by using with statement which has no effect. Instead, an existing instance should be used to acquire lock. pylint calls it useless-with-lock.
- Code
W2101- Severity
- warning
- Message
'{}()' directly created in 'with' has no effect
Used when the ellipsis constant is encountered and can be avoided. A line of code consisting of an ellipsis is unnecessary if there is a docstring on the preceding line or if there is a statement in the same scope. pylint calls it unnecessary-ellipsis.
- Code
W2301- Severity
- warning
- Message
Unnecessary ellipsis constant
Under python 3.5, PEP 3131 allows non-ascii identifiers, but not non-ascii file names.Since Python 3.5, even though Python supports UTF-8 files, some editors or tools don't. pylint calls it non-ascii-file-name.
- Code
W2402- Severity
- warning
- Message
{} name "{}" contains a non-ASCII character.
Used when the py-version set by the user is lower than 3.6 and pylint encounters an f-string. pylint calls it using-f-string-in-unsupported-version.
- Code
W2601- Severity
- warning
- Message
F-strings are not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.8 and pylint encounters a typing.final decorator. pylint calls it using-final-decorator-in-unsupported-version.
- Code
W2602- Severity
- warning
- Message
typing.final is not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.11 and pylint encounters except* or ExceptionGroup. pylint calls it using-exception-groups-in-unsupported-version.
- Code
W2603- Severity
- warning
- Message
Exception groups are not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.12 and pylint encounters generic type syntax. pylint calls it using-generic-type-syntax-in-unsupported-version.
- Code
W2604- Severity
- warning
- Message
Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.8 and pylint encounters an assignment expression (walrus) operator. pylint calls it using-assignment-expression-in-unsupported-version.
- Code
W2605- Severity
- warning
- Message
Assignment expression is not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.8 and pylint encounters positional-only arguments. pylint calls it using-positional-only-args-in-unsupported-version.
- Code
W2606- Severity
- warning
- Message
Positional-only arguments are not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.15 and pylint encounters the * or ** unpacking added by PEP 798 in a comprehension. pylint calls it using-comprehension-unpacking-in-unsupported-version.
- Code
W2607- Severity
- warning
- Message
Unpacking in comprehensions is not supported by all versions included in the py-version setting
Used when the py-version set by the user is lower than 3.15 and pylint encounters the lazy import added by PEP 810. pylint calls it using-lazy-import-in-unsupported-version.
- Code
W2608- Severity
- warning
- Message
Lazy imports are not supported by all versions included in the py-version setting
Used when a method needs a 'timeout' parameter in order to avoid waiting for a long time. If no timeout is specified explicitly the default value is used. For example for 'requests' the program will never time out (i.e. hang indefinitely). pylint calls it missing-timeout.
- Code
W3101- Severity
- warning
- Message
Missing timeout argument for method '{}' can cause your program to hang indefinitely