Releases: pylint-dev/pylint
v2.17.0
2.17 is a small release that is the first to support python 3.11 officially
with the addition of TryStar nodes.
There's still two new default checks: bad-chained-comparison and
implicit-flag-alias, one of them already fixed a previously undetected
bug in sentry.
Thanks to the community effort our documentation is almost complete,
and almost all messages should have a proper documentation now.
A big thank you to everyone who participated !
The next release is going to be 3.0.0, bring breaking changes and
enact long announced deprecations. There's going to be frequent beta
releases, before the official releases, everyone is welcome to try the betas
so we find problems before the actual release.
What's new in Pylint 2.17.0?
Release date: 2023-03-08
New Features
-
pyreversenow supports custom color palettes with the--color-palette
option.Closes #6738
-
Add
invalid-namecheck forTypeAliasnames.Closes #7081
-
Accept values of the form
<class name>.<attribute name>for the
exclude-protectedlist.Closes #7343
-
Add
--versionoption topyreverse.Refs #7851
-
Adds new functionality with preferred-modules configuration to detect
submodules.Refs #7957
-
Support implicit namespace packages (PEP 420).
Closes #8154
-
Add globbing pattern support for
--source-roots.Closes #8290
-
Support globbing pattern when defining which file/directory/module to lint.
Closes #8310
-
pylint now supports
TryStarnodes from Python 3.11 and should be fully
compatible with Python 3.11.Closes #8387
New Checks
-
Add a
bad-chained-comparisoncheck that emits a warning when
there is a chained comparison where one expression is semantically
incompatible with the other.Closes #6559
-
Adds an
implicit-flag-aliascheck that emits a warning when a class
derived fromenum.IntFlagassigns distinct integer values that share
common bit positions.Refs #8102
False Positives Fixed
-
Fix various false positives for functions that return directly from
structural pattern matching cases.Closes #5288
-
Fix false positive for
used-before-assignmentwhen
typing.TYPE_CHECKINGis used with if/elif/else blocks.Closes #7574
-
Fix false positive for isinstance-second-argument-not-valid-type with union
types.Closes #8205
-
Fix false positive for
used-before-assignmentfor named expressions
appearing after the first element in a list, tuple, or set.Closes #8252
-
Fix false positive for
wrong-spelling-in-commentwith class names in a
python 2 type comment.Closes #8370
False Negatives Fixed
-
Fix a false negative for 'missing-parentheses-for-call-in-test' when
inference
failed for the internal of the call as we did not need that information to
raise
correctly.Refs #8185
-
Fix false negative for inconsistent-returns with while-loops.
Closes #8280
Other Bug Fixes
-
Fix
used-before-assignmentfalse positive when the walrus operator
is used with a ternary operator in dictionary key/value initialization.Closes #8125
-
Fix
no-name-in-modulefalse positive raised when a package defines a
variable with the
same name as one of its submodules.Closes #8148
-
Fix a crash happening for python interpreter < 3.9 following a failed typing
update.Closes #8161
-
Fix
nested-min-maxsuggestion message to indicate it's possible to splat
iterable objects.Closes #8168
-
Fix a crash happening when a class attribute was negated in the start
argument of an enumerate.Closes #8207
-
Prevent emitting
invalid-namefor the line on which aglobal
statement is declared.Closes #8307
Other Changes
v2.16.4
v2.16.3
v2.16.2
New Features
-
Add
--versionoption topyreverse.Refs #7851
False Positives Fixed
-
Fix false positive for
used-before-assignmentwhen
typing.TYPE_CHECKINGis used with if/elif/else blocks.Closes #7574
-
Fix false positive for
used-before-assignmentfor named expressions
appearing after the first element in a list, tuple, or set.Closes #8252
Other Bug Fixes
-
Fix
used-before-assignmentfalse positive when the walrus operator
is used with a ternary operator in dictionary key/value initialization.Closes #8125
-
Fix
no-name-in-modulefalse positive raised when a package defines a
variable with the same name as one of its submodules.Closes #8148
-
Fix
nested-min-maxsuggestion message to indicate it's possible to splat
iterable objects.Closes #8168
-
Fix a crash happening when a class attribute was negated in the start
argument of an enumerate.Closes #8207
v2.16.1
v2.16.0
Summary -- Release highlights
In 2.16.0 we added aggregation and composition understanding in pyreverse, and a way to clear
the cache in between run in server mode (originally for the VS Code integration). Apart from the bug
fixes there's also a lot of new checks, and new extensions that have been asked for for a long time
that were implemented.
If you want to benefit from all the new checks load the following plugins::
pylint.extensions.dict_init_mutate,
pylint.extensions.dunder,
pylint.extensions.typing,
pylint.extensions.magic_value,
We still welcome any community effort to help review, integrate, and add good/bad examples to the doc for
#5953. This should be doable without any pylint or astroid
knowledge, so this is the perfect entrypoint if you want to contribute to pylint or open source without
any experience with our code!
Last but not least @clavedeluna and @nickdrozd became triagers, welcome to the team !
What's new in Pylint 2.16.0?
Changes requiring user actions
-
The
accept-no-raise-docoption related tomissing-raises-docwill now
be correctly taken into account all the time.Pylint will no longer raise missing-raises-doc (W9006) when no exceptions are
documented and accept-no-raise-doc is true (issue #7208).
If you were expecting missing-raises-doc errors to be raised in that case,
you
will now have to addaccept-no-raise-doc=noin your configuration to keep
the same behavior.
Closes #7208
New Features
-
Added the
no-headeroutput format. If enabled with
--output-format=no-header, it will not include the module name in the
output.
Closes #5362 -
Added configuration option
clear-cache-post-runto support server-like
usage.
Use this flag if you expect the linted files to be altered between runs.
Refs #5401 -
Add
--allow-reexport-from-packageoption to configure the
useless-import-aliascheck not to emit a warning if a name
is reexported from a package.
Closes #6006 -
Update
pyreverseto differentiate between aggregations and compositions.
pyreversechecks if it's an Instance or a Call of an object via method
parameters (via type hints)
to decide if it's a composition or an aggregation.
Refs #6543
New Checks
-
Adds a
pointless-exception-statementcheck that emits a warning when an
Exception is created and not assigned, raised or returned.
Refs #3110 -
Add a
shadowed-importmessage for aliased imports.
Closes #4836 -
Add new check called
unbalanced-dict-unpackingto check for unbalanced
dict unpacking
in assignment and for loops.
Closes #5797 -
Add new checker
positional-only-arguments-expectedto check for cases
when
positional-only arguments have been passed as keyword arguments.
Closes #6489 -
Added
singledispatch-methodwhich informs that@singledispatchshould
decorate functions and not class/instance methods.
Addedsingledispatchmethod-functionwhich informs that
@singledispatchmethodshould decorate class/instance methods and not
functions.
Closes #6917 -
Rename
broad-excepttobroad-exception-caughtand add new checker
broad-exception-raised
which will warn if general exceptionsBaseExceptionorExceptionare
raised.
Closes #7494 -
Added
nested-min-maxwhich flagsmin(1, min(2, 3))to simplify to
min(1, 2, 3).
Closes #7546 -
Extended
use-dict-literalto also warn about call todict()when
passing keyword arguments.
Closes #7690 -
Add
named-expr-without-contextcheck to emit a warning if a named
expression is used outside a context likeif,for,while, or
a comprehension.
Refs #7760 -
Add
invalid-slice-stepcheck to warn about a slice step value of0
for common builtin sequences.
Refs #7762 -
Add
consider-refactoring-into-while-conditioncheck to recommend
refactoring when
a while loop is defined with a constant condition with an immediateif
statement to check forbreakcondition as a first statement.
Closes #8015
Extensions
-
Add new extension checker
dict-init-mutatethat flags mutating a
dictionary immediately
after the dictionary was created.
Closes #2876 -
Added
bad-dunder-nameextension check, which flags bad or misspelled
dunder methods.
You can use thegood-dunder-namesoption to allow specific dunder names.
Closes #3038 -
Added
consider-using-augmented-assigncheck forCodeStyleextension
which flagsx = x + 1to simplify tox += 1.
This check is disabled by default. To use it, load the code style extension
withload-plugins=pylint.extensions.code_styleand add
consider-using-augmented-assignin theenableoption.
Closes #3391 -
Add
magic-numberplugin checker for comparison with constants instead of
named constants or enums.
You can use it with--load-plugins=pylint.extensions.magic_value.
Closes #7281 -
Add
redundant-typehint-argumentmessage fortypingplugin for duplicate
assign typehints.
Enable the plugin to enable the message with:
--load-plugins=pylint.extensions.typing.
Closes #7636
False Positives Fixed
-
Fix false positive for
unused-variableandunused-importwhen a name
is only used in a string literal type annotation.
Closes #3299 -
Document a known false positive for
useless-suppressionwhen disabling
line-too-longin a module with only comments and no code.
Closes #3368 -
trailing-whitespacesis no longer reported within strings.
Closes #3822 -
Fix false positive for
global-variable-not-assignedwhen a global
variable is re-assigned via anImportFromnode.
Closes #4809 -
Fix false positive for
use-maxsplit-argwith custom split method.
Closes #4857 -
Fix
logging-fstring-interpolationfalse positive raised when logging and
f-string with%sformatting.
Closes #4984 -
Fix false-positive for
used-before-assignmentin pattern matching
with a guard.
Closes #5327 -
Fix
use-sequence-for-iterationwhen unpacking a set with*.
Closes #5788 -
Fix
deprecated-methodfalse positive when alias for method is similar to
name of deprecated method.
Closes #5886 -
Fix false positive
assigning-non-slotwhen a class attribute is
re-assigned.
Closes #6001 -
Fix false positive for
too-many-function-argswhen a function call is
assigned to a class attribute inside the class where the function is defined.
Closes #6592 -
Fixes false positive
abstract-methodon Protocol classes.
Closes #7209 -
Pylint now understands the
kw_onlykeyword argument fordataclass.
Closes #7290, closes #6550, closes #5857 -
Fix false positive for
undefined-loop-variableinfor-elseloops that
use a function
having a return type annotation ofNoReturnorNever.
Closes #7311 -
Fix
used-before-assignmentfor functions/classes defined in type checking
guard.
Closes #7368 -
Fix false positive for
unhashable-memberwhen subclassingdictand
using the subclass as a dictionary key.
Closes #7501 -
Fix the message for
unnecessary-dunder-callfor__aiter__and
__aneext__. Also
only emit the warning whenpy-version>= 3.10.
Closes #7529 -
Fix
used-before-assignmentfalse positive when else branch calls
sys.exitor similar terminating functions.
Closes #7563 -
Fix a false positive for
used-before-assignmentfor imports guarded by
typing.TYPE_CHECKINGlater used in variable annotations.
Closes #7609 -
Fix a false positive for
simplify-boolean-expressionwhen multiple values
are inferred for a constant.
Closes #7626 -
unnecessary-list-index-lookupwill not be wrongly emitted if
enumerateis called withstart.
Closes #7682 -
Don't warn about
stop-iteration-returnwhen usingnext()over
itertools.cycle.
Closes #7765 -
Fixes
used-before-assignmentfalse positive when the walrus operator
is used in a ternary operator.
Closes #7779 -
Fix
missing-param-docfalse positive when function parameter has an
escaped underscore.
Closes #7827 -
Fixes
method-cache-max-size-nonefalse positive for methods inheriting
fromEnum.
Closes #7857 -
multiple-statementsno longer triggers for function stubs using inlined
....
Closes #7860 -
Fix a false positive for
used-before-assignmentwhen a name guarded by
if TYPE_CHECKING:is used as a type annotation in a function body and
later re-imported in the same scope.
Closes #7882 -
Prevent
used-before-assignmentwhen imports guarded byif TYPE_CHECKING
are guarded again when used.
Closes #7979 -
Fixes false positive for
try-except-raisewith multiple exceptions in one
except statement if exception are in different namespace.
Closes #8051 -
Fix
invalid-nameerrors fortyping_extension.TypeVar.
Refs #8089 -
Fix
no-kwoafalse positive for context managers.
Closes #8100 -
Fix a false positive for
redefined-variable-typewhenasyncmethods
are present.
Closes #8120
False Negatives Fixed
-
Code following a call to
quit,exit,sys.exitoros._exit
will be marked asunreachable.
Refs #519 -
Emit
used-before-assignmentwhen function arguments are redefined inside
an inner function and accessed there before assignment.
Closes #2374
...
v2.16.0b1
New beta release following a performance fix in the new pointless exception statement checks in #8073 and a false positive fixed in the unreleased consider-using-augmented-assign check in #8088. We're also using the latest version of astroid (2.13.3).
The complete changelog will be published when the actual 2.16.0 is released.
v2.16.0b0
This is the beta version of 2.16.0 the complete changelog will be published when the actual 2.16.0 is released.
In 2.16.0 we added aggregation and composition understanding in pyreverse, and a way to clear the cache in between run in server mode (originally for the VS Code integration). Apart from the bug fixes there's also a lot of new checks, and new extensions that have been asked for for a long time that were implemented.
If you want to benefit from all the new checks load the following plugins:
pylint.extensions.dict_init_mutate,
pylint.extensions.dunder,
pylint.extensions.typing,
pylint.extensions.magic_value,
We still welcome any community effort to help review, integrate, and add good/bad examples to the doc for #5953. This should be doable without any pylint or astroid knowledge, so this is the perfect entrypoint if you want to contribute to pylint or open source without any experience with our code!
Last but not least @clavedeluna and @nickdrozd became triagers, welcome to the team !
v2.15.10
False Positives Fixed
-
Fix
use-sequence-for-iterationwhen unpacking a set with*.Closes #5788
-
Fix false positive
assigning-non-slotwhen a class attribute is
re-assigned.Closes #6001
-
Fixes
used-before-assignmentfalse positive when the walrus operator
is used in a ternary operator.Closes #7779
-
Prevent
used-before-assignmentwhen imports guarded byif TYPE_CHECKING
are guarded again when used.Closes #7979
Other Bug Fixes
-
Using custom braces in
msg-templatewill now work properly.Closes #5636
v2.15.9
False Positives Fixed
-
Fix false-positive for
used-before-assignmentin pattern matching with a guard.Closes #5327
Other Bug Fixes
-
Pylint will no longer deadlock if a parallel job is killed but fail immediately instead.
Closes #3899
-
When pylint exit due to bad arguments being provided the exit code will now be the expected
32.Refs #7931
-
Fixes a
ModuleNotFoundexception when running pylint on a Django project with thepylint_djangoplugin enabled.Closes #7938