Skip to content

Commit 0939ac5

Browse files
Bump pylint to 4.0.0, update changelog
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
1 parent ea25969 commit 0939ac5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+323
-210
lines changed

doc/whatsnew/4/4.0/index.rst

Lines changed: 295 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:maxdepth: 2
88

99
:Release:4.0
10-
:Date: TBA
10+
:Date: 2025-10-12
1111

1212
Summary -- Release highlights
1313
=============================
@@ -73,3 +73,297 @@ and
7373
to your liking.
7474

7575
.. towncrier release notes start
76+
77+
What's new in Pylint 4.0.0?
78+
---------------------------
79+
Release date: 2025-10-12
80+
81+
82+
Breaking Changes
83+
----------------
84+
85+
- ``invalid-name`` now distinguishes module-level constants that are assigned only once
86+
from those that are reassigned and now applies ``--variable-rgx`` to the latter. Values
87+
other than literals (lists, sets, objects) can pass against either the constant or
88+
variable regexes (e.g. "LOGGER" or "logger" but not "LoGgEr").
89+
90+
Remember that ``--good-names`` or ``--good-names-rgxs`` can be provided to explicitly
91+
allow good names.
92+
93+
Closes #3585 (`#3585 <https://github.com/pylint-dev/pylint/issues/3585>`_)
94+
95+
- The unused ``pylintrc`` argument to ``PyLinter.__init__()`` is deprecated
96+
and will be removed.
97+
98+
Refs #6052 (`#6052 <https://github.com/pylint-dev/pylint/issues/6052>`_)
99+
100+
- Commented out code blocks such as ``# bar() # TODO: remove dead code`` will no longer emit ``fixme``.
101+
102+
Refs #9255 (`#9255 <https://github.com/pylint-dev/pylint/issues/9255>`_)
103+
104+
- ``pyreverse`` ``Run`` was changed to no longer call ``sys.exit()`` in its ``__init__``.
105+
You should now call ``Run(args).run()`` which will return the exit code instead.
106+
Having a class that always raised a ``SystemExit`` exception was considered a bug.
107+
108+
Normal usage of pyreverse through the CLI will not be affected by this change.
109+
110+
Refs #9689 (`#9689 <https://github.com/pylint-dev/pylint/issues/9689>`_)
111+
112+
- The ``suggestion-mode`` option was removed, as pylint now always emits user-friendly hints instead
113+
of false-positive error messages. You should remove it from your conf if it's defined.
114+
115+
Refs #9962 (`#9962 <https://github.com/pylint-dev/pylint/issues/9962>`_)
116+
117+
- The ``async.py`` checker module has been renamed to ``async_checker.py`` since ``async`` is a Python keyword
118+
and cannot be imported directly. This allows for better testing and extensibility of the async checker functionality.
119+
120+
Refs #10071 (`#10071 <https://github.com/pylint-dev/pylint/issues/10071>`_)
121+
122+
- The message-id of ``continue-in-finally`` was changed from ``E0116`` to ``W0136``. The warning is
123+
now emitted for every Python version since it will raise a syntax warning in Python 3.14.
124+
See `PEP 765 - Disallow return/break/continue that exit a finally block <https://peps.python.org/pep-0765/>`_.
125+
126+
Refs #10480 (`#10480 <https://github.com/pylint-dev/pylint/issues/10480>`_)
127+
128+
- Removed support for ``nmp.NaN`` alias for ``numpy.NaN`` being recognized in ':ref:`nan-comparison`'. Use ``np`` or ``numpy`` instead.
129+
130+
Refs #10583 (`#10583 <https://github.com/pylint-dev/pylint/issues/10583>`_)
131+
132+
- Version requirement for ``isort`` has been bumped to >=5.0.0.
133+
The internal compatibility for older ``isort`` versions exposed via ``pylint.utils.IsortDriver`` has
134+
been removed.
135+
136+
Refs #10637 (`#10637 <https://github.com/pylint-dev/pylint/issues/10637>`_)
137+
138+
139+
140+
New Features
141+
------------
142+
143+
- ``comparison-of-constants`` now uses the unicode from the ast instead of reformatting from
144+
the node's values preventing some bad formatting due to ``utf-8`` limitation. The message now uses
145+
``"`` instead of ``'`` to better work with what the python ast returns.
146+
147+
Refs #8736 (`#8736 <https://github.com/pylint-dev/pylint/issues/8736>`_)
148+
149+
- Enhanced pyreverse to properly distinguish between UML relationship types (association, aggregation, composition) based on object ownership semantics. Type annotations without assignment are now treated as associations, parameter assignments as aggregations, and object instantiation as compositions.
150+
151+
Closes #9045
152+
Closes #9267 (`#9045 <https://github.com/pylint-dev/pylint/issues/9045>`_)
153+
154+
- The ``fixme`` check can now search through docstrings as well as comments, by using
155+
``check-fixme-in-docstring = true`` in the ``[tool.pylint.miscellaneous]`` section.
156+
157+
Closes #9255 (`#9255 <https://github.com/pylint-dev/pylint/issues/9255>`_)
158+
159+
- The ``use-implicit-booleaness-not-x`` checks now distinguish between comparisons
160+
used in boolean contexts and those that are not, enabling them to provide more accurate refactoring suggestions.
161+
162+
Closes #9353 (`#9353 <https://github.com/pylint-dev/pylint/issues/9353>`_)
163+
164+
- The verbose option now outputs the filenames of the files that have been checked.
165+
Previously, it only included the number of checked and skipped files.
166+
167+
Closes #9357 (`#9357 <https://github.com/pylint-dev/pylint/issues/9357>`_)
168+
169+
- colorized reporter now colorizes messages/categories that have been configured as ``fail-on`` in red inverse.
170+
This makes it easier to quickly find the errors that are causing pylint CI job failures.
171+
172+
Closes #9898 (`#9898 <https://github.com/pylint-dev/pylint/issues/9898>`_)
173+
174+
- Enhanced support for @property decorator in pyreverse to correctly display return types of annotated properties when generating class diagrams.
175+
176+
Closes #10057 (`#10057 <https://github.com/pylint-dev/pylint/issues/10057>`_)
177+
178+
- 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.
179+
This helps manage visualization of large codebases by limiting the depth of displayed packages and classes.
180+
181+
Refs #10077 (`#10077 <https://github.com/pylint-dev/pylint/issues/10077>`_)
182+
183+
- Handle deferred evaluation of annotations in Python 3.14.
184+
185+
Closes #10149 (`#10149 <https://github.com/pylint-dev/pylint/issues/10149>`_)
186+
187+
- Enhanced pyreverse to properly detect aggregations for comprehensions (list, dict, set, generator).
188+
189+
Closes #10236 (`#10236 <https://github.com/pylint-dev/pylint/issues/10236>`_)
190+
191+
- ``pyreverse``: add support for colorized output when using output format ``mmd`` (MermaidJS) and ``html``.
192+
193+
Closes #10242 (`#10242 <https://github.com/pylint-dev/pylint/issues/10242>`_)
194+
195+
- pypy 3.11 is now officially supported.
196+
197+
Refs #10287 (`#10287 <https://github.com/pylint-dev/pylint/issues/10287>`_)
198+
199+
- Add support for Python 3.14.
200+
201+
Refs #10467 (`#10467 <https://github.com/pylint-dev/pylint/issues/10467>`_)
202+
203+
- Add naming styles for ``ParamSpec`` and ``TypeVarTuple`` that align with the ``TypeVar`` style.
204+
205+
Refs #10541 (`#10541 <https://github.com/pylint-dev/pylint/issues/10541>`_)
206+
207+
208+
209+
New Checks
210+
----------
211+
212+
- Add ``match-statements`` checker and the following message:
213+
``bare-name-capture-pattern``.
214+
This will emit an error message when a name capture pattern is used in a match statement which would make the remaining patterns unreachable.
215+
This code is a SyntaxError at runtime.
216+
217+
Closes #7128 (`#7128 <https://github.com/pylint-dev/pylint/issues/7128>`_)
218+
219+
- Add new check ``async-context-manager-with-regular-with`` to detect async context managers used with regular ``with`` statements instead of ``async with``.
220+
221+
Refs #10408 (`#10408 <https://github.com/pylint-dev/pylint/issues/10408>`_)
222+
223+
- Add ``break-in-finally`` warning. Using ``break`` inside the ``finally`` clause
224+
will raise a syntax warning in Python 3.14.
225+
See `PEP 765 - Disallow return/break/continue that exit a finally block <https://peps.python.org/pep-0765/>`_.
226+
227+
Refs #10480 (`#10480 <https://github.com/pylint-dev/pylint/issues/10480>`_)
228+
229+
- Add new checks for invalid uses of class patterns in :keyword:`match`.
230+
231+
* :ref:`invalid-match-args-definition` is emitted if :py:data:`object.__match_args__` isn't a tuple of strings.
232+
* :ref:`too-many-positional-sub-patterns` if there are more positional sub-patterns than specified in :py:data:`object.__match_args__`.
233+
* :ref:`multiple-class-sub-patterns` if there are multiple sub-patterns for the same attribute.
234+
235+
Refs #10559 (`#10559 <https://github.com/pylint-dev/pylint/issues/10559>`_)
236+
237+
- Add additional checks for suboptimal uses of class patterns in :keyword:`match`.
238+
239+
* :ref:`match-class-bind-self` is emitted if a name is bound to ``self`` instead of
240+
using an ``as`` pattern.
241+
* :ref:`match-class-positional-attributes` is emitted if a class pattern has positional
242+
attributes when keywords could be used.
243+
244+
Refs #10586 (`#10586 <https://github.com/pylint-dev/pylint/issues/10586>`_)
245+
246+
- Add a ``consider-math-not-float`` message. ``float("nan")`` and ``float("inf")`` are slower
247+
than their counterpart ``math.inf`` and ``math.nan`` by a factor of 4 (notwithstanding
248+
the initial import of math) and they are also not well typed when using mypy.
249+
This check also catches typos in float calls as a side effect.
250+
251+
The :ref:`pylint.extensions.code_style` need to be activated for this check to work.
252+
253+
Refs #10621 (`#10621 <https://github.com/pylint-dev/pylint/issues/10621>`_)
254+
255+
256+
257+
False Positives Fixed
258+
---------------------
259+
260+
- Fix a false positive for ``used-before-assignment`` when a variable defined under
261+
an ``if`` and via a named expression (walrus operator) is used later when guarded
262+
under the same ``if`` test.
263+
264+
Closes #10061 (`#10061 <https://github.com/pylint-dev/pylint/issues/10061>`_)
265+
266+
- Fix :ref:`no-name-in-module` for members of ``concurrent.futures`` with Python 3.14.
267+
268+
Closes #10632 (`#10632 <https://github.com/pylint-dev/pylint/issues/10632>`_)
269+
270+
271+
272+
False Negatives Fixed
273+
---------------------
274+
275+
- Fix false negative for ``used-before-assignment`` when a ``TYPE_CHECKING`` import is used as a type annotation prior to erroneous usage.
276+
277+
Refs #8893 (`#8893 <https://github.com/pylint-dev/pylint/issues/8893>`_)
278+
279+
- Match cases are now counted as edges in the McCabe graph and will increase the complexity accordingly.
280+
281+
Refs #9667 (`#9667 <https://github.com/pylint-dev/pylint/issues/9667>`_)
282+
283+
- Check module-level constants with type annotations for ``invalid-name``.
284+
Remember to adjust ``const-naming-style`` or ``const-rgx`` to your liking.
285+
286+
Closes #9770 (`#9770 <https://github.com/pylint-dev/pylint/issues/9770>`_)
287+
288+
- Fix false negative where function-redefined (E0102) was not reported for functions with a leading underscore.
289+
290+
Closes #9894 (`#9894 <https://github.com/pylint-dev/pylint/issues/9894>`_)
291+
292+
- We now raise a ``logging-too-few-args`` for format string with no
293+
interpolation arguments at all (i.e. for something like ``logging.debug("Awaiting process %s")``
294+
or ``logging.debug("Awaiting process {pid}")``). Previously we did not raise for such case.
295+
296+
Closes #9999 (`#9999 <https://github.com/pylint-dev/pylint/issues/9999>`_)
297+
298+
- Fix false negative for ``used-before-assignment`` when a function is defined inside a ``TYPE_CHECKING`` guard block and used later.
299+
300+
Closes #10028 (`#10028 <https://github.com/pylint-dev/pylint/issues/10028>`_)
301+
302+
- Fix a false negative for ``possibly-used-before-assignment`` when a variable is conditionally defined
303+
and later assigned to a type-annotated variable.
304+
305+
Closes #10421 (`#10421 <https://github.com/pylint-dev/pylint/issues/10421>`_)
306+
307+
- Fix false negative for ``deprecated-module`` when a ``__import__`` method is used instead of ``import`` sentence.
308+
309+
Refs #10453 (`#10453 <https://github.com/pylint-dev/pylint/issues/10453>`_)
310+
311+
- Count match cases for ``too-many-branches`` check.
312+
313+
Refs #10542 (`#10542 <https://github.com/pylint-dev/pylint/issues/10542>`_)
314+
315+
- Fix false-negative where :ref:`unused-import` was not reported for names referenced in a preceding ``global`` statement.
316+
317+
Refs #10633 (`#10633 <https://github.com/pylint-dev/pylint/issues/10633>`_)
318+
319+
320+
321+
Other Bug Fixes
322+
---------------
323+
324+
- When displaying unicode with surrogates (or other potential ``UnicodeEncodeError``),
325+
pylint will now display a '?' character (using ``encode(encoding="utf-8", errors="replace")``)
326+
instead of crashing. The functional tests classes are also updated to handle this case.
327+
328+
Closes #8736. (`#8736 <https://github.com/pylint-dev/pylint/issues/8736>`_)
329+
330+
- Fixed unidiomatic-typecheck only checking left-hand side.
331+
332+
Closes #10217 (`#10217 <https://github.com/pylint-dev/pylint/issues/10217>`_)
333+
334+
- Fix a crash caused by malformed format strings when using ``.format`` with keyword arguments.
335+
336+
Closes #10282 (`#10282 <https://github.com/pylint-dev/pylint/issues/10282>`_)
337+
338+
- Fix false positive ``inconsistent-return-statements`` when using ``quit()`` or ``exit()`` functions.
339+
340+
Closes #10508 (`#10508 <https://github.com/pylint-dev/pylint/issues/10508>`_)
341+
342+
- Fix a crash in :ref:`nested-min-max` when using ``builtins.min`` or ``builtins.max``
343+
instead of ``min`` or ``max`` directly.
344+
345+
Closes #10626 (`#10626 <https://github.com/pylint-dev/pylint/issues/10626>`_)
346+
347+
- Fixed a crash in :ref:`unnecessary-dict-index-lookup` when the index of an enumerated list
348+
was deleted inside a for loop.
349+
350+
Closes #10627 (`#10627 <https://github.com/pylint-dev/pylint/issues/10627>`_)
351+
352+
353+
354+
Other Changes
355+
-------------
356+
357+
- Remove support for launching pylint with Python 3.9.
358+
Code that supports Python 3.9 can still be linted with the ``--py-version=3.9`` setting.
359+
360+
Refs #10405 (`#10405 <https://github.com/pylint-dev/pylint/issues/10405>`_)
361+
362+
363+
364+
Internal Changes
365+
----------------
366+
367+
- Modified test framework to allow for different test output for different Python versions.
368+
369+
Refs #10382 (`#10382 <https://github.com/pylint-dev/pylint/issues/10382>`_)

doc/whatsnew/fragments/10028.false_negative

Lines changed: 0 additions & 3 deletions
This file was deleted.

doc/whatsnew/fragments/10057.feature

Lines changed: 0 additions & 3 deletions
This file was deleted.

doc/whatsnew/fragments/10061.false_positive

Lines changed: 0 additions & 5 deletions
This file was deleted.

doc/whatsnew/fragments/10071.breaking

Lines changed: 0 additions & 4 deletions
This file was deleted.

doc/whatsnew/fragments/10077.feature

Lines changed: 0 additions & 4 deletions
This file was deleted.

doc/whatsnew/fragments/10149.feature

Lines changed: 0 additions & 3 deletions
This file was deleted.

doc/whatsnew/fragments/10217.bugfix

Lines changed: 0 additions & 3 deletions
This file was deleted.

doc/whatsnew/fragments/10236.feature

Lines changed: 0 additions & 3 deletions
This file was deleted.

doc/whatsnew/fragments/10242.feature

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)