Skip to content

Releases: pylint-dev/pylint

v2.16.0

01 Feb 11:47
Compare
Choose a tag to compare

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 to missing-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 add accept-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.
    Added singledispatchmethod-function which informs that
    @singledispatchmethod should decorate class/instance methods and not
    functions.
    Closes #6917

  • Rename broad-except to broad-exception-caught and add new checker
    broad-exception-raised
    which will warn if general exceptions BaseException or Exception are
    raised.
    Closes #7494

  • Added nested-min-max which flags min(1, min(2, 3)) to simplify to
    min(1, 2, 3).
    Closes #7546

  • Extended use-dict-literal to also warn about call to dict() 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 like if, for, while, or
    a comprehension.
    Refs #7760

  • Add invalid-slice-step check to warn about a slice step value of 0
    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 immediate if
    statement to check for break 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 the good-dunder-names option to allow specific dunder names.
    Closes #3038

  • Added consider-using-augmented-assign check for CodeStyle extension
    which flags x = x + 1 to simplify to x += 1.
    This check is disabled by default. To use it, load the code style extension
    with load-plugins=pylint.extensions.code_style and add
    consider-using-augmented-assign in the enable 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 for typing 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 and unused-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 an ImportFrom 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 for dataclass.
    Closes #7290, closes #6550, closes #5857

  • Fix false positive for undefined-loop-variable in for-else loops that
    use a function
    having a return type annotation of NoReturn or Never.
    Closes #7311

  • Fix used-before-assignment for functions/classes defined in type checking
    guard.
    Closes #7368

  • Fix false positive for unhashable-member when subclassing dict 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 when py-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 with start.
    Closes #7682

  • Don't warn about stop-iteration-return when using next() 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
    from Enum.
    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 by if 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 for typing_extension.TypeVar.
    Refs #8089

  • Fix no-kwoa false positive for context managers.
    Closes #8100

  • Fix a false positive for redefined-variable-type when async methods
    are present.
    Closes #8120

False Negatives Fixed

  • Code following a call to quit, exit, sys.exit or os._exit
    will be marked as unreachable.
    Refs #519

  • Emit used-before-assignment when function arguments are redefined inside
    an inner function and accessed there before assignment.
    Closes #2374

...

Read more

v2.16.0b1

22 Jan 14:40
Compare
Choose a tag to compare

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

13 Jan 11:29
Compare
Choose a tag to compare

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

09 Jan 10:58
ea12a60
Compare
Choose a tag to compare

False Positives Fixed

  • Fix use-sequence-for-iteration when unpacking a set with *.

    Closes #5788

  • Fix false positive assigning-non-slot when a class attribute is
    re-assigned.

    Closes #6001

  • Fixes used-before-assignment false positive when the walrus operator
    is used in a ternary operator.

    Closes #7779

  • Prevent used-before-assignment when imports guarded by if TYPE_CHECKING
    are guarded again when used.

    Closes #7979

Other Bug Fixes

  • Using custom braces in msg-template will now work properly.

    Closes #5636

v2.15.9

17 Dec 14:09
1ded4d0
Compare
Choose a tag to compare

False Positives Fixed

  • Fix false-positive for used-before-assignment in 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 ModuleNotFound exception when running pylint on a Django project with the pylint_django plugin enabled.

    Closes #7938

v2.15.8

05 Dec 12:55
1f84ed9
Compare
Choose a tag to compare

False Positives Fixed

  • Document a known false positive for useless-suppression when disabling
    line-too-long in a module with only comments and no code.

    Closes #3368

  • Fix logging-fstring-interpolation false positive raised when logging and f-string with %s formatting.

    Closes #4984

  • Fixes false positive abstract-method on Protocol classes.

    Closes #7209

  • Fix missing-param-doc false positive when function parameter has an escaped underscore.

    Closes #7827

  • multiple-statements no longer triggers for function stubs using inlined ....

    Closes #7860

v2.15.7

29 Nov 11:19
5a96370
Compare
Choose a tag to compare

False Positives Fixed

  • Fix deprecated-method false positive when alias for method is similar to
    name of deprecated method.

    Closes #5886

  • Fix a false positive for used-before-assignment for imports guarded by
    typing.TYPE_CHECKING later used in variable annotations.

    Closes #7609

Other Bug Fixes

  • 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

  • Fixes a crash in stop-iteration-return when the next builtin is
    called without arguments.

    Closes #7828

v2.15.6

19 Nov 08:27
b2af2b2
Compare
Choose a tag to compare

False Positives Fixed

  • Fix false positive for unhashable-member when subclassing dict and
    using the subclass as a dictionary key.

    Closes #7501

  • unnecessary-list-index-lookup will not be wrongly emitted if
    enumerate is called with start.

    Closes #7682

  • Don't warn about stop-iteration-return when using next() over
    itertools.cycle.

    Closes #7765

Other Bug Fixes

  • Messages sent to reporter are now copied so a reporter cannot modify the
    message sent to other reporters.

    Closes #7214

  • Fixes edge case of custom method named next raised an astroid error.

    Closes #7610

  • 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 a
    parent class with an __init__ class attribute.

    Closes #7742

v2.15.5

21 Oct 21:18
bb17694
Compare
Choose a tag to compare

What's new in Pylint 2.15.5?

Release date: 2022-10-21

False Positives Fixed

  • Fix a false positive for simplify-boolean-expression when multiple values
    are inferred for a constant.

    Closes #7626

Other Bug Fixes

  • Remove __index__ dunder method call from unnecessary-dunder-call
    check.

    Closes #6795

  • 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 dill would throw an error when attempting to serialise the linter object for multi-processing use.

    Closes #7635.

Other Changes

  • Add a keyword-only compare_constants argument to safe_infer.

    Refs #7626

  • Sort --generated-rcfile output.

    Refs #7655

v2.15.4

10 Oct 13:23
Compare
Choose a tag to compare

False Positives Fixed

  • Fix the message for unnecessary-dunder-call for __aiter__ and
    __anext__. Also
    only emit the warning when py-version >= 3.10.

    Closes #7529

Other Bug Fixes

  • Fix bug in detecting unused-variable when iterating on variable.

    Closes #3044

  • Fixed handling of -- as separator between positional arguments and flags.
    This was not actually fixed in 2.14.5.

    Closes #7003, Refs #7096

  • Report no-self-argument rather than no-method-argument for methods
    with variadic arguments.

    Closes #7507

  • Fixed an issue where syntax-error couldn't be raised on files with
    invalid encodings.

    Closes #7522

  • Fix false positive for redefined-outer-name when aliasing typing
    e.g. as t and guarding imports under t.TYPE_CHECKING.

    Closes #7524

  • Fixed a crash of the modified_iterating checker when iterating on a set
    defined as a class attribute.

    Closes #7528

  • 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

Other Changes

  • Add method name to the error messages of no-method-argument and
    no-self-argument.

    Closes #7507