List is deprecated and shouldn T be used use a list literal, (), or the List filled constructor instead

Pylint features¶

Pylint global options and switches¶

Pylint provides global options and switches.

General options¶

ignore

Files or directories to be skipped. They should be base names, not paths.

Default: CVS

ignore-patterns

Files or directories matching the regex patterns are skipped. The regex matches against base names, not paths. The default value ignores emacs file locks

Default: ^\.#

ignore-paths

Add files or directories matching the regex patterns to the ignore-list. The regex matches against paths and can be in Posix or Windows format.

persistent

Pickle collected data for later comparisons.

Default: yes

load-plugins

List of plugins [as comma separated values of python module names] to load, usually to register additional checkers.

fail-under

Specify a score threshold to be exceeded before program exits with error.

Default: 10.0

fail-on

Return non-zero exit code if any of these messages/categories are detected, even if score is above --fail-under value. Syntax same as enable. Messages specified are enabled, while categories only check already-enabled messages.

jobs

Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the number of processors available to use.

Default: 1

unsafe-load-any-extension

Allow loading of arbitrary C extensions. Extensions are imported into the active Python interpreter and may run arbitrary code.

limit-inference-results

Control the amount of potential inferred values when inferring a single object. This can help the performance when dealing with large functions or complex, nested conditions.

Default: 100

extension-pkg-allow-list

A comma-separated list of package or module names from where C extensions may be loaded. Extensions are loading into the active Python interpreter and may run arbitrary code.

extension-pkg-whitelist

A comma-separated list of package or module names from where C extensions may be loaded. Extensions are loading into the active Python interpreter and may run arbitrary code. [This is an alternative name to extension-pkg-allow-list for backward compatibility.]

suggestion-mode

When enabled, pylint would attempt to guess common misconfiguration and emit user-friendly hints instead of false-positive error messages.

Default: yes

exit-zero

Always return a 0 [non-error] status code, even if lint errors are found. This is primarily useful in continuous integration scripts.

from-stdin

Interpret the stdin as a python script, whose filename needs to be passed as the module_or_package argument.

py-version

Minimum Python version to use for version dependent checks. Will default to the version used to run pylint.

Messages control options¶

confidence

Only show warnings with the listed confidence levels. Leave empty to show all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.

enable

Enable the message, report, category or checker with the given id[s]. You can either give multiple identifier separated by comma [,] or put this option multiple time [only on the command line, not in the configuration file where it should appear only once]. See also the "--disable" option for examples.

disable

Disable the message, report, category or checker with the given id[s]. You can either give multiple identifiers separated by comma [,] or put this option multiple times [only on the command line, not in the configuration file where it should appear only once]. You can also use "--disable=all" to disable everything first and then re-enable specific checks. For example, if you want to run only the similarities checker, you can use "--disable=all --enable=similarities". If you want to run only the classes checker, but have no Warning level messages displayed, use "--disable=all --enable=classes --disable=W".

Reports options¶

output-format

Set the output format. Available formats are text, parseable, colorized, json and msvs [visual studio]. You can also give a reporter class, e.g. mypackage.mymodule.MyReporterClass.

Default: text

reports

Tells whether to display a full report or only the messages.

evaluation

Python expression which should return a score less than or equal to 10. You have access to the variables 'fatal', 'error', 'warning', 'refactor', 'convention', and 'info' which contain the number of messages in each category, as well as 'statement' which is the total number of statements analyzed. This score is used by the global evaluation report [RP0004].

Default: max[0, 0 if fatal else 10.0 - [[float[5 * error + warning + refactor + convention] / statement] * 10]]

score

Activate the evaluation score.

Default: yes

msg-template

Template used to display messages. This is a python new-style format string used to format the message information. See doc for all details.

Pylint checkers' options and switches¶

Pylint checkers can provide three set of features:

  • options that control their execution,

  • messages that they can raise,

  • reports that they can generate.

Below is a list of all checkers and their features.

Async checker¶

Verbatim name of the checker is async.

Async checker Messages¶

not-async-context-manager [E1701]

Async context manager '%s' doesn't implement __aenter__ and __aexit__. Used when an async context manager is used with an object that does not implement the async context management protocol. This message can't be emitted when using Python < 3.5.

yield-inside-async-function [E1700]

Yield inside async function Used when an yield or yield from statement is found inside an async function. This message can't be emitted when using Python < 3.5.

Basic checker¶

Verbatim name of the checker is basic.

Basic checker Options¶

good-names

Good variable names which should always be accepted, separated by a comma.

Default: i,j,k,ex,Run,_

good-names-rgxs

Good variable names regexes, separated by a comma. If names match any regex, they will always be accepted

bad-names

Bad variable names which should always be refused, separated by a comma.

Default: foo,bar,baz,toto,tutu,tata

bad-names-rgxs

Bad variable names regexes, separated by a comma. If names match any regex, they will always be refused

name-group

Colon-delimited sets of names that determine each other's naming style when the name regexes allow several styles.

include-naming-hint

Include a hint for the correct naming format with invalid-name.

property-classes

List of decorators that produce properties, such as abc.abstractproperty. Add to this list to register other decorators that produce valid properties. These decorators are taken in consideration only for invalid-name.

Default: abc.abstractproperty

argument-naming-style

Naming style matching correct argument names.

Default: snake_case

argument-rgx

Regular expression matching correct argument names. Overrides argument- naming-style.

attr-naming-style

Naming style matching correct attribute names.

Default: snake_case

attr-rgx

Regular expression matching correct attribute names. Overrides attr-naming- style.

class-naming-style

Naming style matching correct class names.

Default: PascalCase

class-rgx

Regular expression matching correct class names. Overrides class-naming- style.

class-attribute-naming-style

Naming style matching correct class attribute names.

Default: any

class-attribute-rgx

Regular expression matching correct class attribute names. Overrides class- attribute-naming-style.

class-const-naming-style

Naming style matching correct class constant names.

Default: UPPER_CASE

class-const-rgx

Regular expression matching correct class constant names. Overrides class- const-naming-style.

const-naming-style

Naming style matching correct constant names.

Default: UPPER_CASE

const-rgx

Regular expression matching correct constant names. Overrides const-naming- style.

function-naming-style

Naming style matching correct function names.

Default: snake_case

function-rgx

Regular expression matching correct function names. Overrides function- naming-style.

inlinevar-naming-style

Naming style matching correct inline iteration names.

Default: any

inlinevar-rgx

Regular expression matching correct inline iteration names. Overrides inlinevar-naming-style.

method-naming-style

Naming style matching correct method names.

Default: snake_case

method-rgx

Regular expression matching correct method names. Overrides method-naming- style.

module-naming-style

Naming style matching correct module names.

Default: snake_case

module-rgx

Regular expression matching correct module names. Overrides module-naming- style.

variable-naming-style

Naming style matching correct variable names.

Default: snake_case

variable-rgx

Regular expression matching correct variable names. Overrides variable- naming-style.

no-docstring-rgx

Regular expression which should only match function or class names that do not require a docstring.

Default: ^_

docstring-min-length

Minimum line length for functions/classes that require docstrings, shorter ones are exempt.

Default: -1

Basic checker Messages¶

not-in-loop [E0103]

%r not properly in loop Used when break or continue keywords are used outside a loop.

function-redefined [E0102]

%s already defined line %s Used when a function / class / method is redefined.

continue-in-finally [E0116]

'continue' not supported inside 'finally' clause Emitted when the continue keyword is found inside a finally clause, which is a SyntaxError. This message can't be emitted when using Python >= 3.8.

abstract-class-instantiated [E0110]

Abstract class %r with abstract methods instantiated Used when an abstract class with abc.ABCMeta as metaclass has abstract methods and is instantiated.

star-needs-assignment-target [E0114]

Can use starred expression only in assignment target Emitted when a star expression is not used in an assignment target.

duplicate-argument-name [E0108]

Duplicate argument name %s in function definition Duplicate argument names in function definitions are syntax errors.

return-in-init [E0101]

Explicit return in __init__ Used when the special class method __init__ has an explicit return value.

too-many-star-expressions [E0112]

More than one starred expression in assignment Emitted when there are more than one starred expressions [*x] in an assignment. This is a SyntaxError.

nonlocal-and-global [E0115]

Name %r is nonlocal and global Emitted when a name is both nonlocal and global.

used-prior-global-declaration [E0118]

Name %r is used prior to global declaration Emitted when a name is used prior a global declaration, which results in an error since Python 3.6. This message can't be emitted when using Python < 3.6.

return-outside-function [E0104]

Return outside function Used when a "return" statement is found outside a function or method.

return-arg-in-generator [E0106]

Return with argument inside generator Used when a "return" statement with an argument is found outside in a generator function or method [e.g. with some "yield" statements]. This message can't be emitted when using Python >= 3.3.

invalid-star-assignment-target [E0113]

Starred assignment target must be in a list or tuple Emitted when a star expression is used as a starred assignment target.

bad-reversed-sequence [E0111]

The first reversed[] argument is not a sequence Used when the first argument to reversed[] builtin isn't a sequence [does not implement __reversed__, nor __getitem__ and __len__

nonexistent-operator [E0107]

Use of the non-existent %s operator Used when you attempt to use the C-style pre-increment or pre-decrement operator -- and ++, which doesn't exist in Python.

yield-outside-function [E0105]

Yield outside function Used when a "yield" statement is found outside a function or method.

init-is-generator [E0100]

__init__ method is a generator Used when the special class method __init__ is turned into a generator by a yield in its body.

misplaced-format-function [E0119]

format function is not called on str Emitted when format function is not called on str object. e.g doing print["value: {}"].format[123] instead of print["value: {}".format[123]]. This might not be what the user intended to do.

nonlocal-without-binding [E0117]

nonlocal name %s found without binding Emitted when a nonlocal variable does not have an attached name somewhere in the parent scopes

lost-exception [W0150]

%s statement in finally block may swallow exception 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.

assert-on-tuple [W0199]

Assert called on a 2-item-tuple. Did you mean 'assert x,y'? 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.

assert-on-string-literal [W0129]

Assert statement has a string literal as its first argument. The assert will %s fail. Used when an assert statement has a string literal as its first argument, which will cause the assert to always pass.

self-assigning-variable [W0127]

Assigning the same variable %r to itself Emitted when we detect that a variable is assigned to itself

comparison-with-callable [W0143]

Comparing against a callable, did you omit the parenthesis? 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.

nan-comparison [W0177]

Comparison %s should be %s Used when an expression is compared to NaNvalues like numpy.NaN and float['nan']

dangerous-default-value [W0102]

Dangerous default value %s as argument Used when a mutable value as list or dictionary is detected in a default value for an argument.

duplicate-key [W0109]

Duplicate key %r in dictionary Used when a dictionary expression binds the same key multiple times.

useless-else-on-loop [W0120]

Else clause on loop without a break statement 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.

expression-not-assigned [W0106]

Expression "%s" is assigned to nothing Used when an expression that is not a function call is assigned to nothing. Probably something else was intended.

confusing-with-statement [W0124]

Following "as" with another context manager looks like a tuple. 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.

unnecessary-lambda [W0108]

Lambda may not be necessary 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.

assign-to-new-keyword [W0111]

Name %s will become a keyword in Python %s Used when assignment will become invalid in future Python release due to introducing new keyword.

redeclared-assigned-name [W0128]

Redeclared variable %r in assignment Emitted when we detect that a variable was redeclared in the same assignment.

pointless-statement [W0104]

Statement seems to have no effect Used when a statement doesn't have [or at least seems to] any effect.

pointless-string-statement [W0105]

String statement has 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.

unnecessary-pass [W0107]

Unnecessary pass statement Used when a "pass" statement that can be avoided is encountered.

unreachable [W0101]

Unreachable code Used when there is some code behind a "return" or "raise" statement, which will never be accessed.

eval-used [W0123]

Use of eval 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.

exec-used [W0122]

Use of exec Used when you use the "exec" statement [function for Python 3], to discourage its usage. That doesn't mean you cannot use it !

using-constant-test [W0125]

Using a conditional statement with a constant value 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.

missing-parentheses-for-call-in-test [W0126]

Using a conditional statement with potentially wrong function or method call due to missing parentheses Emitted when a conditional statement [If or ternary if] seems to wrongly call a function due to missing parentheses

literal-comparison [R0123]

Comparison to literal Used when comparing an object to a literal, which is usually what you do not want to do, since you can compare to a different literal than what was expected altogether.

comparison-with-itself [R0124]

Redundant comparison - %s Used when something is compared against itself.

non-ascii-name [C0144]

%s name "%s" contains a non-ASCII unicode character Used when the name contains at least one non-ASCII unicode character.

invalid-name [C0103]

%s name "%s" doesn't conform to %s Used when the name doesn't conform to naming rules associated to its type [constant, variable, class...].

singleton-comparison [C0121]

Comparison %s should be %s Used when an expression is compared to singleton values like True, False or None.

disallowed-name [C0104]

Disallowed name "%s" Used when the name matches bad-names or bad-names-rgxs- [unauthorized names].

empty-docstring [C0112]

Empty %s docstring Used when a module, function, class or method has an empty docstring [it would be too easy ;].

missing-class-docstring [C0115]

Missing class docstring Used when a class has no docstring.Even an empty class must have a docstring.

missing-function-docstring [C0116]

Missing function or method docstring Used when a function or method has no docstring.Some special methods like __init__ do not require a docstring.

missing-module-docstring [C0114]

Missing module docstring Used when a module has no docstring.Empty modules do not require a docstring.

unidiomatic-typecheck [C0123]

Use isinstance[] rather than type[] for a typecheck. The idiomatic way to perform an explicit typecheck in Python is to use isinstance[x, Y] rather than type[x] == Y, type[x] is Y. Though there are unusual situations where these give different results.

Basic checker Reports¶

RP0101

Statistics by type

Classes checker¶

Verbatim name of the checker is classes.

Classes checker Options¶

defining-attr-methods

List of method names used to declare [i.e. assign] instance attributes.

Default: __init__,__new__,setUp,__post_init__

valid-classmethod-first-arg

List of valid names for the first argument in a class method.

Default: cls

valid-metaclass-classmethod-first-arg

List of valid names for the first argument in a metaclass class method.

Default: cls

exclude-protected

List of member names, which should be excluded from the protected access warning.

Default: _asdict,_fields,_replace,_source,_make

check-protected-access-in-special-methods

Warn about protected attribute access inside special methods

Classes checker Messages¶

access-member-before-definition [E0203]

Access to member %r before its definition line %s Used when an instance member is accessed before it's actually assigned.

method-hidden [E0202]

An attribute defined in %s line %s hides this method Used when a class defines a method which is hidden by an instance attribute from an ancestor class or set by some client code.

assigning-non-slot [E0237]

Assigning to attribute %r not defined in class slots Used when assigning to an attribute not defined in the class slots.

duplicate-bases [E0241]

Duplicate bases for class %r Used when a class has duplicate bases.

inconsistent-mro [E0240]

Inconsistent method resolution order for class %r Used when a class has an inconsistent method resolution order.

inherit-non-class [E0239]

Inheriting %r, which is not a class. Used when a class inherits from something which is not a class.

invalid-class-object [E0243]

Invalid __class__ object Used when an invalid object is assigned to a __class__ property. Only a class is permitted.

invalid-slots [E0238]

Invalid __slots__ object Used when an invalid __slots__ is found in class. Only a string, an iterable or a sequence is permitted.

invalid-slots-object [E0236]

Invalid object %r in __slots__, must contain only non empty strings Used when an invalid [non-string] object occurs in __slots__.

no-method-argument [E0211]

Method has no argument Used when a method which should have the bound instance as first argument has no argument defined.

no-self-argument [E0213]

Method should have "self" as first argument Used when a method has an attribute different the "self" as first argument. This is considered as an error since this is a so common convention that you shouldn't break it!

unexpected-special-method-signature [E0302]

The special method %r expects %s param[s], %d %s given Emitted when a special method was defined with an invalid number of parameters. If it has too few or too many, it might not work at all.

class-variable-slots-conflict [E0242]

Value %r in slots conflicts with class variable Used when a value in __slots__ conflicts with a class variable, property or method.

invalid-bool-returned [E0304]

__bool__ does not return bool Used when a __bool__ method returns something which is not a bool

invalid-bytes-returned [E0308]

__bytes__ does not return bytes Used when a __bytes__ method returns something which is not bytes

invalid-format-returned [E0311]

__format__ does not return str Used when a __format__ method returns something which is not a string

invalid-getnewargs-returned [E0312]

__getnewargs__ does not return a tuple Used when a __getnewargs__ method returns something which is not a tuple

invalid-getnewargs-ex-returned [E0313]

__getnewargs_ex__ does not return a tuple containing [tuple, dict] Used when a __getnewargs_ex__ method returns something which is not of the form tuple[tuple, dict]

invalid-hash-returned [E0309]

__hash__ does not return int Used when a __hash__ method returns something which is not an integer

invalid-index-returned [E0305]

__index__ does not return int Used when an __index__ method returns something which is not an integer

non-iterator-returned [E0301]

__iter__ returns non-iterator Used when an __iter__ method returns something which is not an iterable [i.e. has no __next__ method]

invalid-length-returned [E0303]

__len__ does not return non-negative integer Used when a __len__ method returns something which is not a non-negative integer

invalid-length-hint-returned [E0310]

__length_hint__ does not return non-negative integer Used when a __length_hint__ method returns something which is not a non- negative integer

invalid-repr-returned [E0306]

__repr__ does not return str Used when a __repr__ method returns something which is not a string

invalid-str-returned [E0307]

__str__ does not return str Used when a __str__ method returns something which is not a string

arguments-differ [W0221]

%s %s %r method Used when a method has a different number of arguments than in the implemented interface or in an overridden method.

arguments-renamed [W0237]

%s %s %r method Used when a method parameter has a different name than in the implemented interface or in an overridden method.

protected-access [W0212]

Access to a protected member %s of a client class Used when a protected member [i.e. class member with a name beginning with an underscore] is access outside the class or a descendant of the class where it's defined.

attribute-defined-outside-init [W0201]

Attribute %r defined outside __init__ Used when an instance attribute is defined outside the __init__ method.

subclassed-final-class [W0240]

Class %r is a subclass of a class decorated with typing.final: %r Used when a class decorated with typing.final has been subclassed.

no-init [W0232]

Class has no __init__ method Used when a class has no __init__ method, neither its parent classes.

abstract-method [W0223]

Method %r is abstract in class %r but is not overridden Used when an abstract method [i.e. raise NotImplementedError] is not overridden in concrete class.

overridden-final-method [W0239]

Method %r overrides a method decorated with typing.final which is defined in class %r Used when a method decorated with typing.final has been overridden.

invalid-overridden-method [W0236]

Method %r was expected to be %r, found it instead as %r 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.

signature-differs [W0222]

Signature differs from %s %r method Used when a method signature is different than in the implemented interface or in an overridden method.

bad-staticmethod-argument [W0211]

Static method with %r as first argument 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.

unused-private-member [W0238]

Unused private member `%s.%s` Emitted when a private member of a class is defined but not used.

useless-super-delegation [W0235]

Useless super delegation in method %r Used whenever we can detect that an overridden method is useless, relying on super[] delegation to do the same thing as another method from the MRO.

non-parent-init-called [W0233]

__init__ method from a non direct base class %r is called Used when an __init__ method is called on a class which is not in the direct ancestors for the analysed class.

super-init-not-called [W0231]

__init__ method from base class %r is not called Used when an ancestor class method has an __init__ method which is not called by a derived class.

property-with-parameters [R0206]

Cannot have defined parameters for properties Used when we detect that a property also has parameters, which are useless, given that properties cannot be called with additional arguments.

useless-object-inheritance [R0205]

Class %r inherits from object, can be safely removed from bases in python3 Used when a class inherit from object, which under python3 is implicit, hence can be safely removed from bases.

no-classmethod-decorator [R0202]

Consider using a decorator instead of calling classmethod Used when a class method is defined without using the decorator syntax.

no-staticmethod-decorator [R0203]

Consider using a decorator instead of calling staticmethod Used when a static method is defined without using the decorator syntax.

no-self-use [R0201]

Method could be a function Used when a method doesn't use its bound instance, and so could be written as a function.

single-string-used-for-slots [C0205]

Class __slots__ should be a non-string iterable Used when a class __slots__ is a simple string, rather than an iterable.

bad-classmethod-argument [C0202]

Class method %s should have %s as first argument Used when a class method has a first argument named differently than the value specified in valid-classmethod-first-arg option [default to "cls"], recommended to easily differentiate them from regular instance methods.

bad-mcs-classmethod-argument [C0204]

Metaclass class method %s should have %s as first argument Used when a metaclass class method has a first argument named differently than the value specified in valid-metaclass-classmethod-first-arg option [default to "mcs"], recommended to easily differentiate them from regular instance methods.

bad-mcs-method-argument [C0203]

Metaclass method %s should have %s as first argument Used when a metaclass method has a first argument named differently than the value specified in valid-classmethod-first-arg option [default to "cls"], recommended to easily differentiate them from regular instance methods.

method-check-failed [F0202]

Unable to check methods signature [%s / %s] Used when Pylint has been unable to check methods signature compatibility for an unexpected reason. Please report this kind if you don't make sense of it.

Design checker¶

Verbatim name of the checker is design.

Design checker Options¶

max-args

Maximum number of arguments for function / method.

Default: 5

max-locals

Maximum number of locals for function / method body.

Default: 15

max-returns

Maximum number of return / yield for function / method body.

Default: 6

max-branches

Maximum number of branch for function / method body.

Default: 12

max-statements

Maximum number of statements in function / method body.

Default: 50

max-parents

Maximum number of parents for a class [see R0901].

Default: 7

ignored-parents

List of qualified class names to ignore when counting class parents [see R0901]

max-attributes

Maximum number of attributes for a class [see R0902].

Default: 7

min-public-methods

Minimum number of public methods for a class [see R0903].

Default: 2

max-public-methods

Maximum number of public methods for a class [see R0904].

Default: 20

max-bool-expr

Maximum number of boolean expressions in an if statement [see R0916].

Default: 5

exclude-too-few-public-methods

List of regular expressions of class ancestor names to ignore when counting public methods [see R0903]

Design checker Messages¶

too-few-public-methods [R0903]

Too few public methods [%s/%s] Used when class has too few public methods, so be sure it's really worth it.

too-many-ancestors [R0901]

Too many ancestors [%s/%s] Used when class has too many parent classes, try to reduce this to get a simpler [and so easier to use] class.

too-many-arguments [R0913]

Too many arguments [%s/%s] Used when a function or method takes too many arguments.

too-many-boolean-expressions [R0916]

Too many boolean expressions in if statement [%s/%s] Used when an if statement contains too many boolean expressions.

too-many-branches [R0912]

Too many branches [%s/%s] Used when a function or method has too many branches, making it hard to follow.

too-many-instance-attributes [R0902]

Too many instance attributes [%s/%s] Used when class has too many instance attributes, try to reduce this to get a simpler [and so easier to use] class.

too-many-locals [R0914]

Too many local variables [%s/%s] Used when a function or method has too many local variables.

too-many-public-methods [R0904]

Too many public methods [%s/%s] Used when class has too many public methods, try to reduce this to get a simpler [and so easier to use] class.

too-many-return-statements [R0911]

Too many return statements [%s/%s] Used when a function or method has too many return statement, making it hard to follow.

too-many-statements [R0915]

Too many statements [%s/%s] Used when a function or method has too many statements. You should then split it in smaller functions / methods.

Exceptions checker¶

Verbatim name of the checker is exceptions.

Exceptions checker Options¶

overgeneral-exceptions

Exceptions that will emit a warning when being caught. Defaults to "BaseException, Exception".

Default: BaseException,Exception

Exceptions checker Messages¶

bad-except-order [E0701]

Bad except clauses order [%s] Used when except clauses are not in the correct order [from the more specific to the more generic]. If you don't fix the order, some exceptions may not be caught by the most specific handler.

catching-non-exception [E0712]

Catching an exception which doesn't inherit from Exception: %s Used when a class which doesn't inherit from Exception is used as an exception in an except clause.

bad-exception-context [E0703]

Exception context set to something which is not an exception, nor None Used when using the syntax "raise ... from ...", where the exception context is not an exception, nor None.

notimplemented-raised [E0711]

NotImplemented raised - should raise NotImplementedError Used when NotImplemented is raised instead of NotImplementedError

raising-bad-type [E0702]

Raising %s while only classes or instances are allowed Used when something which is neither a class, an instance or a string is raised [i.e. a TypeError will be raised].

raising-non-exception [E0710]

Raising a new style class which doesn't inherit from BaseException Used when a new style class which doesn't inherit from BaseException is raised.

misplaced-bare-raise [E0704]

The raise statement is not inside an except clause 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.

duplicate-except [W0705]

Catching previously caught exception type %s Used when an except catches a type that was already caught by a previous handler.

broad-except [W0703]

Catching too general exception %s Used when an except catches a too general exception, possibly burying unrelated errors.

raise-missing-from [W0707]

Consider explicitly re-raising using the 'from' keyword Python 3's exception chaining means it shows the traceback of the current exception, but also the original exception. Not using raise from makes the traceback inaccurate, because the message implies there is a bug in the exception-handling code itself, which is a separate situation than wrapping an exception.

raising-format-tuple [W0715]

Exception arguments suggest string formatting might be intended 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

binary-op-exception [W0711]

Exception to catch is the result of a binary "%s" operation Used when the exception to catch is of the form "except A or B:". If intending to catch multiple, rewrite as "except [A, B]:"

wrong-exception-operation [W0716]

Invalid exception operation. %s 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.

bare-except [W0702]

No exception type[s] specified Used when an except clause doesn't specify exceptions type to catch.

try-except-raise [W0706]

The except handler raises immediately 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!

Format checker¶

Verbatim name of the checker is format.

Format checker Options¶

max-line-length

Maximum number of characters on a single line.

Default: 100

ignore-long-lines

Regexp for a line that is allowed to be longer than the limit.

Default: ^\s*[# ]?

Chủ Đề