Full changelog¶
What's New in Pylint 2.0?¶
Release date: 2018-07-15
try-except-raiseshould not be emitted if there are any parent exception class handlers.Closes #2284
trailing-comma-tuplecan be emitted forreturnstatements as well.Closes #2269
Fix a false positive
inconsistent-return-statementsmessage when exception is raised inside an else statement.Closes #1782
ImportFromnodes correctly use the full name for the import sorting checks.Closes #2181
[].extend and similar builtin operations don't emit dict-*-not-iterating with the Python 3 porting checker
Closes #2187
Add a check
consider-using-dict-comprehensionwhich is emitted if for dict initialization the old style with list comprehensions is used.Add a check
consider-using-set-comprehensionwhich is emitted if for set initialization the old style with list comprehensions is used.logging-not-lazyis emitted whenever pylint infers that a string is built with additionCloses #2193
Add a check
chained-comparisonwhich is emitted if a boolean operation can be simplified by chaining some of its operations. e.g "a < b and b < c", can be simplified as "a < b < c".Closes #2032
Add a check
consider-using-infor comparisons of a variable against multiple values with "==" and "or"s instead of checking if the variable is contained "in" a tuple of those values.inis considered iterating context for some of the Python 3 porting checkersCloses #2186
Add
--ignore-noneflag to control if pylint should warn aboutno-memberwhere the owner is NoneFix a false positive related to
too-many-argumentsand bounded__get__methodsCloses #2172
mcsas the first parameter of metaclass's__new__method was replaced byclsCloses #2028
assignment-from-no-returnconsiders methods as well.Closes #2081
Support typing.TYPE_CHECKING for unused-import errors
Closes #1948
Inferred classes at a function level no longer emit
invalid-namewhen they don't respect the variable regular expressionCloses #1049
Added basic support for postponed evaluation of function annotations.
Closes #2069
Fix a bug with
missing-kwoaand variadics parametersCloses #1111
simplifiable-if-statementtakes in account only when assigning to same targetsCloses #1984
Make
len-as-conditiontest more cases, such aslen() < 1orlen <= 0Fix false-positive
line-too-longmessage emission for commented line at the end of a moduleCloses #1950
Fix false-positive
bad-continuationfor with statementsCloses #461
Don't warn about
stop-iteration-returnwhen usingnext()overitertools.countCloses #2158
Add a check
consider-using-getfor unidiomatic usage of value/default-retrieval for a key from a dictionaryCloses #2076
invalid-slice-index is not emitted when the slice is used as index for a complex object.
We only use a handful of known objects (list, set and friends) to figure out if we should emit invalid-slice-index when the slice is used to subscript an object.
Don't emit
unused-importanymore for typing imports used in type comments.Add a new check 'useless-import-alias'.
Closes #2052
Add
comparison-with-callableto warn for comparison with bare callable, without calling it.Closes #2082
Don't warn for
missing-type-docand/ormissing-return-type-doc, if type annotations exist on the function signature for a parameter and/or return type.Closes #2083
Add
--exit-zerooption for continuous integration scripts to more easily call Pylint in environments that abort when a program returns a non-zero (error) status code.Closes #2042
Warn if the first argument of an instance/ class method gets assigned
Closes #977
New check
comparison-with-itselfto check comparison between same value.Closes #2051
Add a new warning, 'logging-fstring-interpolation', emitted when f-string is used within logging function calls.
Closes #1998
Don't show 'useless-super-delegation' if the subclass method has different type annotations.
Closes #1923
Add
unhashable-dict-keycheck.Closes #586
Don't warn that a global variable is unused if it is defined by an import
Closes #1453
Skip wildcard import check for
__init__.py.Closes #2026
The Python 3 porting mode can now run with Python 3 as well.
too-few-public-methodsis not emitted for dataclasses.Closes #1793
New verbose mode option, enabled with
--verbosecommand line flag, to display of extra non-checker-related output. It is disabled by default.Closes #1863
undefined-loop-variabletakes in consideration non-empty iterred objects before emittingCloses #2039
Add support for numpydoc optional return value names.
Closes #2030
singleton-comparisonaccounts for negative checksCloses #2037
Add a check
consider-using-infor comparisons of a variable against multiple values with "==" and "or"s instead of checking if the variable is contained "in" a tuple of those values.Closes #1977
defaultdict and subclasses of dict are now handled for dict-iter-* checks
Closes #2005
logging-format-interpolationalso emits when f-strings are used instead of % syntax.Closes #1788
Don't trigger misplaced-bare-raise when the raise is in a finally clause
Closes #1924
Add a new check,
possibly-unused-variable.This is similar to
unused-variable, the only difference is that it is emitted when we detect a locals() call in the scope of the unused variable. Thelocals()call could potentially use the said variable, by consuming all values that are present up to the point of the call. This new check allows to disable this error when the user intentionally useslocals()to consume everything.Closes #1909.
no-else-returnaccounts for multiple casesThe check was a bit overrestrictive because we were checking for return nodes in the .orelse node. At that point though the if statement can be refactored to not have the orelse. This improves the detection of other cases, for instance it now detects TryExcept nodes that are part of the .else branch.
Closes #1852
Added two new checks,
invalid-envvar-valueandinvalid-envvar-default.The former is trigger whenever pylint detects that environment variable manipulation functions uses a different type than strings, while the latter is emitted whenever the said functions are using a default variable of different type than expected.
Add a check
consider-using-joinfor concatenation of strings using str.join(sequence)Closes #1952
Add a check
consider-swap-variablesfor swapping variables with tuple unpackingCloses #1922
Add new checker
try-except-raisethat warns the user if an except handler block has araisestatement as its first operator. The warning is shown when there is a bare raise statement, effectively re-raising the exception that was caught or the type of the exception being raised is the same as the one being handled.Don't crash on invalid strings when checking for
logging-format-interpolationCloses #1944
Exempt
__doc__from triggering aredefined-builtin__doc__can be used to specify a docstring for a module without passing it as a first-statement string.Fix false positive bad-whitespace from function arguments with default values and annotations
Closes #1831
Fix stop-iteration-return false positive when next builtin has a default value in a generator
Closes #1830
Fix emission of false positive
no-membermessage for class with "private" attributes whose name is mangled.Closes #1643
Fixed a crash which occurred when
Uninferablewasn't properly handled instop-iteration-returnCloses #1779
Use the proper node to get the name for redefined functions (#1792)
Closes #1774
Don't crash when encountering bare raises while checking inconsistent returns
Closes #1773
Fix a false positive
inconsistent-return-statementsmessage when if statement is inside try/except.Closes #1770
Fix a false positive
inconsistent-return-statementsmessage when while loop are used.Closes #1772
Correct column number for whitespace conventions.
Previously the column was stuck at 0
Closes #1649
Fix
unused-argumentfalse positives with overshadowed variable in dictionary comprehension.Closes #1731
Fix false positive
inconsistent-return-statementsmessage when never returning functions are used (i.e sys.exit for example).Closes #1771
Fix error when checking if function is exception, as in
bad-exception-context.Fix false positive
inconsistent-return-statementsmessage when a function is defined under an if statement.Closes #1794
New
useless-returnmessage when function or method ends with a "return" or "return None" statement and this is the only return statement in the body.Fix false positive
inconsistent-return-statementsmessage by avoiding useless exception inference if the exception is not handled.Closes #1794 (second part)
Fix bad thread instantiation check when target function is provided in args.
Closes #1840
Fixed false positive when a numpy Attributes section follows a Parameters section
Closes #1867
Fix incorrect file path when file absolute path contains multiple
path_strip_prefixstrings.Closes #1120
Fix false positive undefined-variable for lambda argument in class definitions
Closes #1824
Add of a new checker that warns the user if some messages are enabled or disabled by id instead of symbol.
Closes #1599
Suppress false-positive
not-callablemessages from certain staticmethod descriptorsCloses #1699
Fix indentation handling with tabs
Closes #1148
Fix false-positive
bad-continuationerrorCloses #638
Fix false positive unused-variable in lambda default arguments
Closes #1921 Closes #1552 Closes #1099 Closes #210
Updated the default report format to include paths that can be clicked on in some terminals (e.g. iTerm).
Fix inline def behavior with
too-many-statementscheckerCloses #1978
Fix
KeyErrorraised when using docparams and NotImplementedError is documented.Closes #2102
Fix 'method-hidden' raised when assigning to a property or data descriptor.
Fix emitting
useless-super-delegationwhen changing the default value of keyword arguments.Closes #2022
Expand ignored-argument-names include starred arguments and keyword arguments
Closes #2214
Fix false-positive undefined-variable in nested lambda
Closes #760
Fix false-positive
bad-whitespacemessage for typing annoatations with ellipses in themClose 1992
Broke down "missing-docstrings" between "module", "class" and "function"
For this to work we had to make multiple messages with the same old name possible.
Closes #1164