What's New in Pylint 4.0

:Release:4.0 :Date: TBA

Summary -- Release highlights

What's new in Pylint 4.0.0-dev0?

Release date: TBA

Breaking Changes

  • invalid-name now distinguishes module-level constants that are assigned only once from those that are reassigned and now applies --variable-rgx to the latter. Values other than literals (lists, sets, objects) can pass against either the constant or variable regexes (e.g. "LOGGER" or "logger" but not "LoGgEr").

    Remember that --good-names or --good-names-rgxs can be provided to explicitly allow good names.

    Closes #3585 (#3585)

  • Commented out code blocks such as #    bar() # TODO: remove dead code will no longer emit fixme.

    Refs #9255 (#9255)

  • pyreverse Run was changed to no longer call sys.exit() in its __init__. You should now call Run(args).run() which will return the exit code instead. Having a class that always raised a SystemExit exception was considered a bug.

    Normal usage of pyreverse through the CLI will not be affected by this change.

    Refs #9689 (#9689)

  • The async.py checker module has been renamed to async_checker.py since async is a Python keyword and cannot be imported directly. This allows for better testing and extensibility of the async checker functionality.

    Refs #10071 (#10071)

New Features

  • The fixme check can now search through docstrings as well as comments, by using check-fixme-in-docstring = true in the [tool.pylint.miscellaneous] section.

    Closes #9255 (#9255)

  • Enhanced support for @property decorator in pyreverse to correctly display return types of annotated properties when generating class diagrams.

    Closes #10057 (#10057)

  • Add --max-depth option to pyreverse to control diagram complexity. A depth of 0 shows only top-level packages, 1 shows one level of subpackages, etc. This helps manage visualization of large codebases by limiting the depth of displayed packages and classes.

    Refs #10077 (#10077)

  • pyreverse: add support for colorized output when using output format mmd (MermaidJS) and html.

    Closes #10242 (#10242)

False Positives Fixed

  • Fix a false positive for used-before-assignment when an inner function's return type annotation is a class defined at module scope.

    Closes #9391 (#9391)

  • Fix a false positive for used-before-assignment when a variable defined under an if and via a named expression (walrus operator) is used later when guarded under the same if test.

    Closes #10061 (#10061)

  • Fix false positives for use-implicit-booleaness-not-comparison, use-implicit-booleaness-not-comparison-to-string and use-implicit-booleaness-not-comparison-to-zero when chained comparisons are checked.

    Closes #10065 (#10065)

  • Fix a false positive for invalid-getnewargs-ex-returned when the tuple or dict has been assigned to a name.

    Closes #10208 (#10208)

  • Remove getopt and optparse from the list of deprecated modules.

    Closes #10211 (#10211)

False Negatives Fixed

  • Fix false negative for used-before-assignment when a TYPE_CHECKING import is used as a type annotation prior to erroneous usage.

    Refs #8893 (#8893)

  • Check module-level constants with type annotations for invalid-name. Remember to adjust const-naming-style or const-rgx to your liking.

    Closes #9770 (#9770)

  • Fix false negative for used-before-assignment when a function is defined inside a TYPE_CHECKING guard block and used later.

    Closes #10028 (#10028)

Other Bug Fixes

  • Fixes "skipped files" count calculation; the previous method was displaying an arbitrary number.

    Closes #10073 (#10073)

  • Fixed conditional import x.y causing false positive possibly-used-before-assignment.

    Closes #10081 (#10081)

  • Fixes a crash that occurred when pylint was run in a container on a host with cgroupsv2 and restrictions on CPU usage.

    Closes #10103 (#10103)

  • Fix a crash when something besides a class is found in an except handler.

    Closes #10106 (#10106)

  • Fixed raising invalid-name when using camelCase for private methods with two leading underscores.

    Closes #10189 (#10189)

  • Relaxed the requirements for isort so pylint can benefit from isort 6.

    Closes #10203 (#10203)

  • Fixed unidiomatic-typecheck only checking left-hand side.

    Closes #10217 (#10217)

Other Changes

  • Upload release assets to PyPI via Trusted Publishing.

    Closes #10256 (#10256)