What's New in Pylint 2.16#

:Release:2.16 :Date: TBA

Summary -- Release highlights#

What's new in Pylint 2.16.0?#

Release date: TBA

New Checks#

  • Added consider-using-augmented-assign which flags x = x + 1 to simplify to x += 1.

    Closes #3391 (#3391)

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 (#3299)

  • trailing-whitespaces is no longer reported within strings.

    Closes #3822 (#3822)

  • Fix false positive for global-variable-not-assigned when a global variable is re-assigned via an ImportFrom node.

    Closes #4809 (#4809)

  • 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 (#6592)

  • Pylint now understands the kw_only keyword argument for dataclass.

    Closes #7290, closes #6550, closes #5857 (#7290)

  • 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 (#7311)

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

    Closes #7368 (#7368)

False Negatives Fixed#

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

    Closes #2374 (#2374)

Other Bug Fixes#

  • 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 (#3299)

  • Fix ignored files being linted when passed on stdin.

    Closes #4354 (#4354)

  • Fix no-member false negative when augmented assign is done manually, without +=.

    Closes #4562 (#4562)

  • Any assertion on a populated tuple will now receive a assert-on-tuple warning.

    Closes #4655 (#4655)

  • missing-return-doc, missing-raises-doc and missing-yields-doc now respect the no-docstring-rgx option.

    Closes #4743 (#4743)

  • Don't crash on OSError in config file discovery.

    Closes #7169 (#7169)

  • Fixed a case where custom plugins specified by command line could silently fail.

    Specifically, if a plugin relies on the init-hook option changing sys.path before it can be imported, this will now emit a bad-plugin-value message. Before this 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. (#7264)

  • Update modified_iterating checker to fix a crash with for loops on empty list.

    Closes #7380 (#7380)

  • Update wording for arguments-differ and arguments-renamed to clarify overriding object.

    Closes #7390 (#7390)

  • disable-next is now correctly scoped to only the succeeding line.

    Closes #7401 (#7401)

  • Fixed a crash in the unhashable-member checker when using a lambda as a dict key.

    Closes #7453 (#7453)

  • Add mailcap to deprecated modules list.

    Closes #7457 (#7457)

  • Fix a crash in the modified-iterating-dict checker involving instance attributes.

    Closes #7461 (#7461)

  • invalid-class-object does not crash anymore when __class__ is assigned alongside another variable.

    Closes #7467 (#7467)

  • --help-msg now accepts a comma-separated list of message IDs again.

    Closes #7471 (#7471)

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

    Closes #7507 (#7507)

Other Changes#

  • Update message for abstract-method to include child class name.

    Closes #7124 (#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 (#7346)

  • The docparams extension now considers typing in Numpy style docstrings as "documentation" for the missing-param-doc message.

    Refs #7398 (#7398)

  • Relevant DeprecationWarnings are now raised with stacklevel=2, so they have the callsite attached in the message.

    Closes #7463 (#7463)

  • Add a minimal option to pylint-config and its toml generator.

    Closes #7485 (#7485)

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

    Closes #7507 (#7507)

Internal Changes#

  • Add and fix regression tests for plugin loading.

    This shores up the tests that cover the loading of custom plugins as affected by any changes made to the sys.path during execution of an init-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 (#7264)