What's New in Pylint 3.3

:Release:3.3 :Date: TBA

Summary -- Release highlights

What's new in Pylint 3.3.0?

Release date: TBA

New Features

  • Add new declare-non-slot error which reports when a class has a __slots__ member and a type hint on the class is not present in __slots__.

    Refs #9499 (#9499)

False Positives Fixed

  • Classes with only an Ellipsis (...) in their body do not trigger 'multiple-statements' anymore if they are inlined (in accordance with black's 2024 style).

    Closes #9398 (#9398)

  • Fix multiple false positives for generic class syntax added in Python 3.12 (PEP 695).

    Closes #9406 (#9406)

  • Exclude context manager without cleanup from contextmanager-generator-missing-cleanup checks.

    Closes #9625 (#9625)

  • Exclude if/else branches containing terminating functions (e.g. sys.exit()) from possibly-used-before-assignment checks.

    Closes #9627 (#9627)

  • Don't emit typevar-name-incorrect-variance warnings for PEP 695 style TypeVars. The variance is inferred automatically by the type checker. Adding _co or _contra suffix can help to reason about TypeVar.

    Refs #9638 (#9638)

  • Fix a false positive for possibly-used-before-assignment when using typing.assert_never() (3.11+) to indicate exhaustiveness.

    Closes #9643 (#9643)

  • Fix a false positive for redefined-outer-name when there is a name defined in an exception-handling block which shares the same name as a local variable that has been defined in a function body.

    Closes #9671 (#9671)

  • Prevent emitting possibly-used-before-assignment when relying on names only potentially not defined in conditional blocks guarded by functions annotated with typing.Never or typing.NoReturn.

    Closes #9674 (#9674)

  • Fix a false positive for use-yield-from when using the return value from the yield atom.

    Closes #9696 (#9696)

False Negatives Fixed

  • Fix a false negative for --ignore-patterns when the directory to be linted is specified using a dot(.) and all files are ignored instead of only the files whose name begin with a dot.

    Closes #9273 (#9273)

  • Fix a false negative for await-outside-async when await is inside Lambda.

    Refs #9653 (#9653)

  • Fix a false negative for duplicate-argument-name by including positional-only, *args and **kwargs arguments in the check.

    Closes #9669 (#9669)

Other Bug Fixes

  • Fixed a crash when the lineno of a variable used as an annotation wasn't available for undefined-variable.

    Closes #8866 (#8866)

  • Fixed a crash when the start value in an enumerate was non-constant and impossible to infer (like in``enumerate(apples, start=int(random_apple_index)``) for unnecessary-list-index-lookup.

    Closes #9078 (#9078)

  • Restore "errors / warnings by module" section to report output (with -ry).

    Closes #9145 (#9145)

  • Fixed a crash in symilar when the -d or -i short option were not properly recognized. It's still impossible to do -d=1 (you must do -d 1).

    Closes #9343 (#9343)

  • trailing-comma-tuple should now be correctly emitted when it was disabled globally but enabled via local message control, after removal of an over-optimisation.

    Refs #9608. (#9608)

  • Add --prefer-stubs=yes option to opt-in to the astroid 3.2 feature that prefers .pyi stubs over same-named .py files. This has the potential to reduce no-member errors but at the cost of more errors such as not-an-iterable from function bodies appearing as ....

    Defaults to no.

    Closes #9626 Closes #9623 (#9626)

  • Impossible to compile regexes for paths in the configuration or argument given to pylint won't crash anymore but raise an argparse error and display the error message from re.compile instead.

    Closes #9680 (#9680)

  • Fix a bug where a tox.ini file with pylint configuration was ignored and it exists in the current directory.

    .cfg and .ini files containing a Pylint configuration may now use a section named [pylint]. This enhancement impacts the scenario where these file types are used as defaults when they are present and have not been explicitly referred to, using the --rcfile option.

    Closes #9727 (#9727)

Internal Changes

  • Update astroid version to 3.2.1. This solves some reports of RecursionError and also makes the prefer .pyi stubs feature in astroid 3.2.0 opt-in with the aforementioned --prefer-stubs=y option.

    Refs #9139 (#9139)

  • All variables, classes, functions and file names containing the word 'similar', when it was, in fact, referring to 'symilar' (the standalone program for the duplicate-code check) were renamed to 'symilar'.

    Closes #9734 (#9734)