Releases: pylint-dev/pylint
v2.17.2
False Positives Fixed
-
invalid-name
now allows for integers intypealias
names:- now valid:
Good2Name
,GoodName2
. - still invalid:
_1BadName
.
Closes #8485
- now valid:
-
No longer consider
Union
as type annotation as type alias for naming
checks.Closes #8487
-
unnecessary-lambda
no longer warns on lambdas which use its parameters in
their body (other than the final arguments), e.g.
lambda foo: (bar if foo else baz)(foo)
.Closes #8496
Other Bug Fixes
-
Fix a crash in pyreverse when "/" characters are used in the output filename
e.g pyreverse -o png -p name/ path/to/project.Closes #8504
v3.0.0a6
3.0.0a6 is an alpha release, other breaking changes will be added before the official 3.0.0 release. We're including the new features and false negative fixes that will be in 3.0.0, so it's the latest current version of pylint.
Breaking Changes
-
pyreverse
now uses a new default color palette that is more colorblind
friendly.
The color scheme is taken from Paul Tol's Notes.
If you prefer other colors, you can use the--color-palette
option to
specify custom colors.Closes #8251
-
Everything related to the
__implements__
construct was removed. It was
based on PEP245
that was proposed in 2001 and rejected in 2006.The capability from pyreverse to take
__implements__
into account when
generating diagrams
was also removed.Refs #8404
-
pyreverse
: Support for the.vcg
output format (Visualaization of
Compiler Graphs) has been dropped.Closes #8416
-
The warning when the now useless old pylint cache directory (pylint.d) was
found was removed. The cache dir is documented in
the
FAQ.Refs #8462
Changes requiring user actions
-
epylint was removed. It now lives at:
https://github.com/emacsorphanage/pylint.Refs #7737
-
The 'overgeneral-exceptions' option now only takes fully qualified name
into account (builtins.Exception
notException
). If you overrode
this option, you need to use the fully qualified name now.There's still a warning, but it will be removed in 3.1.0.
Refs #8411
-
Following a deprecation period, it's no longer possible to use
MASTER
ormaster
as configuration section insetup.cfg
ortox.ini
. It's
bad practice
to not start sections titles with the tool name. Please usepylint.main
instead.Refs #8465
New Features
-
Add new option (
--show-stdlib
,-L
) topyreverse
.
This is similar to the behavior of--show-builtin
in that standard
library
modules are now not included by default, and this option will include them.Closes #8181
False Positives Fixed
-
Adds
asyncSetUp
to the defaultdefining-attr-methods
list to silence
attribute-defined-outside-init
warning when using
unittest.IsolatedAsyncioTestCase
.Refs #8403
-
invalid-name
now allows for integers intypealias
names:- now valid:
Good2Name
,GoodName2
. - still invalid:
_1BadName
.
Closes #8485
- now valid:
-
No longer consider
Union
as type annotation as type alias for naming
checks.Closes #8487
-
unnecessary-lambda
no longer warns on lambdas which use its parameters in
their body (other than the final arguments), e.g.
lambda foo: (bar if foo else baz)(foo)
.Closes #8496
Other Bug Fixes
-
--clear-cache-post-run
now also clears LRU caches for pylint utilities
holding references to AST nodes.Closes #8361
-
Fix a crash when
TYPE_CHECKING
is used without importing it.Closes #8434
-
Fix a
used-before-assignment
false positive when imports
are made under theTYPE_CHECKING
else if branch.Closes #8437
-
Fix a regression of
preferred-modules
where a partial match was used
instead of the required full match.Closes #8453
Other Changes
-
Pylint now exposes its type annotations.
-
All code related to the optparse config parsing has been removed.
Refs #8405
Internal Changes
-
get_message_definition
was removed from the base checker API. You can
access
message definitions through theMessageStore
.Refs #8401
-
Everything related to the
__implements__
construct was removed. It was
based on PEP245
that was proposed in 2001 and rejected in 2006.All the classes inheriting
Interface
inpylint.interfaces
were
removed.
Checker
should only inheritBaseChecker
or any of the other checker
types
frompylint.checkers
.Reporter
should only inheritBaseReporter
.Refs #8404
-
modname
andmsg_store
are now required to be given inFileState
.
collect_block_lines
has also been removed.Pylinter.current_name
cannot be null anymore.Refs #8407
-
'Reporter.set_output' was removed in favor of 'reporter.out = stream'.
Refs #8408
-
A number of old utility functions and classes have been removed:
MapReduceMixin
: To make a checker reduce map data simply implement
get_map_data
andreduce_map_data
.is_inside_lambda
: Useutils.get_node_first_ancestor_of_type(x, nodes.Lambda)
check_messages
: Useutils.only_required_for_messages
is_class_subscriptable_pep585_with_postponed_evaluation_enabled
: Use
is_postponed_evaluation_enabled(node)
and
is_node_in_type_annotation_context(node)
get_python_path
: assumption that there's always an init.py is not
true since
python 3.3 and is causing problems, particularly with PEP 420. Use
discover_package_path
and pass source root(s).fix_import_path
: Useaugmented_sys_path
and pass additional
sys.path
entries as an argument obtained fromdiscover_package_path
.get_global_option
: Usechecker.linter.config
to get all global
options.Related private objects have been removed as well.
Refs #8409
-
colorize_ansi
now only accept aMessageStyle
object.Refs #8412
-
The following utilities are deprecated in favor of the more robust
in_type_checking_block
and will be removed in pylint 3.0:is_node_in_guarded_import_block
is_node_in_typing_guarded_import_block
is_typing_guard
is_sys_guard
is still available, which was part of
is_node_in_guarded_import_block
.Refs #8433
-
Following a deprecation period,
Pylinter.check
now only work with
sequences of strings, not strings.Refs #8463
-
Following a deprecation period,
ColorizedTextReporter
only accepts
ColorMappingDict
.Refs #8464
-
Following a deprecation period,
MessageTest
'send_line
and
end_col_offset
must be accurate in functional tests (for python 3.8 or above on cpython, and
for
python 3.9 or superior on pypy).Refs #8466
-
Following a deprecation period, the
do_exit
argument of theRun
class
(and of the_Run
class in testutils) were removed.Refs #8472
-
Following a deprecation period, the
py_version
argument of the
MessageDefinition.may_be_emitted
function is now required. The most
likely solution
is to use 'linter.config.py_version' if you need to keep using this
function, or to use 'MessageDefinition.is_message_enabled' instead.Refs #8473
-
Following a deprecation period, the
OutputLine
class now requires
the right number of argument all the time. The functional output can be
regenerated automatically to achieve that easily.Refs #8474
-
Following a deprecation period,
is_typing_guard
,
is_node_in_typing_guarded_import_block
and
is_node_in_guarded_import_block
: frompylint.utils
were removed: use
a combination of
is_sys_guard
andin_type_checking_block
instead.Refs #8475
-
Following a deprecation period, the
location
argument of the
Message
class must now be aMessageLocationTuple
.Refs #8477
-
Following a deprecation period, the
check_single_file
function of the
Pylinter
is replaced byPylinter.check_single_file_item
.Refs #8478
v2.17.1
False Positives Fixed
-
Adds
asyncSetUp
to the defaultdefining-attr-methods
list to silence
attribute-defined-outside-init
warning when using
unittest.IsolatedAsyncioTestCase
.Refs #8403
Other Bug Fixes
-
--clear-cache-post-run
now also clears LRU caches for pylint utilities
holding references to AST nodes.Closes #8361
-
Fix a crash when
TYPE_CHECKING
is used without importing it.Closes #8434
-
Fix a regression of
preferred-modules
where a partial match was used
instead of the required full match.Closes #8453
Internal Changes
-
The following utilities are deprecated in favor of the more robust
in_type_checking_block
and will be removed in pylint 3.0:is_node_in_guarded_import_block
is_node_in_typing_guarded_import_block
is_typing_guard
is_sys_guard
is still available, which was part of
is_node_in_guarded_import_block
.Refs #8433
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
-
pyreverse
now supports custom color palettes with the--color-palette
option.Closes #6738
-
Add
invalid-name
check forTypeAlias
names.Closes #7081
-
Accept values of the form
<class name>.<attribute name>
for the
exclude-protected
list.Closes #7343
-
Add
--version
option 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
TryStar
nodes from Python 3.11 and should be fully
compatible with Python 3.11.Closes #8387
New Checks
-
Add a
bad-chained-comparison
check 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-alias
check that emits a warning when a class
derived fromenum.IntFlag
assigns 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-assignment
when
typing.TYPE_CHECKING
is 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-assignment
for named expressions
appearing after the first element in a list, tuple, or set.Closes #8252
-
Fix false positive for
wrong-spelling-in-comment
with 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-assignment
false positive when the walrus operator
is used with a ternary operator in dictionary key/value initialization.Closes #8125
-
Fix
no-name-in-module
false 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-max
suggestion 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-name
for the line on which aglobal
statement is declared.Closes #8307
Other Changes
v2.16.4
v2.16.3
v2.16.2
New Features
-
Add
--version
option topyreverse
.Refs #7851
False Positives Fixed
-
Fix false positive for
used-before-assignment
when
typing.TYPE_CHECKING
is used with if/elif/else blocks.Closes #7574
-
Fix false positive for
used-before-assignment
for named expressions
appearing after the first element in a list, tuple, or set.Closes #8252
Other Bug Fixes
-
Fix
used-before-assignment
false positive when the walrus operator
is used with a ternary operator in dictionary key/value initialization.Closes #8125
-
Fix
no-name-in-module
false positive raised when a package defines a
variable with the same name as one of its submodules.Closes #8148
-
Fix
nested-min-max
suggestion 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-doc
option related tomissing-raises-doc
will 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=no
in your configuration to keep
the same behavior.
Closes #7208
New Features
-
Added the
no-header
output 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-run
to support server-like
usage.
Use this flag if you expect the linted files to be altered between runs.
Refs #5401 -
Add
--allow-reexport-from-package
option to configure the
useless-import-alias
check not to emit a warning if a name
is reexported from a package.
Closes #6006 -
Update
pyreverse
to differentiate between aggregations and compositions.
pyreverse
checks 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-statement
check that emits a warning when an
Exception is created and not assigned, raised or returned.
Refs #3110 -
Add a
shadowed-import
message for aliased imports.
Closes #4836 -
Add new check called
unbalanced-dict-unpacking
to check for unbalanced
dict unpacking
in assignment and for loops.
Closes #5797 -
Add new checker
positional-only-arguments-expected
to check for cases
when
positional-only arguments have been passed as keyword arguments.
Closes #6489 -
Added
singledispatch-method
which informs that@singledispatch
should
decorate functions and not class/instance methods.
Addedsingledispatchmethod-function
which informs that
@singledispatchmethod
should decorate class/instance methods and not
functions.
Closes #6917 -
Rename
broad-except
tobroad-exception-caught
and add new checker
broad-exception-raised
which will warn if general exceptionsBaseException
orException
are
raised.
Closes #7494 -
Added
nested-min-max
which flagsmin(1, min(2, 3))
to simplify to
min(1, 2, 3)
.
Closes #7546 -
Extended
use-dict-literal
to also warn about call todict()
when
passing keyword arguments.
Closes #7690 -
Add
named-expr-without-context
check to emit a warning if a named
expression is used outside a context likeif
,for
,while
, or
a comprehension.
Refs #7760 -
Add
invalid-slice-step
check to warn about a slice step value of0
for common builtin sequences.
Refs #7762 -
Add
consider-refactoring-into-while-condition
check to recommend
refactoring when
a while loop is defined with a constant condition with an immediateif
statement to check forbreak
condition as a first statement.
Closes #8015
Extensions
-
Add new extension checker
dict-init-mutate
that flags mutating a
dictionary immediately
after the dictionary was created.
Closes #2876 -
Added
bad-dunder-name
extension check, which flags bad or misspelled
dunder methods.
You can use thegood-dunder-names
option to allow specific dunder names.
Closes #3038 -
Added
consider-using-augmented-assign
check forCodeStyle
extension
which flagsx = x + 1
to simplify tox += 1
.
This check is disabled by default. To use it, load the code style extension
withload-plugins=pylint.extensions.code_style
and add
consider-using-augmented-assign
in theenable
option.
Closes #3391 -
Add
magic-number
plugin 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-argument
message fortyping
plugin 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-variable
andunused-import
when a name
is only used in a string literal type annotation.
Closes #3299 -
Document a known false positive for
useless-suppression
when disabling
line-too-long
in a module with only comments and no code.
Closes #3368 -
trailing-whitespaces
is no longer reported within strings.
Closes #3822 -
Fix false positive for
global-variable-not-assigned
when a global
variable is re-assigned via anImportFrom
node.
Closes #4809 -
Fix false positive for
use-maxsplit-arg
with custom split method.
Closes #4857 -
Fix
logging-fstring-interpolation
false positive raised when logging and
f-string with%s
formatting.
Closes #4984 -
Fix false-positive for
used-before-assignment
in pattern matching
with a guard.
Closes #5327 -
Fix
use-sequence-for-iteration
when unpacking a set with*
.
Closes #5788 -
Fix
deprecated-method
false positive when alias for method is similar to
name of deprecated method.
Closes #5886 -
Fix false positive
assigning-non-slot
when a class attribute is
re-assigned.
Closes #6001 -
Fix false positive for
too-many-function-args
when a function call is
assigned to a class attribute inside the class where the function is defined.
Closes #6592 -
Fixes false positive
abstract-method
on Protocol classes.
Closes #7209 -
Pylint now understands the
kw_only
keyword argument fordataclass
.
Closes #7290, closes #6550, closes #5857 -
Fix false positive for
undefined-loop-variable
infor-else
loops that
use a function
having a return type annotation ofNoReturn
orNever
.
Closes #7311 -
Fix
used-before-assignment
for functions/classes defined in type checking
guard.
Closes #7368 -
Fix false positive for
unhashable-member
when subclassingdict
and
using the subclass as a dictionary key.
Closes #7501 -
Fix the message for
unnecessary-dunder-call
for__aiter__
and
__aneext__
. Also
only emit the warning whenpy-version
>= 3.10.
Closes #7529 -
Fix
used-before-assignment
false positive when else branch calls
sys.exit
or similar terminating functions.
Closes #7563 -
Fix a false positive for
used-before-assignment
for imports guarded by
typing.TYPE_CHECKING
later used in variable annotations.
Closes #7609 -
Fix a false positive for
simplify-boolean-expression
when multiple values
are inferred for a constant.
Closes #7626 -
unnecessary-list-index-lookup
will not be wrongly emitted if
enumerate
is called withstart
.
Closes #7682 -
Don't warn about
stop-iteration-return
when usingnext()
over
itertools.cycle
.
Closes #7765 -
Fixes
used-before-assignment
false positive when the walrus operator
is used in a ternary operator.
Closes #7779 -
Fix
missing-param-doc
false positive when function parameter has an
escaped underscore.
Closes #7827 -
Fixes
method-cache-max-size-none
false positive for methods inheriting
fromEnum
.
Closes #7857 -
multiple-statements
no longer triggers for function stubs using inlined
...
.
Closes #7860 -
Fix a false positive for
used-before-assignment
when 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-assignment
when imports guarded byif TYPE_CHECKING
are guarded again when used.
Closes #7979 -
Fixes false positive for
try-except-raise
with multiple exceptions in one
except statement if exception are in different namespace.
Closes #8051 -
Fix
invalid-name
errors fortyping_extension.TypeVar
.
Refs #8089 -
Fix
no-kwoa
false positive for context managers.
Closes #8100 -
Fix a false positive for
redefined-variable-type
whenasync
methods
are present.
Closes #8120
False Negatives Fixed
-
Code following a call to
quit
,exit
,sys.exit
oros._exit
will be marked asunreachable
.
Refs #519 -
Emit
used-before-assignment
when 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.