Update dependency pylint to v2.16.2 #47
Reference in New Issue
Block a user
Delete Branch "renovate/pylint-2.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
==2.15.10->==2.16.2Release Notes
PyCQA/pylint
v2.16.2Compare Source
New Features
Add
--versionoption topyreverse.Refs #7851
False Positives Fixed
Fix false positive for
used-before-assignmentwhentyping.TYPE_CHECKINGis used with if/elif/else blocks.Closes #7574
Fix false positive for
used-before-assignmentfor named expressionsappearing after the first element in a list, tuple, or set.
Closes #8252
Other Bug Fixes
Fix
used-before-assignmentfalse positive when the walrus operatoris used with a ternary operator in dictionary key/value initialization.
Closes #8125
Fix
no-name-in-modulefalse positive raised when a package defines avariable with the same name as one of its submodules.
Closes #8148
Fix
nested-min-maxsuggestion message to indicate it's possible to splatiterable 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: 2.16.1Compare Source
Other Bug Fixes
Fix a crash happening for python interpreter < 3.9 following a failed typing
update.
Closes #8161
v2.16.0: 2.16.0Compare Source
Summary -- Release highlights
In 2.16.0 we added aggregation and composition understanding in
pyreverse, and a way to clearthe 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::
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
pylintorastroidknowledge, so this is the perfect entrypoint if you want to contribute to
pylintor open source withoutany 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 nowbe 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 add
accept-no-raise-doc=noin your configuration to keepthe 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 theoutput.
Closes #5362
Added configuration option
clear-cache-post-runto support server-likeusage.
Use this flag if you expect the linted files to be altered between runs.
Refs #5401
Add
--allow-reexport-from-packageoption to configure theuseless-import-aliascheck not to emit a warning if a nameis 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 methodparameters (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 anException 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 unbalanceddict unpacking
in assignment and for loops.
Closes #5797
Add new checker
positional-only-arguments-expectedto check for caseswhen
positional-only arguments have been passed as keyword arguments.
Closes #6489
Added
singledispatch-methodwhich informs that@singledispatchshoulddecorate functions and not class/instance methods.
Added
singledispatchmethod-functionwhich informs that@singledispatchmethodshould decorate class/instance methods and notfunctions.
Closes #6917
Rename
broad-excepttobroad-exception-caughtand add new checkerbroad-exception-raisedwhich will warn if general exceptions
BaseExceptionorExceptionareraised.
Closes #7494
Added
nested-min-maxwhich flagsmin(1, min(2, 3))to simplify tomin(1, 2, 3).Closes #7546
Extended
use-dict-literalto also warn about call todict()whenpassing keyword arguments.
Closes #7690
Add
named-expr-without-contextcheck to emit a warning if a namedexpression is used outside a context like
if,for,while, ora comprehension.
Refs #7760
Add
invalid-slice-stepcheck to warn about a slice step value of0for common builtin sequences.
Refs #7762
Add
consider-refactoring-into-while-conditioncheck to recommendrefactoring when
a while loop is defined with a constant condition with an immediate
ifstatement to check for
breakcondition as a first statement.Closes #8015
Extensions
Add new extension checker
dict-init-mutatethat flags mutating adictionary immediately
after the dictionary was created.
Closes #2876
Added
bad-dunder-nameextension check, which flags bad or misspelleddunder methods.
You can use the
good-dunder-namesoption to allow specific dunder names.Closes #3038
Added
consider-using-augmented-assigncheck forCodeStyleextensionwhich flags
x = x + 1to simplify tox += 1.This check is disabled by default. To use it, load the code style extension
with
load-plugins=pylint.extensions.code_styleand addconsider-using-augmented-assignin theenableoption.Closes #3391
Add
magic-numberplugin checker for comparison with constants instead ofnamed constants or enums.
You can use it with
--load-plugins=pylint.extensions.magic_value.Closes #7281
Add
redundant-typehint-argumentmessage fortypingplugin for duplicateassign 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 nameis only used in a string literal type annotation.
Closes #3299
Document a known false positive for
useless-suppressionwhen disablingline-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 globalvariable is re-assigned via an
ImportFromnode.Closes #4809
Fix false positive for
use-maxsplit-argwith custom split method.Closes #4857
Fix
logging-fstring-interpolationfalse positive raised when logging andf-string with
%sformatting.Closes #4984
Fix false-positive for
used-before-assignmentin pattern matchingwith 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 toname of deprecated method.
Closes #5886
Fix false positive
assigning-non-slotwhen a class attribute isre-assigned.
Closes #6001
Fix false positive for
too-many-function-argswhen a function call isassigned 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 thatuse a function
having a return type annotation of
NoReturnorNever.Closes #7311
Fix
used-before-assignmentfor functions/classes defined in type checkingguard.
Closes #7368
Fix false positive for
unhashable-memberwhen subclassingdictandusing the subclass as a dictionary key.
Closes #7501
Fix the message for
unnecessary-dunder-callfor__aiter__and__aneext__. Alsoonly emit the warning when
py-version>= 3.10.Closes #7529
Fix
used-before-assignmentfalse positive when else branch callssys.exitor similar terminating functions.Closes #7563
Fix a false positive for
used-before-assignmentfor imports guarded bytyping.TYPE_CHECKINGlater used in variable annotations.Closes #7609
Fix a false positive for
simplify-boolean-expressionwhen multiple valuesare inferred for a constant.
Closes #7626
unnecessary-list-index-lookupwill not be wrongly emitted ifenumerateis called withstart.Closes #7682
Don't warn about
stop-iteration-returnwhen usingnext()overitertools.cycle.Closes #7765
Fixes
used-before-assignmentfalse positive when the walrus operatoris used in a ternary operator.
Closes #7779
Fix
missing-param-docfalse positive when function parameter has anescaped underscore.
Closes #7827
Fixes
method-cache-max-size-nonefalse positive for methods inheritingfrom
Enum.Closes #7857
multiple-statementsno longer triggers for function stubs using inlined....Closes #7860
Fix a false positive for
used-before-assignmentwhen a name guarded byif TYPE_CHECKING:is used as a type annotation in a function body andlater re-imported in the same scope.
Closes #7882
Prevent
used-before-assignmentwhen imports guarded byif TYPE_CHECKINGare guarded again when used.
Closes #7979
Fixes false positive for
try-except-raisewith multiple exceptions in oneexcept 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-typewhenasyncmethodsare present.
Closes #8120
False Negatives Fixed
Code following a call to
quit,exit,sys.exitoros._exitwill be marked as
unreachable.Refs #519
Emit
used-before-assignmentwhen function arguments are redefined insidean inner function and accessed there before assignment.
Closes #2374
Fix a false negative for
unused-importwhen one module used an import ina type annotation that was also used in another module.
Closes #4150
Flag
superfluous-parensif parentheses are used during stringconcatenation.
Closes #4792
Emit
used-before-assignmentwhen relying on names only defined underconditions always testing false.
Closes #4913
consider-using-joincan now be emitted for non-empty string separators.Closes #6639
Emit
used-before-assignmentfor further imports guarded byTYPE_CHECKINGPreviously, this message was only emitted for imports guarded directly under
TYPE_CHECKING, not guarded two if-branches deep, nor whenTYPE_CHECKINGwas imported from
typingunder an alias.Closes #7539
Fix a false negative for
unused-importwhen a constant insidetyping.Annotatedwas treated as a reference to an import.Closes #7547
consider-using-any-or-allmessage will now be raised in cases whenboolean is initialized, reassigned during loop, and immediately returned.
Closes #7699
Extend
invalid-slice-indexto emit an warning for invalid slice indicesused with string and byte sequences, and range objects.
Refs #7762
Fixes
unnecessary-list-index-lookupfalse negative whenenumerateiscalled with
iterableas a kwarg.Closes #7770
no-else-returnorno-else-raisewill be emitted ifexceptblockalways returns or raises.
Closes #7788
Fix
dangerous-default-valuefalse negative when*is used.Closes #7818
consider-using-withnow triggers forpathlib.Path.open.Closes #7964
Other Bug Fixes
Fix bug in detecting
unused-variablewhen iterating on variable.Closes #3044
Fix bug in scanning of names inside arguments to
typing.Literal.See https://peps.python.org/pep-0586/#literals-enums-and-forward-references
for details.
Refs #3299
Update
disallowed-namecheck to flag module-level variables.Closes #3701
Pylint will no longer deadlock if a parallel job is killed but fail
immediately instead.
Closes #3899
Fix ignored files being linted when passed on stdin.
Closes #4354
Fix
no-memberfalse negative when augmented assign is done manually,without
+=.Closes #4562
Any assertion on a populated tuple will now receive a
assert-on-tuplewarning.
Closes #4655
missing-return-doc,missing-raises-docandmissing-yields-docnowrespect
the
no-docstring-rgxoption.Closes #4743
Update
reimportedhelp message for clarity.Closes #4836
consider-iterating-dictionarywill no longer be raised if bitwiseoperations are used.
Closes #5478
Using custom braces in
msg-templatewill now work properly.Closes #5636
Pylint will now filter duplicates given to it before linting. The output
should
be the same whether a file is given/discovered multiple times or not.
Closes #6242, #4053
Remove
__index__dunder method call fromunnecessary-dunder-callcheck.
Closes #6795
Fixed handling of
--as separator between positional arguments and flags.This was not actually fixed in 2.14.5.
Closes #7003, Refs #7096
Don't crash on
OSErrorin config file discovery.Closes #7169
Messages sent to reporter are now copied so a reporter cannot modify the
message sent to other reporters.
Closes #7214
Fixed a case where custom plugins specified by command line could silently
fail.
Specifically, if a plugin relies on the
init-hookoption changingsys.pathbeforeit can be imported, this will now emit a
bad-plugin-valuemessage. Beforethis
change, it would silently fail to register the plugin for use, but would load
any configuration, which could have unintended effects.
Fixes part of #7264.
Update
modified_iteratingchecker to fix a crash withforloops onempty list.
Closes #7380
Update wording for
arguments-differandarguments-renamedto clarifyoverriding object.
Closes #7390
disable-nextis now correctly scoped to only the succeeding line.Closes #7401
Fixed a crash in the
unhashable-memberchecker when using alambdaasa dict key.
Closes #7453
Add
mailcapto deprecated modules list.Closes #7457
Fix a crash in the
modified-iterating-dictchecker involving instanceattributes.
Closes #7461
invalid-class-objectdoes not crash anymore when__class__isassigned alongside another variable.
Closes #7467
--help-msgnow accepts a comma-separated list of message IDs again.Closes #7471
Allow specifying non-builtin exceptions in the
overgeneral-exceptionoption
using an exception's qualified name.
Closes #7495
Report
no-self-argumentrather thanno-method-argumentfor methodswith variadic arguments.
Closes #7507
Fixed an issue where
syntax-errorcouldn't be raised on files withinvalid encodings.
Closes #7522
Fix false positive for
redefined-outer-namewhen aliasingtypinge.g. as
tand guarding imports undert.TYPE_CHECKING.Closes #7524
Fixed a crash of the
modified_iteratingchecker when iterating on a setdefined as a class attribute.
Closes #7528
Use
py-versionto determine if a message should be emitted for messagesdefined with
max-versionormin-version.Closes #7569
Improve
bad-thread-instantiationcheck to warn iftargetis notpassed in as a keyword argument
or as a second argument.
Closes #7570
Fixes edge case of custom method named
nextraised an astroid error.Closes #7610
Fixed a multi-processing crash that prevents using any more than 1 thread on
MacOS.
The returned module objects and errors that were cached by the linter plugin
loader
cannot be reliably pickled. This means that
dillwould throw an errorwhen
attempting to serialise the linter object for multi-processing use.
Closes #7635.
Fix crash that happened when parsing files with unexpected encoding starting
with 'utf' like
utf13.Closes #7661
Fix a crash when a child class with an
__init__method inherits from aparent class with an
__init__class attribute.Closes #7742
Fix
valid-metaclass-classmethod-first-argdefault config value from "cls"to "mcs"
which would cause both a false-positive and false-negative.
Closes #7782
Fixes a crash in the
unnecessary_list_index_lookupcheck when usingenumeratewithstartand a class attribute.Closes #7821
Fixes a crash in
stop-iteration-returnwhen thenextbuiltin iscalled without arguments.
Closes #7828
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 projectwith the
pylint_djangoplugin enabled.Closes #7938
Fixed a crash when inferring a value and using its qname on a slice that was
being incorrectly called.
Closes #8067
Use better regex to check for private attributes.
Refs #8081
Fix issue with new typing Union syntax in runtime context for Python 3.10+.
Closes #8119
Other Changes
Pylint now provides basic support for Python 3.11.
Closes #5920
Update message for
abstract-methodto include child class name.Closes #7124
Update Pyreverse's dot and plantuml printers to detect when class methods are
abstract and show them with italic font.
For the dot printer update the label to use html-like syntax.
Closes #7346
The
docparamsextension now considers typing in Numpy style docstringsas "documentation" for the
missing-param-docmessage.Refs #7398
Relevant
DeprecationWarningsare now raised withstacklevel=2, sothey have the callsite attached in the message.
Closes #7463
Add a
minimaloption topylint-configand its toml generator.Closes #7485
Add method name to the error messages of
no-method-argumentandno-self-argument.Closes #7507
Prevent leaving the pip install cache in the Docker image.
Refs #7544
Add a keyword-only
compare_constantsargument tosafe_infer.Refs #7626
Add
default_enabledoption to optional message dict. Provides an optionto disable a checker message by default.
To use a disabled message, the user must enable it explicitly by adding the
message to the
enableoption.Refs #7629
Sort
--generated-rcfileoutput.Refs #7655
epylint is now deprecated and will be removed in pylint 3.0.0. All emacs and
flymake related
files were removed and their support will now happen in an external
repository :
https://github.com/emacsorphanage/pylint.
Closes #7737
Adds test for existing preferred-modules configuration functionality.
Refs #7957
Internal Changes
This shores up the tests that cover the loading of custom plugins as affected
by any changes made to the
sys.pathduring execution of aninit-hook.Given the existing contract of allowing plugins to be loaded by fiddling with
the path in this way, this is now the last bit of work needed to close Github
issue #7264.
Closes #7264
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.
Kudos, SonarCloud Quality Gate passed!