Releases: pylint-dev/pylint
v2.14.3
-
Fixed two false positives for
bad-super-callfor calls that refer to a non-direct parent. -
Fixed a false positive for
useless-super-delegationfor subclasses that specify the number of
of parameters against a parent that uses a variadic argument.Closes #2270
-
Allow suppressing
undefined-loop-variableandundefined-variablewithout raisinguseless-suppression. -
Fixed false positive for
undefined-variablefor__class__in inner methods.Closes #4032
v2.14.2
-
Fixed a false positive for
unused-variablewhen a function returns an
argparse.Namespaceobject.Closes #6895
-
Avoided raising an identical
undefined-loop-variablemessage twice on the same line. -
Don't crash if
lint.run._query_cpu()is run within a Kubernetes Pod, that has only
a fraction of a cpu core assigned. Just go with one process then.Closes #6902
-
Fixed a false positive in
consider-using-f-stringif the left side of a%is not a string.Closes #6689
-
Fixed a false positive in
unnecessary-list-index-lookupandunnecessary-dict-index-lookup
when the subscript is updated in the body of a nested loop.Closes #6818
-
Fixed an issue with multi-line
init-hookoptions which did not record the line endings.Closes #6888
-
Fixed a false positive for
used-before-assignmentwhen a try block returns
but an except handler defines a name via type annotation. -
--errors-onlyno longer enables previously disabled messages. It was acting as
"emit all and only error messages" without being clearly documented that way.Closes #6811
v2.14.1
-
Avoid reporting
unnecessary-dict-index-lookuporunnecessary-list-index-lookup
when the index lookup is part of a destructuring assignment.Closes #6788
-
Fixed parsing of unrelated options in
tox.ini.Closes #6800
-
Fixed a crash when linting
__new__()methods that return a call expression.Closes #6805
-
Don't crash if we can't find the user's home directory.
Closes #6802
-
Fixed false positives for
unused-importwhen aliasingtypinge.g. ast
and guarding imports undert.TYPE_CHECKING.Closes #3846
-
Fixed a false positive regression in 2.13 for
used-before-assignmentwhere it is safe to rely
on a name defined only in anexceptblock because theelseblock returned.Closes #6790
-
Fixed the use of abbreviations for some special options on the command line.
Closes #6810
-
Fix a crash in the optional
pylint.extensions.private_importextension.Closes #6624
-
bad-option-value(E0012) is now a warningunknown-option-value(W0012). Deleted messages that do not exist
anymore in pylint now raiseuseless-option-value(R0022) instead ofbad-option-value. This allows to
distinguish between genuine typos and configuration that could be cleaned up. Existing message disables for
bad-option-valuewill still work on both new messages.Refs #6794
v3.0.0-a5
This is 2.14.0 with breaking changes for 3.0 included. Released only so that the old alpha 4 release based on pylint 2.9.0 is not proposed by tools instead of 2.14.0. 2.14.0 is the stable version you should use that.
v2.14.0
Summary -- Release highlights
With 2.14 pylint only supports Python version 3.7.2 and above.
We introduced several new checks among which duplicate-value for sets,
comparison-of-constants, and checks related to lambdas. We removed no-init and
made no-self-use optional as they were too opinionated. We also added an option
to generate a toml configuration: --generate-toml-config.
We migrated to argparse from optparse and refactored the configuration handling
thanks to Daniël van Noord. On the user side it should change the output of the
--help command, and some inconsistencies and bugs should disappear. The behavior
between options set in a config file versus on the command line will be more consistent. For us,
it will permit to maintain this part of the code easily in the future and anticipate
optparse's removal in Python 3.12.
As a result of the refactor there are a lot of internal deprecations. If you're a library
maintainer that depends on pylint, please verify that you're ready for pylint 3.0
by activating deprecation warnings.
We continued the integration of pylint-error and are now at 33%!. We still welcome
any community effort to help review, integrate, and add good/bad examples in #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!
New checkers
-
Added new checker
comparison-of-constants.Closes #6076
-
Added new checker
typevar-name-mismatch: TypeVar must be assigned to a variable with the same name as its name argument.Closes #5224
-
invalid-enum-extension: Used when a class tries to extend an inherited Enum class.Closes #5501
-
Added new checker
typevar-double-variance: The "covariant" and "contravariant" keyword arguments
cannot both be set to "True" in a TypeVar.Closes #5895
-
Add new check
unnecessary-dunder-callfor unnecessary dunder method calls.Closes #5936
-
unnecessary-lambda-assignment: Lambda expression assigned to a variable.
Define a function using the "def" keyword instead.
unnecessary-direct-lambda-call: Lambda expression called directly.
Execute the expression inline instead.Closes #5976
-
potential-index-error: Emitted when the index of a list or tuple exceeds its length.
This checker is currently quite conservative to avoid false positives. We welcome
suggestions for improvements.Closes #578
-
Added new checker
unnecessary-list-index-lookupfor indexing into a list while
iterating overenumerate().Closes #4525
-
Added new message called
duplicate-valuewhich identifies duplicate values inside sets.Closes #5880
-
Added the
super-without-bracketschecker, raised when a super call is missing its brackets.Closes #4008
Removed checkers
-
The
no-init(W0232) warning has been removed. It's ok to not have an__init__in a class.Closes #2409
-
Removed the
assign-to-new-keywordmessage as there are no new keywords in the supported Python
versions any longer.Closes #4683
-
Moved
no-self-usecheck to optional extension.
You now need to explicitly enable this check using
load-plugins=pylint.extensions.no_self_use.Closes #5502
Extensions
-
RedefinedLoopNameChecker- Added optional extension
redefined-loop-nameto emit messages when a loop variable
is redefined in the loop body.
Closes #5072
- Added optional extension
-
DocStringStyleChecker- Re-enable checker
bad-docstring-quotesfor Python <= 3.7.
Closes #6087
- Re-enable checker
-
NoSelfUseChecker- Added
no-self-usecheck, previously enabled by default.
Closes #5502
- Added
Other Changes
-
Started ignoring underscore as a local variable for
too-many-locals.Closes #6488
-
Pylint can now be installed with an extra-require called
spelling(pip install pylint[spelling]).
This will addpyenchantto pylint's dependencies. You will still need to install the
requirements forpyenchant(theenchantlibrary and any dictionaries) yourself. You will also
need to set thespelling-dictoption.Refs #6462
-
Improved wording of the message of
deprecated-moduleCloses #6169
-
Pylintnow requires Python 3.7.2 or newer to run.Closes #4301
-
We made a greater effort to reraise failures stemming from the
astroid
library asAstroidError, with the effect that pylint emitsastroid-error
rather than merelyfatal. Regardless, please report any such issues you encounter! -
We have improved our recognition of inline disable and enable comments. It is
now possible to disablebad-option-valueinline (as long as you disable it before
the bad option value is raised, i.e.disable=bad-option-value,bad-messagenotdisable=bad-message,bad-option-value) as well as certain other
previously unsupported messages.Closes #3312
-
The main checker name is now
maininstead ofmaster. The configuration does not need to be updated as sections' name are optional.Closes #5467
-
Update
invalid-slots-objectmessage to show bad object rather than its inferred value.Closes #6101
-
Fixed a crash in the
not-an-iterablechecker involving multiple starred expressions
inside a call.Closes #6372
-
Fixed a crash in the
unused-private-memberchecker involving chained private attributes.Closes #6709
-
Disable spellchecking of mypy rule names in ignore directives.
Closes #5929
-
implicit-str-concatwill now be raised on calls likeopen("myfile.txt" "a+b")too.Closes #6441
-
Fix a failure to respect inline disables for
fixmeoccurring on the last line
of a module when pylint is launched with--enable=fixme. -
Removed the broken
generate-manoption. -
Fixed failure to enable
deprecated-moduleafter adisable=all
by makingImportsCheckersolely responsible for emittingdeprecated-moduleinstead
of sharing responsibility withStdlibChecker. (This could have led to double messages.) -
Added the
generate-toml-configoption.Refs #5462
-
bad-option-valuewill be emitted whenever a configuration value or command line invocation
includes an unknown message.Closes #4324
-
Added the
unrecognized-optionmessage. Raised if we encounter any unrecognized options.Closes #5259
-
Fix false negative for
bad-string-format-typeif the value to be formatted is passed in
as a variable holding a constant. -
The concept of checker priority has been removed.
-
The
cache-max-size-nonechecker has been renamed tomethod-cache-max-size-none.Closes #5670
-
The
method-cache-max-size-nonechecker will now also checkfunctools.cache.Closes #5670
-
BaseCheckerclasses now require thelinterargument to be passed. -
The
set_config_directlydecorator has been removed. -
Don't report
useless-super-delegationfor the__hash__method in classes that also override the__eq__method.Closes #3934
-
Fix falsely issuing
useless-suppressionon thewrong-import-positionchecker.Closes #5219
-
Fixed false positive
no-memberfor Enums with self-defined members.Closes #5138
-
Fix false negative for
no-memberwhen attempting to assign an instance
attribute to itself without any prior assignment.Closes #1555
-
Changed message type from
redefined-outer-nametoredefined-loop-name
(optional extension) for redefinitions of outer loop variables by inner loops.Closes #5608
-
By default the similarity checker will now ignore imports and ignore function signatures when computing
duplication. If you want to keep the previous behaviour setignore-importsandignore-signaturestoFalse. -
Pylint now expands the user path (i.e.
~tohome/yusef/) and expands environment variables (i.e.home/$USER/$project
tohome/yusef/pylintforUSER=yusefandproject=pylint) for pyreverse'soutput-directory,
import-graph,ext-import-graph,int-import-graphoptions, and the spell checker'sspelling-private-dict-file
option.Refs #6493
-
Don't emit
unsubscriptable-objectfor string annotations.
Pylint doesn't check if class is only generic in type stubs only. -
Fix pyreverse crash
RuntimeError: dictionary changed size during iterationRefs #6612
-
Fix syntax for return type annotations in MermaidJS diagrams produced with
pyreverse.Closes #6467
-
Fix type annotations of class and instance attributes using the alternative union syntax in
pyreversediagrams. -
Fix bug where it writes a plain text error message to stdout, invalidating output formats.
Closes #6597
-
The refactoring checker now also raises 'consider-using-a-generator' messages for
max(),min()andsum().Refs #6595
-
Update ranges for
using-constant-testandmissing-parentheses-for-call-in-test
error messages. -
Don't emit
no-memberinside type annotations with
from __future__ import annotations.Closes #6594
-
Fix
unexpected-special-method-signaturefalse positive for__init_subclass__methods with one or more arguments.Closes #6644
Deprecations
-
The
ignore-mixin-membersoption has been deprecated. You should now use the new
ignored-checks-for-mixinsoption.Closes #5205
-
interfaces.implementshas b...
v2.13.9
2.13.9 is the last release supporting python interpreter between 3.6.2 and 3.7.2.
-
Respect ignore configuration options with
--recursive=y.Closes #6471
-
Fix false positives for
no-name-in-moduleandimport-errorfornumpy.distutilsandpydantic.Closes #6497
-
Fix
IndexErrorcrash inuninferable_final_decoratorsmethod.Relates to #6531
-
Fix a crash in
unnecessary-dict-index-lookupwhen subscripting an attribute.Closes #6557
-
Fix a crash when accessing
__code__and assigning it to a variable.Closes #6539
-
Fix a false positive for
undefined-loop-variablewhen usingenumerate().Closes #6593
2.14.0-b1
Provisional changelog for 2.14.0:
-
We have improved our recognition of inline disable and enable comments. It is
now possible to disablebad-option-valueinline (as long as you disable it before
the bad option value is raised, i.e.disable=bad-option-value,bad-messagenotdisable=bad-message,bad-option-value) as well as certain other previously unsupported messages.Closes #3312
-
Added new checker
comparison-of-constants.Closes #6076
-
Started ignoring underscore as a local variable for
too-many-locals.Closes #6488
-
Improved wording of the message of
deprecated-moduleCloses #6169
-
Pylintnow requires Python 3.7.2 or newer to run.Closes #4301
-
BaseCheckerclasses now require thelinterargument to be passed. -
Fix a failure to respect inline disables for
fixmeoccurring on the last line
of a module when pylint is launched with--enable=fixme. -
Update
invalid-slots-objectmessage to show bad object rather than its inferred value.Closes #6101
-
The main checker name is now
maininstead ofmaster. The configuration does not need to be updated as sections' name are optional.Closes #5467
-
Added new checker
typevar-name-mismatch: TypeVar must be assigned to a variable with the same name as its name argument.Closes #5224
-
Pylint can now be installed with an extra-require called
spelling(pip install pylint[spelling]).
This will addpyenchantto pylint's dependencies. You will still need to install the
requirements forpyenchant(theenchantlibrary and any dictionaries) yourself. You will also
need to set thespelling-dictoption.Refs #6462
-
Removed the
assign-to-new-keywordmessage as there are no new keywords in the supported Python
versions any longer.Closes #4683
-
Fixed a crash in the
not-an-iterablechecker involving multiple starred expressions
inside a call.Closes #6372
-
Fixed failure to enable
deprecated-moduleafter adisable=all
by makingImportsCheckersolely responsible for emittingdeprecated-moduleinstead
of sharing responsibility withStdlibChecker. (This could have led to double messages.) -
The
no-init(W0232) warning has been removed. It's ok to not have an__init__in a class.Closes #2409
-
The
configattribute ofBaseCheckerhas been deprecated. You can usechecker.linter.config
to access the global configuration object instead of a checker-specific object.Ref #5392
-
The
levelattribute ofBaseCheckerhas been deprecated: everything is now
displayed in--help, all the time.Ref #5392
-
The
options_providersattribute ofArgumentsManagerhas been deprecated.Ref #5392
-
The
option_groupsattribute ofPyLinterhas been deprecated.Ref #5392
-
All
Interfaceclasses inpylint.interfaceshave been deprecated. You can subclass
the respective normal classes to get the same behaviour. The__implements__functionality
was based on a rejected PEP from 2001:
https://peps.python.org/pep-0245/Closes #2287
-
The
set_optionmethod ofBaseCheckerhas been deprecated. You can usechecker.linter.set_option
to set an option on the global configuration object instead of a checker-specific object.Ref #5392
-
implicit-str-concatwill now be raised on calls likeopen("myfile.txt" "a+b")too.Closes #6441
-
The
configattribute ofPyLinteris now of theargparse.Namespacetype instead of
optparse.Values.Ref #5392
-
MapReduceMixinhas been deprecated.BaseCheckernow implementsget_map_dataand
reduce_map_data. If a checker actually needs to reduce data it should defineget_map_data
as returning something different thanNoneand let itsreduce_map_datahandle a list
of the types returned byget_map_data.
An example can be seen by looking atpylint/checkers/similar.py. -
UnsupportedActionhas been deprecated.Ref #5392
-
OptionsManagerMixInhas been deprecated.Ref #5392
-
OptionParserhas been deprecated.Ref #5392
-
Optionhas been deprecated.Ref #5392
-
OptionsProviderMixInhas been deprecated.Ref #5392
-
ConfigurationMixInhas been deprecated.Ref #5392
-
get_global_confighas been deprecated. You can now access all global options from
checker.linter.config.Ref #5392
-
OptionsManagerMixInhas been replaced withArgumentsManager.ArgumentsManageris considered
private API and most methods that were public onOptionsManagerMixInhave now been deprecated and will
be removed in a future release.Ref #5392
-
OptionsProviderMixInhas been replaced withArgumentsProvider.ArgumentsProvideris considered
private API and most methods that were public onOptionsProviderMixInhave now been deprecated and will
be removed in a future release.Ref #5392
-
interfaces.implementshas been deprecated and will be removed in 3.0. Please use standard inheritance
patterns instead of__implements__.Ref #2287
-
invalid-enum-extension: Used when a class tries to extend an inherited Enum class.Closes #5501
-
Added the
unrecognized-optionmessage. Raised if we encounter any unrecognized options.Closes #5259
-
Added new checker
typevar-double-variance: The "covariant" and "contravariant" keyword arguments
cannot both be set to "True" in a TypeVar.Closes #5895
-
Re-enable checker
bad-docstring-quotesfor Python <= 3.7.Closes #6087
-
Removed the broken
generate-manoption. -
Fix false negative for
bad-string-format-typeif the value to be formatted is passed in
as a variable holding a constant. -
Add new check
unnecessary-dunder-callfor unnecessary dunder method calls. -
The
cache-max-size-nonechecker has been renamed tomethod-cache-max-size-none.Closes #5670
-
The
method-cache-max-size-nonechecker will now also checkfunctools.cache.Closes #5670
-
unnecessary-lambda-assignment: Lambda expression assigned to a variable.
Define a function using the "def" keyword instead.
unnecessary-direct-lambda-call: Lambda expression called directly.
Execute the expression inline instead.Closes #5976
-
potential-index-error: Emitted when the index of a list or tuple exceeds its length.
This checker is currently quite conservative to avoid false positives. We welcome
suggestions for improvements.Closes #578
-
Added optional extension
redefined-loop-nameto emit messages when a loop variable
is redefined in the loop body.Closes #5072
-
Changed message type from
redefined-outer-nametoredefined-loop-name
(optional extension) for redefinitions of outer loop variables by inner loops.Closes #5608
-
The
ignore-mixin-membersoption has been deprecated. You should now use the new
ignored-checks-for-mixinsoption.Closes #5205
-
bad-option-valuewill be emitted whenever a configuration value or command line invocation
includes an unknown message.Closes #4324
-
Avoid reporting
superfluous-parenson expressions using theis notoperator.Closes #5930
-
Added the
super-without-bracketschecker, raised when a super call is missing its brackets.Closes #4008
-
Added the
generate-toml-configoption.Ref #5462
-
Added new checker
unnecessary-list-index-lookupfor indexing into a list while
iterating overenumerate().Closes #4525
-
Fix falsely issuing
useless-suppressionon thewrong-import-positionchecker.Closes #5219
-
Fixed false positive
no-memberfor Enums with self-defined members.Closes #5138
-
Fix false negative for
no-memberwhen attempting to assign an instance
attribute to itself without any prior assignment.Closes #1555
-
The concept of checker priority has been removed.
-
Add a new command line option
--minimal-messages-configforpytest, which disables all
irrelevant messages when running the functional tests. -
duplicate-argument-namenow only raises once for each set of duplicated arguments. -
Fix bug where specifically enabling just
await-outside-asyncwas not possible. -
The
set_config_directlydecorator has been removed. -
Added new message called
duplicate-valuewhich identifies duplicate values inside sets.Closes #5880
-
Pylint now expands the user path (i.e.
~tohome/yusef/) and expands environment variables (i.e.home/$USER/$project
tohome/yusef/pylintforUSER=yusefandproject=pylint) for pyreverse'soutput-directory,
import-graph,ext-import-graph,int-import-graphoptions, and the spell checker'sspelling-private-dict-file
option.Relates to #6493
-
Created
NoSelfUseCheckerextension and moved theno-self-usecheck.
You now need to explicitly enable this check using
load-plugins=pylint.extensions.no_self_use.Closes #5502
-
Fix saving of persistent data files in environments where the user's cache
directory and the linted file are on a different drive.Closes #6394
-
Don't emit
unsubscriptable-objectfor string annotations.
Pylint doesn't check if class is only generic in type stubs only. -
is_class_subscriptable_pep585_with_postponed_evaluation_enabledhas been deprecated.
Usesubscriptable_with_postponed_evaluation_enabledinstead.Ref #6536
v2.13.8
-
Fix a false positive for
undefined-loop-variablefor a variable used in a lambda
inside the first of multiple loops.Closes #6419
-
Fix a crash when linting a file that passes an integer
mode=toopenCloses #6414
-
Avoid reporting
superfluous-parenson expressions using theis notoperator.Closes #5930
-
Fix a false positive for
undefined-loop-variablewhen theelseof afor
loop raises or returns.Closes #5971
-
Fix false positive for
unused-variablefor classes inside functions
and where a metaclass is provided via a call.Closes #4020
-
Fix false positive for
unsubscriptable-objectin Python 3.8 and below for
statements guarded byif TYPE_CHECKING.Closes #3979
v2.13.7
v2.13.6
-
Fix a crash in the
unsupported-membership-testchecker when assigning
multiple constants to class attributes including__iter__via unpacking.Closes #6366
-
Asterisks are no longer required in Sphinx and Google style parameter documentation
formissing-param-docand are parsed correctly. -
Fixed a false positive for
unused-variablewhen a builtin specified in
--additional-builtinsis given a type annotation.Closes #6388
-
Fixed an
AstroidErrorin 2.13.0 raised by theduplicate-codechecker with
ignore-importsorignore-signaturesenabled.Closes #6301