Debian Codegraph @

doc/whatsnew/2/2.15/index.rst

raw
1 ***************************
2 What's New in Pylint 2.15
3 ***************************
4
5 .. toctree::
6 :maxdepth: 2
7
8 :Release: 2.15
9 :Date: 2022-08-26
10
11 Summary -- Release highlights
12 =============================
13
14 In pylint 2.15.0, we added a new check ``missing-timeout`` to warn of
15 default timeout values that could cause a program to be hanging indefinitely.
16
17 We improved ``pylint``'s handling of namespace packages. More packages should
18 be linted without resorting to using the ``--recursive=y`` option.
19
20 We still welcome any community effort to help review, integrate, and add good/bad examples to the doc for
21 <https://github.com/pylint-dev/pylint/issues/5953>`_. This should be doable without any ``pylint`` or ``astroid``
22 knowledge, so this is the perfect entrypoint if you want to contribute to ``pylint`` or open source without
23 any experience with our code!
24
25 Internally, we changed the way we generate the release notes, thanks to DudeNr33.
26 There will be no more conflict resolution to do in the changelog, and every contributor rejoice.
27
28 Marc Byrne became a maintainer, welcome to the team !
29
30 .. towncrier release notes start
31
32 What's new in Pylint 2.15.10?
33 -----------------------------
34 Release date: 2023-01-09
35
36
37 False Positives Fixed
38 ---------------------
39
40 - Fix ``use-sequence-for-iteration`` when unpacking a set with ``*``.
41
42 Closes #5788 (`#5788 <https://github.com/pylint-dev/pylint/issues/5788>`_)
43
44 - Fix false positive ``assigning-non-slot`` when a class attribute is
45 re-assigned.
46
47 Closes #6001 (`#6001 <https://github.com/pylint-dev/pylint/issues/6001>`_)
48
49 - Fixes ``used-before-assignment`` false positive when the walrus operator
50 is used in a ternary operator.
51
52 Closes #7779 (`#7779 <https://github.com/pylint-dev/pylint/issues/7779>`_)
53
54 - Prevent ``used-before-assignment`` when imports guarded by ``if
55 TYPE_CHECKING``
56 are guarded again when used.
57
58 Closes #7979 (`#7979 <https://github.com/pylint-dev/pylint/issues/7979>`_)
59
60
61
62 Other Bug Fixes
63 ---------------
64
65 - Using custom braces in ``msg-template`` will now work properly.
66
67 Closes #5636 (`#5636 <https://github.com/pylint-dev/pylint/issues/5636>`_)
68
69
70 What's new in Pylint 2.15.9?
71 ----------------------------
72 Release date: 2022-12-17
73
74
75 False Positives Fixed
76 ---------------------
77
78 - Fix false-positive for ``used-before-assignment`` in pattern matching
79 with a guard.
80
81 Closes #5327 (`#5327 <https://github.com/pylint-dev/pylint/issues/5327>`_)
82
83
84
85 Other Bug Fixes
86 ---------------
87
88 - Pylint will no longer deadlock if a parallel job is killed but fail
89 immediately instead.
90
91 Closes #3899 (`#3899 <https://github.com/pylint-dev/pylint/issues/3899>`_)
92
93 - When pylint exit due to bad arguments being provided the exit code will now
94 be the expected ``32``.
95
96 Refs #7931 (`#7931 <https://github.com/pylint-dev/pylint/issues/7931>`_)
97
98 - Fixes a ``ModuleNotFound`` exception when running pylint on a Django project
99 with the ``pylint_django`` plugin enabled.
100
101 Closes #7938 (`#7938 <https://github.com/pylint-dev/pylint/issues/7938>`_)
102
103
104 What's new in Pylint 2.15.8?
105 ----------------------------
106 Release date: 2022-12-05
107
108
109 False Positives Fixed
110 ---------------------
111
112 - Document a known false positive for ``useless-suppression`` when disabling
113 ``line-too-long`` in a module with only comments and no code.
114
115 Closes #3368 (`#3368 <https://github.com/pylint-dev/pylint/issues/3368>`_)
116
117 - Fix ``logging-fstring-interpolation`` false positive raised when logging and
118 f-string with ``%s`` formatting.
119
120 Closes #4984 (`#4984 <https://github.com/pylint-dev/pylint/issues/4984>`_)
121
122 - Fixes false positive ``abstract-method`` on Protocol classes.
123
124 Closes #7209 (`#7209 <https://github.com/pylint-dev/pylint/issues/7209>`_)
125
126 - Fix ``missing-param-doc`` false positive when function parameter has an
127 escaped underscore.
128
129 Closes #7827 (`#7827 <https://github.com/pylint-dev/pylint/issues/7827>`_)
130
131 - ``multiple-statements`` no longer triggers for function stubs using inlined
132 ``...``.
133
134 Closes #7860 (`#7860 <https://github.com/pylint-dev/pylint/issues/7860>`_)
135
136
137 What's new in Pylint 2.15.7?
138 ----------------------------
139 Release date: 2022-11-27
140
141
142 False Positives Fixed
143 ---------------------
144
145 - Fix ``deprecated-method`` false positive when alias for method is similar to
146 name of deprecated method.
147
148 Closes #5886 (`#5886 <https://github.com/pylint-dev/pylint/issues/5886>`_)
149
150 - Fix a false positive for ``used-before-assignment`` for imports guarded by
151 ``typing.TYPE_CHECKING`` later used in variable annotations.
152
153 Closes #7609 (`#7609 <https://github.com/pylint-dev/pylint/issues/7609>`_)
154
155
156
157 Other Bug Fixes
158 ---------------
159
160 - Pylint will now filter duplicates given to it before linting. The output
161 should
162 be the same whether a file is given/discovered multiple times or not.
163
164 Closes #6242, #4053 (`#6242 <https://github.com/pylint-dev/pylint/issues/6242>`_)
165
166 - Fixes a crash in ``stop-iteration-return`` when the ``next`` builtin is
167 called without arguments.
168
169 Closes #7828 (`#7828 <https://github.com/pylint-dev/pylint/issues/7828>`_)
170
171
172 What's new in Pylint 2.15.6?
173 ----------------------------
174 Release date: 2022-11-19
175
176
177 False Positives Fixed
178 ---------------------
179
180 - Fix false positive for ``unhashable-member`` when subclassing ``dict`` and
181 using the subclass as a dictionary key.
182
183 Closes #7501 (`#7501 <https://github.com/pylint-dev/pylint/issues/7501>`_)
184
185 - ``unnecessary-list-index-lookup`` will not be wrongly emitted if
186 ``enumerate`` is called with ``start``.
187
188 Closes #7682 (`#7682 <https://github.com/pylint-dev/pylint/issues/7682>`_)
189
190 - Don't warn about ``stop-iteration-return`` when using ``next()`` over
191 ``itertools.cycle``.
192
193 Closes #7765 (`#7765 <https://github.com/pylint-dev/pylint/issues/7765>`_)
194
195
196
197 Other Bug Fixes
198 ---------------
199
200 - Messages sent to reporter are now copied so a reporter cannot modify the
201 message sent to other reporters.
202
203 Closes #7214 (`#7214 <https://github.com/pylint-dev/pylint/issues/7214>`_)
204
205 - Fixes edge case of custom method named ``next`` raised an astroid error.
206
207 Closes #7610 (`#7610 <https://github.com/pylint-dev/pylint/issues/7610>`_)
208
209 - Fix crash that happened when parsing files with unexpected encoding starting
210 with 'utf' like ``utf13``.
211
212 Closes #7661 (`#7661 <https://github.com/pylint-dev/pylint/issues/7661>`_)
213
214 - Fix a crash when a child class with an ``__init__`` method inherits from a
215 parent class with an ``__init__`` class attribute.
216
217 Closes #7742 (`#7742 <https://github.com/pylint-dev/pylint/issues/7742>`_)
218
219
220 What's new in Pylint 2.15.5?
221 ----------------------------
222 Release date: 2022-10-21
223
224
225 False Positives Fixed
226 ---------------------
227
228 - Fix a false positive for ``simplify-boolean-expression`` when multiple values
229 are inferred for a constant.
230
231 Closes #7626 (`#7626 <https://github.com/pylint-dev/pylint/issues/7626>`_)
232
233
234
235 Other Bug Fixes
236 ---------------
237
238 - Remove ``__index__`` dunder method call from ``unnecessary-dunder-call``
239 check.
240
241 Closes #6795 (`#6795 <https://github.com/pylint-dev/pylint/issues/6795>`_)
242
243 - Fixed a multi-processing crash that prevents using any more than 1 thread on
244 MacOS.
245
246 The returned module objects and errors that were cached by the linter plugin
247 loader
248 cannot be reliably pickled. This means that ``dill`` would throw an error
249 when
250 attempting to serialise the linter object for multi-processing use.
251
252 Closes #7635. (`#7635 <https://github.com/pylint-dev/pylint/issues/7635>`_)
253
254
255
256 Other Changes
257 -------------
258
259 - Add a keyword-only ``compare_constants`` argument to ``safe_infer``.
260
261 Refs #7626 (`#7626 <https://github.com/pylint-dev/pylint/issues/7626>`_)
262
263 - Sort ``--generated-rcfile`` output.
264
265 Refs #7655 (`#7655 <https://github.com/pylint-dev/pylint/issues/7655>`_)
266
267
268 What's new in Pylint 2.15.4?
269 ----------------------------
270 Release date: 2022-10-10
271
272
273 False Positives Fixed
274 ---------------------
275
276 - Fix the message for ``unnecessary-dunder-call`` for ``__aiter__`` and
277 ``__anext__``. Also
278 only emit the warning when ``py-version`` >= 3.10.
279
280 Closes #7529 (`#7529 <https://github.com/pylint-dev/pylint/issues/7529>`_)
281
282
283
284 Other Bug Fixes
285 ---------------
286
287 - Fix bug in detecting ``unused-variable`` when iterating on variable.
288
289 Closes #3044 (`#3044 <https://github.com/pylint-dev/pylint/issues/3044>`_)
290
291 - Fixed handling of ``--`` as separator between positional arguments and flags.
292 This was not actually fixed in 2.14.5.
293
294 Closes #7003, Refs #7096 (`#7003
295 <https://github.com/pylint-dev/pylint/issues/7003>`_)
296
297 - Report ``no-self-argument`` rather than ``no-method-argument`` for methods
298 with variadic arguments.
299
300 Closes #7507 (`#7507 <https://github.com/pylint-dev/pylint/issues/7507>`_)
301
302 - Fixed an issue where ``syntax-error`` couldn't be raised on files with
303 invalid encodings.
304
305 Closes #7522 (`#7522 <https://github.com/pylint-dev/pylint/issues/7522>`_)
306
307 - Fix false positive for ``redefined-outer-name`` when aliasing ``typing``
308 e.g. as ``t`` and guarding imports under ``t.TYPE_CHECKING``.
309
310 Closes #7524 (`#7524 <https://github.com/pylint-dev/pylint/issues/7524>`_)
311
312 - Fixed a crash of the ``modified_iterating`` checker when iterating on a set
313 defined as a class attribute.
314
315 Closes #7528 (`#7528 <https://github.com/pylint-dev/pylint/issues/7528>`_)
316
317 - Fix bug in scanning of names inside arguments to ``typing.Literal``.
318 See https://peps.python.org/pep-0586/#literals-enums-and-forward-references
319 for details.
320
321 Refs #3299 (`#3299 <https://github.com/pylint-dev/pylint/issues/3299>`_)
322
323
324 Other Changes
325 -------------
326
327 - Add method name to the error messages of ``no-method-argument`` and
328 ``no-self-argument``.
329
330 Closes #7507 (`#7507 <https://github.com/pylint-dev/pylint/issues/7507>`_)
331
332
333 What's new in Pylint 2.15.3?
334 ----------------------------
335 Release date: 2022-09-19
336
337
338 - Fixed a crash in the ``unhashable-member`` checker when using a ``lambda`` as a dict key.
339
340 Closes #7453 (`#7453 <https://github.com/pylint-dev/pylint/issues/7453>`_)
341 - Fix a crash in the ``modified-iterating-dict`` checker involving instance attributes.
342
343 Closes #7461 (`#7461 <https://github.com/pylint-dev/pylint/issues/7461>`_)
344 - ``invalid-class-object`` does not crash anymore when ``__class__`` is assigned alongside another variable.
345
346 Closes #7467 (`#7467 <https://github.com/pylint-dev/pylint/issues/7467>`_)
347 - Fix false positive for ``global-variable-not-assigned`` when a global variable is re-assigned via an ``ImportFrom`` node.
348
349 Closes #4809 (`#4809 <https://github.com/pylint-dev/pylint/issues/4809>`_)
350 - Fix false positive for ``undefined-loop-variable`` in ``for-else`` loops that use a function
351 having a return type annotation of ``NoReturn`` or ``Never``.
352
353 Closes #7311 (`#7311 <https://github.com/pylint-dev/pylint/issues/7311>`_)
354 - ``--help-msg`` now accepts a comma-separated list of message IDs again.
355
356 Closes #7471 (`#7471 <https://github.com/pylint-dev/pylint/issues/7471>`_)
357
358 What's new in Pylint 2.15.2?
359 ----------------------------
360 Release date: 2022-09-07
361
362 - Fixed a case where custom plugins specified by command line could silently fail.
363
364 Specifically, if a plugin relies on the ``init-hook`` option changing ``sys.path`` before
365 it can be imported, this will now emit a ``bad-plugin-value`` message. Before this
366 change, it would silently fail to register the plugin for use, but would load
367 any configuration, which could have unintended effects.
368
369 Fixes part of #7264. (`#7264 <https://github.com/pylint-dev/pylint/issues/7264>`_)
370 - Fix ``used-before-assignment`` for functions/classes defined in type checking guard.
371
372 Closes #7368 (`#7368 <https://github.com/pylint-dev/pylint/issues/7368>`_)
373 - Update ``modified_iterating`` checker to fix a crash with ``for`` loops on empty list.
374
375 Closes #7380 (`#7380 <https://github.com/pylint-dev/pylint/issues/7380>`_)
376 - The ``docparams`` extension now considers typing in Numpy style docstrings
377 as "documentation" for the ``missing-param-doc`` message.
378
379 Refs #7398 (`#7398 <https://github.com/pylint-dev/pylint/issues/7398>`_)
380 - Fix false positive for ``unused-variable`` and ``unused-import`` when a name is only used in a string literal type annotation.
381
382 Closes #3299 (`#3299 <https://github.com/pylint-dev/pylint/issues/3299>`_)
383 - 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.
384
385 Closes #6592 (`#6592 <https://github.com/pylint-dev/pylint/issues/6592>`_)
386 - Fix ignored files being linted when passed on stdin.
387
388 Closes #4354 (`#4354 <https://github.com/pylint-dev/pylint/issues/4354>`_)
389 - ``missing-return-doc``, ``missing-raises-doc`` and ``missing-yields-doc`` now respect
390 the ``no-docstring-rgx`` option.
391
392 Closes #4743 (`#4743 <https://github.com/pylint-dev/pylint/issues/4743>`_)
393 - Don't crash on ``OSError`` in config file discovery.
394
395 Closes #7169 (`#7169 <https://github.com/pylint-dev/pylint/issues/7169>`_)
396 - ``disable-next`` is now correctly scoped to only the succeeding line.
397
398 Closes #7401 (`#7401 <https://github.com/pylint-dev/pylint/issues/7401>`_)
399 - Update ``modified_iterating`` checker to fix a crash with ``for`` loops on empty list.
400
401 Closes #7380 (`#7380 <https://github.com/pylint-dev/pylint/issues/7380>`_)
402
403 What's new in Pylint 2.15.1?
404 ----------------------------
405 Release date: 2022-09-06
406
407 This is a "github only release", it was mistakenly released as ``2.16.0-dev`` on pypi. Replaced by ``2.15.2``.
408
409 What's new in Pylint 2.15.0?
410 ----------------------------
411
412 New Checks
413 ----------
414
415 - Added new checker ``missing-timeout`` to warn of default timeout values that could cause
416 a program to be hanging indefinitely.
417
418 Refs #6780 (`#6780 <https://github.com/pylint-dev/pylint/issues/6780>`_)
419
420
421 False Positives Fixed
422 ---------------------
423
424 - Don't report ``super-init-not-called`` for abstract ``__init__`` methods.
425
426 Closes #3975 (`#3975 <https://github.com/pylint-dev/pylint/issues/3975>`_)
427 - Don't report ``unsupported-binary-operation`` on Python <= 3.9 when using the ``|`` operator
428 with types, if one has a metaclass that overloads ``__or__`` or ``__ror__`` as appropriate.
429
430 Closes #4951 (`#4951 <https://github.com/pylint-dev/pylint/issues/4951>`_)
431 - Don't report ``no-value-for-parameter`` for dataclasses fields annotated with ``KW_ONLY``.
432
433 Closes #5767 (`#5767 <https://github.com/pylint-dev/pylint/issues/5767>`_)
434 - Fixed inference of ``Enums`` when they are imported under an alias.
435
436 Closes #5776 (`#5776 <https://github.com/pylint-dev/pylint/issues/5776>`_)
437 - Prevent false positives when accessing ``PurePath.parents`` by index (not slice) on Python 3.10+.
438
439 Closes #5832 (`#5832 <https://github.com/pylint-dev/pylint/issues/5832>`_)
440 - ``unnecessary-list-index-lookup`` is now more conservative to avoid potential false positives.
441
442 Closes #6896 (`#6896 <https://github.com/pylint-dev/pylint/issues/6896>`_)
443 - Fix double emitting ``trailing-whitespace`` for multi-line docstrings.
444
445 Closes #6936 (`#6936 <https://github.com/pylint-dev/pylint/issues/6936>`_)
446 - ``import-error`` now correctly checks for ``contextlib.suppress`` guards on import statements.
447
448 Closes #7270 (`#7270 <https://github.com/pylint-dev/pylint/issues/7270>`_)
449 - Fix false positive for `no-self-argument`/`no-method-argument` when a staticmethod is applied to a function but uses a different name.
450
451 Closes #7300 (`#7300 <https://github.com/pylint-dev/pylint/issues/7300>`_)
452 - Fix `undefined-loop-variable` with `break` and `continue` statements in `else` blocks.
453
454 Refs #7311 (`#7311 <https://github.com/pylint-dev/pylint/issues/7311>`_)
455 - Improve default TypeVar name regex. Disallow names prefixed with ``T``.
456 E.g. use ``AnyStrT`` instead of ``TAnyStr``.
457
458 Refs #7322 (`#7322 <https://github.com/pylint-dev/pylint/issues/7322>`_`)
459
460
461 False Negatives Fixed
462 ---------------------
463
464 - Emit ``used-before-assignment`` when relying on a name that is reimported later in a function.
465
466 Closes #4624 (`#4624 <https://github.com/pylint-dev/pylint/issues/4624>`_)
467 - Emit ``used-before-assignment`` for self-referencing named expressions (``:=``) lacking
468 prior assignments.
469
470 Closes #5653 (`#5653 <https://github.com/pylint-dev/pylint/issues/5653>`_)
471 - Emit ``used-before-assignment`` for self-referencing assignments under if conditions.
472
473 Closes #6643 (`#6643 <https://github.com/pylint-dev/pylint/issues/6643>`_)
474 - Emit ``modified-iterating-list`` and analogous messages for dicts and sets when iterating
475 literals, or when using the ``del`` keyword.
476
477 Closes #6648 (`#6648 <https://github.com/pylint-dev/pylint/issues/6648>`_)
478 - Emit ``used-before-assignment`` when calling nested functions before assignment.
479
480 Closes #6812 (`#6812 <https://github.com/pylint-dev/pylint/issues/6812>`_)
481 - Emit ``nonlocal-without-binding`` when a nonlocal name has been assigned at a later point in the same scope.
482
483 Closes #6883 (`#6883 <https://github.com/pylint-dev/pylint/issues/6883>`_)
484 - Emit ``using-constant-test`` when testing the truth value of a variable or call result
485 holding a generator.
486
487 Closes #6909 (`#6909 <https://github.com/pylint-dev/pylint/issues/6909>`_)
488 - Rename ``unhashable-dict-key`` to ``unhashable-member`` and emit when creating sets and dicts,
489 not just when accessing dicts.
490
491 Closes #7034, Closes #7055 (`#7034 <https://github.com/pylint-dev/pylint/issues/7034>`_)
492
493
494 Other Bug Fixes
495 ---------------
496
497 - Fix a failure to lint packages with ``__init__.py`` contained in directories lacking ``__init__.py``.
498
499 Closes #1667 (`#1667 <https://github.com/pylint-dev/pylint/issues/1667>`_)
500 - Fixed a :ref:`syntax-error` crash that was not handled properly when the declared encoding of a file
501 was ``utf-9``.
502
503 Closes #3860 (`#3860 <https://github.com/pylint-dev/pylint/issues/3860>`_)
504 - Fix a crash in the ``not-callable`` check when there is ambiguity whether an instance is being incorrectly provided to ``__new__()``.
505
506 Closes #7109 (`#7109 <https://github.com/pylint-dev/pylint/issues/7109>`_)
507 - Fix crash when regex option raises a `re.error` exception.
508
509 Closes #7202 (`#7202 <https://github.com/pylint-dev/pylint/issues/7202>`_)
510 - Fix `undefined-loop-variable` from walrus in comprehension test.
511
512 Closes #7222 (`#7222 <https://github.com/pylint-dev/pylint/issues/7222>`_)
513 - Check for `<cwd>` before removing first item from `sys.path` in `modify_sys_path`.
514
515 Closes #7231 (`#7231 <https://github.com/pylint-dev/pylint/issues/7231>`_)
516 - Fix sys.path pollution in parallel mode.
517
518 Closes #7246 (`#7246 <https://github.com/pylint-dev/pylint/issues/7246>`_)
519 - Prevent `useless-parent-delegation` for delegating to a builtin
520 written in C (e.g. `Exception.__init__`) with non-self arguments.
521
522 Closes #7319 (`#7319 <https://github.com/pylint-dev/pylint/issues/7319>`_)
523
524
525 Other Changes
526 -------------
527
528 - ``bad-exception-context`` has been renamed to ``bad-exception-cause`` as it is about the cause and not the context.
529
530 Closes #3694 (`#3694 <https://github.com/pylint-dev/pylint/issues/3694>`_)
531 - The message for ``literal-comparison`` is now more explicit about the problem and the
532 solution.
533
534 Closes #5237 (`#5237 <https://github.com/pylint-dev/pylint/issues/5237>`_)
535 - ``useless-super-delegation`` has been renamed to ``useless-parent-delegation`` in order to be more generic.
536
537 Closes #6953 (`#6953 <https://github.com/pylint-dev/pylint/issues/6953>`_)
538 - Pylint now uses ``towncrier`` for changelog generation.
539
540 Refs #6974 (`#6974 <https://github.com/pylint-dev/pylint/issues/6974>`_)
541 - Update ``astroid`` to 2.12.
542
543 Refs #7153 (`#7153 <https://github.com/pylint-dev/pylint/issues/7153>`_)
544 - Fix crash when a type-annotated `__slots__` with no value is declared.
545
546 Closes #7280 (`#7280 <https://github.com/pylint-dev/pylint/issues/7280>`_)
547
548
549 Internal Changes
550 ----------------
551
552 - Fixed an issue where it was impossible to update functional tests output when the existing
553 output was impossible to parse. Instead of raising an error we raise a warning message and
554 let the functional test fail with a default value.
555
556 Refs #6891 (`#6891 <https://github.com/pylint-dev/pylint/issues/6891>`_)
557 - ``pylint.testutils.primer`` is now a private API.
558
559 Refs #6905 (`#6905 <https://github.com/pylint-dev/pylint/issues/6905>`_)
560 - We changed the way we handle the changelog internally by using towncrier.
561 If you're a contributor you won't have to fix merge conflicts in the
562 changelog anymore.
563
564 Closes #6974 (`#6974 <https://github.com/pylint-dev/pylint/issues/6974>`_)
565 - Pylint is now using Scorecards to implement security recommendations from the
566 `OpenSSF <https://openssf.org/>`_. This is done in order to secure our supply chains using a combination
567 of automated tooling and best practices, most of which were already implemented before.
568
569 Refs #7267 (`#7267 <https://github.com/pylint-dev/pylint/issues/7267>`_)