| 1 |
*************************** |
| 2 |
What's New in Pylint 2.16 |
| 3 |
*************************** |
| 4 |
|
| 5 |
.. toctree:: |
| 6 |
:maxdepth: 2 |
| 7 |
|
| 8 |
:Release: 2.16 |
| 9 |
:Date: 2023-02-01 |
| 10 |
|
| 11 |
Summary -- Release highlights |
| 12 |
============================= |
| 13 |
|
| 14 |
In 2.16.0 we added aggregation and composition understanding in ``pyreverse``, and a way to clear |
| 15 |
the cache in between run in server mode (originally for the VS Code integration). Apart from the bug |
| 16 |
fixes there's also a lot of new checks, and new extensions that have been asked for for a long time |
| 17 |
that were implemented. |
| 18 |
|
| 19 |
If you want to benefit from all the new checks load the following plugins:: |
| 20 |
|
| 21 |
pylint.extensions.dict_init_mutate, |
| 22 |
pylint.extensions.dunder, |
| 23 |
pylint.extensions.typing, |
| 24 |
pylint.extensions.magic_value, |
| 25 |
|
| 26 |
We still welcome any community effort to help review, integrate, and add good/bad examples to the doc for |
| 27 |
<https://github.com/pylint-dev/pylint/issues/5953>`_. This should be doable without any ``pylint`` or ``astroid`` |
| 28 |
knowledge, so this is the perfect entrypoint if you want to contribute to ``pylint`` or open source without |
| 29 |
any experience with our code! |
| 30 |
|
| 31 |
Last but not least @clavedeluna and @nickdrozd became triagers, welcome to the team ! |
| 32 |
|
| 33 |
.. towncrier release notes start |
| 34 |
|
| 35 |
What's new in Pylint 2.16.4? |
| 36 |
---------------------------- |
| 37 |
Release date: 2023-03-06 |
| 38 |
|
| 39 |
|
| 40 |
False Positives Fixed |
| 41 |
--------------------- |
| 42 |
|
| 43 |
- Fix false positive for :ref:`isinstance-second-argument-not-valid-type` with union |
| 44 |
types. |
| 45 |
|
| 46 |
Closes #8205 (`#8205 <https://github.com/pylint-dev/pylint/issues/8205>`_) |
| 47 |
|
| 48 |
|
| 49 |
What's new in Pylint 2.16.3? |
| 50 |
---------------------------- |
| 51 |
Release date: 2023-03-03 |
| 52 |
|
| 53 |
|
| 54 |
False Positives Fixed |
| 55 |
--------------------- |
| 56 |
|
| 57 |
- Fix false positive for ``wrong-spelling-in-comment`` with class names in a |
| 58 |
python 2 type comment. |
| 59 |
|
| 60 |
Closes #8370 (`#8370 <https://github.com/pylint-dev/pylint/issues/8370>`_) |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
Other Bug Fixes |
| 65 |
--------------- |
| 66 |
|
| 67 |
- Prevent emitting ``invalid-name`` for the line on which a ``global`` |
| 68 |
statement is declared. |
| 69 |
|
| 70 |
Closes #8307 (`#8307 <https://github.com/pylint-dev/pylint/issues/8307>`_) |
| 71 |
|
| 72 |
|
| 73 |
What's new in Pylint 2.16.2? |
| 74 |
---------------------------- |
| 75 |
Release date: 2023-02-13 |
| 76 |
|
| 77 |
|
| 78 |
New Features |
| 79 |
------------ |
| 80 |
|
| 81 |
- Add `--version` option to `pyreverse`. |
| 82 |
|
| 83 |
Refs #7851 (`#7851 <https://github.com/pylint-dev/pylint/issues/7851>`_) |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
False Positives Fixed |
| 88 |
--------------------- |
| 89 |
|
| 90 |
- Fix false positive for ``used-before-assignment`` when |
| 91 |
``typing.TYPE_CHECKING`` is used with if/elif/else blocks. |
| 92 |
|
| 93 |
Closes #7574 (`#7574 <https://github.com/pylint-dev/pylint/issues/7574>`_) |
| 94 |
|
| 95 |
- Fix false positive for ``used-before-assignment`` for named expressions |
| 96 |
appearing after the first element in a list, tuple, or set. |
| 97 |
|
| 98 |
Closes #8252 (`#8252 <https://github.com/pylint-dev/pylint/issues/8252>`_) |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
Other Bug Fixes |
| 103 |
--------------- |
| 104 |
|
| 105 |
- Fix ``used-before-assignment`` false positive when the walrus operator |
| 106 |
is used with a ternary operator in dictionary key/value initialization. |
| 107 |
|
| 108 |
Closes #8125 (`#8125 <https://github.com/pylint-dev/pylint/issues/8125>`_) |
| 109 |
|
| 110 |
- Fix ``no-name-in-module`` false positive raised when a package defines a |
| 111 |
variable with the |
| 112 |
same name as one of its submodules. |
| 113 |
|
| 114 |
Closes #8148 (`#8148 <https://github.com/pylint-dev/pylint/issues/8148>`_) |
| 115 |
|
| 116 |
- Fix ``nested-min-max`` suggestion message to indicate it's possible to splat |
| 117 |
iterable objects. |
| 118 |
|
| 119 |
Closes #8168 (`#8168 <https://github.com/pylint-dev/pylint/issues/8168>`_) |
| 120 |
|
| 121 |
- Fix a crash happening when a class attribute was negated in the start |
| 122 |
argument of an enumerate. |
| 123 |
|
| 124 |
Closes #8207 (`#8207 <https://github.com/pylint-dev/pylint/issues/8207>`_) |
| 125 |
|
| 126 |
|
| 127 |
What's new in Pylint 2.16.1? |
| 128 |
---------------------------- |
| 129 |
Release date: 2023-02-02 |
| 130 |
|
| 131 |
|
| 132 |
Other Bug Fixes |
| 133 |
--------------- |
| 134 |
|
| 135 |
- Fix a crash happening for python interpreter < 3.9 following a failed typing |
| 136 |
update. |
| 137 |
|
| 138 |
Closes #8161 (`#8161 <https://github.com/pylint-dev/pylint/issues/8161>`_) |
| 139 |
|
| 140 |
|
| 141 |
What's new in Pylint 2.16.0? |
| 142 |
---------------------------- |
| 143 |
Release date: 2023-02-01 |
| 144 |
|
| 145 |
|
| 146 |
Changes requiring user actions |
| 147 |
------------------------------ |
| 148 |
|
| 149 |
- The ``accept-no-raise-doc`` option related to ``missing-raises-doc`` will now |
| 150 |
be correctly taken into account all the time. |
| 151 |
|
| 152 |
Pylint will no longer raise :ref:`missing-raises-doc` (W9006) when no exceptions are |
| 153 |
documented and accept-no-raise-doc is true (issue #7208). |
| 154 |
If you were expecting :ref:`missing-raises-doc` errors to be raised in that case, |
| 155 |
you |
| 156 |
will now have to add ``accept-no-raise-doc=no`` in your configuration to keep |
| 157 |
the same behavior. |
| 158 |
|
| 159 |
Closes #7208 (`#7208 <https://github.com/pylint-dev/pylint/issues/7208>`_) |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
New Features |
| 164 |
------------ |
| 165 |
|
| 166 |
- Added the ``no-header`` output format. If enabled with |
| 167 |
``--output-format=no-header``, it will not include the module name in the |
| 168 |
output. |
| 169 |
|
| 170 |
Closes #5362 (`#5362 <https://github.com/pylint-dev/pylint/issues/5362>`_) |
| 171 |
|
| 172 |
- Added configuration option ``clear-cache-post-run`` to support server-like |
| 173 |
usage. |
| 174 |
Use this flag if you expect the linted files to be altered between runs. |
| 175 |
|
| 176 |
Refs #5401 (`#5401 <https://github.com/pylint-dev/pylint/issues/5401>`_) |
| 177 |
|
| 178 |
- Add ``--allow-reexport-from-package`` option to configure the |
| 179 |
``useless-import-alias`` check not to emit a warning if a name |
| 180 |
is reexported from a package. |
| 181 |
|
| 182 |
Closes #6006 (`#6006 <https://github.com/pylint-dev/pylint/issues/6006>`_) |
| 183 |
|
| 184 |
- Update ``pyreverse`` to differentiate between aggregations and compositions. |
| 185 |
``pyreverse`` checks if it's an Instance or a Call of an object via method |
| 186 |
parameters (via type hints) |
| 187 |
to decide if it's a composition or an aggregation. |
| 188 |
|
| 189 |
Refs #6543 (`#6543 <https://github.com/pylint-dev/pylint/issues/6543>`_) |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
New Checks |
| 194 |
---------- |
| 195 |
|
| 196 |
- Adds a ``pointless-exception-statement`` check that emits a warning when an |
| 197 |
Exception is created and not assigned, raised or returned. |
| 198 |
|
| 199 |
Refs #3110 (`#3110 <https://github.com/pylint-dev/pylint/issues/3110>`_) |
| 200 |
|
| 201 |
- Add a ``shadowed-import`` message for aliased imports. |
| 202 |
|
| 203 |
Closes #4836 (`#4836 <https://github.com/pylint-dev/pylint/issues/4836>`_) |
| 204 |
|
| 205 |
- Add new check called ``unbalanced-dict-unpacking`` to check for unbalanced |
| 206 |
dict unpacking |
| 207 |
in assignment and for loops. |
| 208 |
|
| 209 |
Closes #5797 (`#5797 <https://github.com/pylint-dev/pylint/issues/5797>`_) |
| 210 |
|
| 211 |
- Add new checker ``positional-only-arguments-expected`` to check for cases |
| 212 |
when |
| 213 |
positional-only arguments have been passed as keyword arguments. |
| 214 |
|
| 215 |
Closes #6489 (`#6489 <https://github.com/pylint-dev/pylint/issues/6489>`_) |
| 216 |
|
| 217 |
- Added ``singledispatch-method`` which informs that ``@singledispatch`` should |
| 218 |
decorate functions and not class/instance methods. |
| 219 |
Added ``singledispatchmethod-function`` which informs that |
| 220 |
``@singledispatchmethod`` should decorate class/instance methods and not |
| 221 |
functions. |
| 222 |
|
| 223 |
Closes #6917 (`#6917 <https://github.com/pylint-dev/pylint/issues/6917>`_) |
| 224 |
|
| 225 |
- Rename ``broad-except`` to ``broad-exception-caught`` and add new checker |
| 226 |
``broad-exception-raised`` |
| 227 |
which will warn if general exceptions ``BaseException`` or ``Exception`` are |
| 228 |
raised. |
| 229 |
|
| 230 |
Closes #7494 (`#7494 <https://github.com/pylint-dev/pylint/issues/7494>`_) |
| 231 |
|
| 232 |
- Added ``nested-min-max`` which flags ``min(1, min(2, 3))`` to simplify to |
| 233 |
``min(1, 2, 3)``. |
| 234 |
|
| 235 |
Closes #7546 (`#7546 <https://github.com/pylint-dev/pylint/issues/7546>`_) |
| 236 |
|
| 237 |
- Extended ``use-dict-literal`` to also warn about call to ``dict()`` when |
| 238 |
passing keyword arguments. |
| 239 |
|
| 240 |
Closes #7690 (`#7690 <https://github.com/pylint-dev/pylint/issues/7690>`_) |
| 241 |
|
| 242 |
- Add ``named-expr-without-context`` check to emit a warning if a named |
| 243 |
expression is used outside a context like ``if``, ``for``, ``while``, or |
| 244 |
a comprehension. |
| 245 |
|
| 246 |
Refs #7760 (`#7760 <https://github.com/pylint-dev/pylint/issues/7760>`_) |
| 247 |
|
| 248 |
- Add ``invalid-slice-step`` check to warn about a slice step value of ``0`` |
| 249 |
for common builtin sequences. |
| 250 |
|
| 251 |
Refs #7762 (`#7762 <https://github.com/pylint-dev/pylint/issues/7762>`_) |
| 252 |
|
| 253 |
- Add ``consider-refactoring-into-while-condition`` check to recommend |
| 254 |
refactoring when |
| 255 |
a while loop is defined with a constant condition with an immediate ``if`` |
| 256 |
statement to check for ``break`` condition as a first statement. |
| 257 |
|
| 258 |
Closes #8015 (`#8015 <https://github.com/pylint-dev/pylint/issues/8015>`_) |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
Extensions |
| 263 |
---------- |
| 264 |
|
| 265 |
- Add new extension checker ``dict-init-mutate`` that flags mutating a |
| 266 |
dictionary immediately |
| 267 |
after the dictionary was created. |
| 268 |
|
| 269 |
Closes #2876 (`#2876 <https://github.com/pylint-dev/pylint/issues/2876>`_) |
| 270 |
|
| 271 |
- Added ``bad-dunder-name`` extension check, which flags bad or misspelled |
| 272 |
dunder methods. |
| 273 |
You can use the ``good-dunder-names`` option to allow specific dunder names. |
| 274 |
|
| 275 |
Closes #3038 (`#3038 <https://github.com/pylint-dev/pylint/issues/3038>`_) |
| 276 |
|
| 277 |
- Added ``consider-using-augmented-assign`` check for ``CodeStyle`` extension |
| 278 |
which flags ``x = x + 1`` to simplify to ``x += 1``. |
| 279 |
This check is disabled by default. To use it, load the code style extension |
| 280 |
with ``load-plugins=pylint.extensions.code_style`` and add |
| 281 |
``consider-using-augmented-assign`` in the ``enable`` option. |
| 282 |
|
| 283 |
Closes #3391 (`#3391 <https://github.com/pylint-dev/pylint/issues/3391>`_) |
| 284 |
|
| 285 |
- Add ``magic-number`` plugin checker for comparison with constants instead of |
| 286 |
named constants or enums. |
| 287 |
You can use it with ``--load-plugins=pylint.extensions.magic_value``. |
| 288 |
|
| 289 |
Closes #7281 (`#7281 <https://github.com/pylint-dev/pylint/issues/7281>`_) |
| 290 |
|
| 291 |
- Add ``redundant-typehint-argument`` message for `typing` plugin for duplicate |
| 292 |
assign typehints. |
| 293 |
Enable the plugin to enable the message with: |
| 294 |
``--load-plugins=pylint.extensions.typing``. |
| 295 |
|
| 296 |
Closes #7636 (`#7636 <https://github.com/pylint-dev/pylint/issues/7636>`_) |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
False Positives Fixed |
| 301 |
--------------------- |
| 302 |
|
| 303 |
- Fix false positive for ``unused-variable`` and ``unused-import`` when a name |
| 304 |
is only used in a string literal type annotation. |
| 305 |
|
| 306 |
Closes #3299 (`#3299 <https://github.com/pylint-dev/pylint/issues/3299>`_) |
| 307 |
|
| 308 |
- Document a known false positive for ``useless-suppression`` when disabling |
| 309 |
``line-too-long`` in a module with only comments and no code. |
| 310 |
|
| 311 |
Closes #3368 (`#3368 <https://github.com/pylint-dev/pylint/issues/3368>`_) |
| 312 |
|
| 313 |
- ``trailing-whitespaces`` is no longer reported within strings. |
| 314 |
|
| 315 |
Closes #3822 (`#3822 <https://github.com/pylint-dev/pylint/issues/3822>`_) |
| 316 |
|
| 317 |
- Fix false positive for ``global-variable-not-assigned`` when a global |
| 318 |
variable is re-assigned via an ``ImportFrom`` node. |
| 319 |
|
| 320 |
Closes #4809 (`#4809 <https://github.com/pylint-dev/pylint/issues/4809>`_) |
| 321 |
|
| 322 |
- Fix false positive for ``use-maxsplit-arg`` with custom split method. |
| 323 |
|
| 324 |
Closes #4857 (`#4857 <https://github.com/pylint-dev/pylint/issues/4857>`_) |
| 325 |
|
| 326 |
- Fix ``logging-fstring-interpolation`` false positive raised when logging and |
| 327 |
f-string with ``%s`` formatting. |
| 328 |
|
| 329 |
Closes #4984 (`#4984 <https://github.com/pylint-dev/pylint/issues/4984>`_) |
| 330 |
|
| 331 |
- Fix false-positive for ``used-before-assignment`` in pattern matching |
| 332 |
with a guard. |
| 333 |
|
| 334 |
Closes #5327 (`#5327 <https://github.com/pylint-dev/pylint/issues/5327>`_) |
| 335 |
|
| 336 |
- Fix ``use-sequence-for-iteration`` when unpacking a set with ``*``. |
| 337 |
|
| 338 |
Closes #5788 (`#5788 <https://github.com/pylint-dev/pylint/issues/5788>`_) |
| 339 |
|
| 340 |
- Fix ``deprecated-method`` false positive when alias for method is similar to |
| 341 |
name of deprecated method. |
| 342 |
|
| 343 |
Closes #5886 (`#5886 <https://github.com/pylint-dev/pylint/issues/5886>`_) |
| 344 |
|
| 345 |
- Fix false positive ``assigning-non-slot`` when a class attribute is |
| 346 |
re-assigned. |
| 347 |
|
| 348 |
Closes #6001 (`#6001 <https://github.com/pylint-dev/pylint/issues/6001>`_) |
| 349 |
|
| 350 |
- Fix false positive for ``too-many-function-args`` when a function call is |
| 351 |
assigned to a class attribute inside the class where the function is defined. |
| 352 |
|
| 353 |
Closes #6592 (`#6592 <https://github.com/pylint-dev/pylint/issues/6592>`_) |
| 354 |
|
| 355 |
- Fixes false positive ``abstract-method`` on Protocol classes. |
| 356 |
|
| 357 |
Closes #7209 (`#7209 <https://github.com/pylint-dev/pylint/issues/7209>`_) |
| 358 |
|
| 359 |
- Pylint now understands the ``kw_only`` keyword argument for ``dataclass``. |
| 360 |
|
| 361 |
Closes #7290, closes #6550, closes #5857 (`#7290 |
| 362 |
<https://github.com/pylint-dev/pylint/issues/7290>`_) |
| 363 |
|
| 364 |
- Fix false positive for ``undefined-loop-variable`` in ``for-else`` loops that |
| 365 |
use a function |
| 366 |
having a return type annotation of ``NoReturn`` or ``Never``. |
| 367 |
|
| 368 |
Closes #7311 (`#7311 <https://github.com/pylint-dev/pylint/issues/7311>`_) |
| 369 |
|
| 370 |
- Fix ``used-before-assignment`` for functions/classes defined in type checking |
| 371 |
guard. |
| 372 |
|
| 373 |
Closes #7368 (`#7368 <https://github.com/pylint-dev/pylint/issues/7368>`_) |
| 374 |
|
| 375 |
- Fix false positive for ``unhashable-member`` when subclassing ``dict`` and |
| 376 |
using the subclass as a dictionary key. |
| 377 |
|
| 378 |
Closes #7501 (`#7501 <https://github.com/pylint-dev/pylint/issues/7501>`_) |
| 379 |
|
| 380 |
- Fix the message for ``unnecessary-dunder-call`` for ``__aiter__`` and |
| 381 |
``__aneext__``. Also |
| 382 |
only emit the warning when ``py-version`` >= 3.10. |
| 383 |
|
| 384 |
Closes #7529 (`#7529 <https://github.com/pylint-dev/pylint/issues/7529>`_) |
| 385 |
|
| 386 |
- Fix ``used-before-assignment`` false positive when else branch calls |
| 387 |
``sys.exit`` or similar terminating functions. |
| 388 |
|
| 389 |
Closes #7563 (`#7563 <https://github.com/pylint-dev/pylint/issues/7563>`_) |
| 390 |
|
| 391 |
- Fix a false positive for ``used-before-assignment`` for imports guarded by |
| 392 |
``typing.TYPE_CHECKING`` later used in variable annotations. |
| 393 |
|
| 394 |
Closes #7609 (`#7609 <https://github.com/pylint-dev/pylint/issues/7609>`_) |
| 395 |
|
| 396 |
- Fix a false positive for ``simplify-boolean-expression`` when multiple values |
| 397 |
are inferred for a constant. |
| 398 |
|
| 399 |
Closes #7626 (`#7626 <https://github.com/pylint-dev/pylint/issues/7626>`_) |
| 400 |
|
| 401 |
- ``unnecessary-list-index-lookup`` will not be wrongly emitted if |
| 402 |
``enumerate`` is called with ``start``. |
| 403 |
|
| 404 |
Closes #7682 (`#7682 <https://github.com/pylint-dev/pylint/issues/7682>`_) |
| 405 |
|
| 406 |
- Don't warn about ``stop-iteration-return`` when using ``next()`` over |
| 407 |
``itertools.cycle``. |
| 408 |
|
| 409 |
Closes #7765 (`#7765 <https://github.com/pylint-dev/pylint/issues/7765>`_) |
| 410 |
|
| 411 |
- Fixes ``used-before-assignment`` false positive when the walrus operator |
| 412 |
is used in a ternary operator. |
| 413 |
|
| 414 |
Closes #7779 (`#7779 <https://github.com/pylint-dev/pylint/issues/7779>`_) |
| 415 |
|
| 416 |
- Fix ``missing-param-doc`` false positive when function parameter has an |
| 417 |
escaped underscore. |
| 418 |
|
| 419 |
Closes #7827 (`#7827 <https://github.com/pylint-dev/pylint/issues/7827>`_) |
| 420 |
|
| 421 |
- Fixes ``method-cache-max-size-none`` false positive for methods inheriting |
| 422 |
from ``Enum``. |
| 423 |
|
| 424 |
Closes #7857 (`#7857 <https://github.com/pylint-dev/pylint/issues/7857>`_) |
| 425 |
|
| 426 |
- ``multiple-statements`` no longer triggers for function stubs using inlined |
| 427 |
``...``. |
| 428 |
|
| 429 |
Closes #7860 (`#7860 <https://github.com/pylint-dev/pylint/issues/7860>`_) |
| 430 |
|
| 431 |
- Fix a false positive for ``used-before-assignment`` when a name guarded by |
| 432 |
``if TYPE_CHECKING:`` is used as a type annotation in a function body and |
| 433 |
later re-imported in the same scope. |
| 434 |
|
| 435 |
Closes #7882 (`#7882 <https://github.com/pylint-dev/pylint/issues/7882>`_) |
| 436 |
|
| 437 |
- Prevent ``used-before-assignment`` when imports guarded by ``if |
| 438 |
TYPE_CHECKING`` |
| 439 |
are guarded again when used. |
| 440 |
|
| 441 |
Closes #7979 (`#7979 <https://github.com/pylint-dev/pylint/issues/7979>`_) |
| 442 |
|
| 443 |
- Fixes false positive for ``try-except-raise`` with multiple exceptions in one |
| 444 |
except statement if exception are in different namespace. |
| 445 |
|
| 446 |
Closes #8051 (`#8051 <https://github.com/pylint-dev/pylint/issues/8051>`_) |
| 447 |
|
| 448 |
- Fix ``invalid-name`` errors for ``typing_extension.TypeVar``. |
| 449 |
|
| 450 |
Refs #8089 (`#8089 <https://github.com/pylint-dev/pylint/issues/8089>`_) |
| 451 |
|
| 452 |
- Fix ``no-kwoa`` false positive for context managers. |
| 453 |
|
| 454 |
Closes #8100 (`#8100 <https://github.com/pylint-dev/pylint/issues/8100>`_) |
| 455 |
|
| 456 |
- Fix a false positive for ``redefined-variable-type`` when ``async`` methods |
| 457 |
are present. |
| 458 |
|
| 459 |
Closes #8120 (`#8120 <https://github.com/pylint-dev/pylint/issues/8120>`_) |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
False Negatives Fixed |
| 464 |
--------------------- |
| 465 |
|
| 466 |
- Code following a call to ``quit``, ``exit``, ``sys.exit`` or ``os._exit`` |
| 467 |
will be marked as `unreachable`. |
| 468 |
|
| 469 |
Refs #519 (`#519 <https://github.com/pylint-dev/pylint/issues/519>`_) |
| 470 |
|
| 471 |
- Emit ``used-before-assignment`` when function arguments are redefined inside |
| 472 |
an inner function and accessed there before assignment. |
| 473 |
|
| 474 |
Closes #2374 (`#2374 <https://github.com/pylint-dev/pylint/issues/2374>`_) |
| 475 |
|
| 476 |
- Fix a false negative for ``unused-import`` when one module used an import in |
| 477 |
a type annotation that was also used in another module. |
| 478 |
|
| 479 |
Closes #4150 (`#4150 <https://github.com/pylint-dev/pylint/issues/4150>`_) |
| 480 |
|
| 481 |
- Flag ``superfluous-parens`` if parentheses are used during string |
| 482 |
concatenation. |
| 483 |
|
| 484 |
Closes #4792 (`#4792 <https://github.com/pylint-dev/pylint/issues/4792>`_) |
| 485 |
|
| 486 |
- Emit ``used-before-assignment`` when relying on names only defined under |
| 487 |
conditions always testing false. |
| 488 |
|
| 489 |
Closes #4913 (`#4913 <https://github.com/pylint-dev/pylint/issues/4913>`_) |
| 490 |
|
| 491 |
- ``consider-using-join`` can now be emitted for non-empty string separators. |
| 492 |
|
| 493 |
Closes #6639 (`#6639 <https://github.com/pylint-dev/pylint/issues/6639>`_) |
| 494 |
|
| 495 |
- Emit ``used-before-assignment`` for further imports guarded by |
| 496 |
``TYPE_CHECKING`` |
| 497 |
|
| 498 |
Previously, this message was only emitted for imports guarded directly under |
| 499 |
``TYPE_CHECKING``, not guarded two if-branches deep, nor when |
| 500 |
``TYPE_CHECKING`` |
| 501 |
was imported from ``typing`` under an alias. |
| 502 |
|
| 503 |
Closes #7539 (`#7539 <https://github.com/pylint-dev/pylint/issues/7539>`_) |
| 504 |
|
| 505 |
- Fix a false negative for ``unused-import`` when a constant inside |
| 506 |
``typing.Annotated`` was treated as a reference to an import. |
| 507 |
|
| 508 |
Closes #7547 (`#7547 <https://github.com/pylint-dev/pylint/issues/7547>`_) |
| 509 |
|
| 510 |
- ``consider-using-any-or-all`` message will now be raised in cases when |
| 511 |
boolean is initialized, reassigned during loop, and immediately returned. |
| 512 |
|
| 513 |
Closes #7699 (`#7699 <https://github.com/pylint-dev/pylint/issues/7699>`_) |
| 514 |
|
| 515 |
- Extend ``invalid-slice-index`` to emit an warning for invalid slice indices |
| 516 |
used with string and byte sequences, and range objects. |
| 517 |
|
| 518 |
Refs #7762 (`#7762 <https://github.com/pylint-dev/pylint/issues/7762>`_) |
| 519 |
|
| 520 |
- Fixes ``unnecessary-list-index-lookup`` false negative when ``enumerate`` is |
| 521 |
called with ``iterable`` as a kwarg. |
| 522 |
|
| 523 |
Closes #7770 (`#7770 <https://github.com/pylint-dev/pylint/issues/7770>`_) |
| 524 |
|
| 525 |
- ``no-else-return`` or ``no-else-raise`` will be emitted if ``except`` block |
| 526 |
always returns or raises. |
| 527 |
|
| 528 |
Closes #7788 (`#7788 <https://github.com/pylint-dev/pylint/issues/7788>`_) |
| 529 |
|
| 530 |
- Fix ``dangerous-default-value`` false negative when ``*`` is used. |
| 531 |
|
| 532 |
Closes #7818 (`#7818 <https://github.com/pylint-dev/pylint/issues/7818>`_) |
| 533 |
|
| 534 |
- ``consider-using-with`` now triggers for ``pathlib.Path.open``. |
| 535 |
|
| 536 |
Closes #7964 (`#7964 <https://github.com/pylint-dev/pylint/issues/7964>`_) |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
Other Bug Fixes |
| 541 |
--------------- |
| 542 |
|
| 543 |
- Fix bug in detecting ``unused-variable`` when iterating on variable. |
| 544 |
|
| 545 |
Closes #3044 (`#3044 <https://github.com/pylint-dev/pylint/issues/3044>`_) |
| 546 |
|
| 547 |
- Fix bug in scanning of names inside arguments to ``typing.Literal``. |
| 548 |
See https://peps.python.org/pep-0586/#literals-enums-and-forward-references |
| 549 |
for details. |
| 550 |
|
| 551 |
Refs #3299 (`#3299 <https://github.com/pylint-dev/pylint/issues/3299>`_) |
| 552 |
|
| 553 |
- Update ``disallowed-name`` check to flag module-level variables. |
| 554 |
|
| 555 |
Closes #3701 (`#3701 <https://github.com/pylint-dev/pylint/issues/3701>`_) |
| 556 |
|
| 557 |
- Pylint will no longer deadlock if a parallel job is killed but fail |
| 558 |
immediately instead. |
| 559 |
|
| 560 |
Closes #3899 (`#3899 <https://github.com/pylint-dev/pylint/issues/3899>`_) |
| 561 |
|
| 562 |
- Fix ignored files being linted when passed on stdin. |
| 563 |
|
| 564 |
Closes #4354 (`#4354 <https://github.com/pylint-dev/pylint/issues/4354>`_) |
| 565 |
|
| 566 |
- Fix ``no-member`` false negative when augmented assign is done manually, |
| 567 |
without ``+=``. |
| 568 |
|
| 569 |
Closes #4562 (`#4562 <https://github.com/pylint-dev/pylint/issues/4562>`_) |
| 570 |
|
| 571 |
- Any assertion on a populated tuple will now receive a ``assert-on-tuple`` |
| 572 |
warning. |
| 573 |
|
| 574 |
Closes #4655 (`#4655 <https://github.com/pylint-dev/pylint/issues/4655>`_) |
| 575 |
|
| 576 |
- ``missing-return-doc``, ``missing-raises-doc`` and ``missing-yields-doc`` now |
| 577 |
respect |
| 578 |
the ``no-docstring-rgx`` option. |
| 579 |
|
| 580 |
Closes #4743 (`#4743 <https://github.com/pylint-dev/pylint/issues/4743>`_) |
| 581 |
|
| 582 |
- Update ``reimported`` help message for clarity. |
| 583 |
|
| 584 |
Closes #4836 (`#4836 <https://github.com/pylint-dev/pylint/issues/4836>`_) |
| 585 |
|
| 586 |
- ``consider-iterating-dictionary`` will no longer be raised if bitwise |
| 587 |
operations are used. |
| 588 |
|
| 589 |
Closes #5478 (`#5478 <https://github.com/pylint-dev/pylint/issues/5478>`_) |
| 590 |
|
| 591 |
- Using custom braces in ``msg-template`` will now work properly. |
| 592 |
|
| 593 |
Closes #5636 (`#5636 <https://github.com/pylint-dev/pylint/issues/5636>`_) |
| 594 |
|
| 595 |
- Pylint will now filter duplicates given to it before linting. The output |
| 596 |
should |
| 597 |
be the same whether a file is given/discovered multiple times or not. |
| 598 |
|
| 599 |
Closes #6242, #4053 (`#6242 <https://github.com/pylint-dev/pylint/issues/6242>`_) |
| 600 |
|
| 601 |
- Remove ``__index__`` dunder method call from ``unnecessary-dunder-call`` |
| 602 |
check. |
| 603 |
|
| 604 |
Closes #6795 (`#6795 <https://github.com/pylint-dev/pylint/issues/6795>`_) |
| 605 |
|
| 606 |
- Fixed handling of ``--`` as separator between positional arguments and flags. |
| 607 |
This was not actually fixed in 2.14.5. |
| 608 |
|
| 609 |
Closes #7003, Refs #7096 (`#7003 |
| 610 |
<https://github.com/pylint-dev/pylint/issues/7003>`_) |
| 611 |
|
| 612 |
- Don't crash on ``OSError`` in config file discovery. |
| 613 |
|
| 614 |
Closes #7169 (`#7169 <https://github.com/pylint-dev/pylint/issues/7169>`_) |
| 615 |
|
| 616 |
- Messages sent to reporter are now copied so a reporter cannot modify the |
| 617 |
message sent to other reporters. |
| 618 |
|
| 619 |
Closes #7214 (`#7214 <https://github.com/pylint-dev/pylint/issues/7214>`_) |
| 620 |
|
| 621 |
- Fixed a case where custom plugins specified by command line could silently |
| 622 |
fail. |
| 623 |
|
| 624 |
Specifically, if a plugin relies on the ``init-hook`` option changing |
| 625 |
``sys.path`` before |
| 626 |
it can be imported, this will now emit a ``bad-plugin-value`` message. Before |
| 627 |
this |
| 628 |
change, it would silently fail to register the plugin for use, but would load |
| 629 |
any configuration, which could have unintended effects. |
| 630 |
|
| 631 |
Fixes part of #7264. (`#7264 <https://github.com/pylint-dev/pylint/issues/7264>`_) |
| 632 |
|
| 633 |
- Update ``modified_iterating`` checker to fix a crash with ``for`` loops on |
| 634 |
empty list. |
| 635 |
|
| 636 |
Closes #7380 (`#7380 <https://github.com/pylint-dev/pylint/issues/7380>`_) |
| 637 |
|
| 638 |
- Update wording for ``arguments-differ`` and ``arguments-renamed`` to clarify |
| 639 |
overriding object. |
| 640 |
|
| 641 |
Closes #7390 (`#7390 <https://github.com/pylint-dev/pylint/issues/7390>`_) |
| 642 |
|
| 643 |
- ``disable-next`` is now correctly scoped to only the succeeding line. |
| 644 |
|
| 645 |
Closes #7401 (`#7401 <https://github.com/pylint-dev/pylint/issues/7401>`_) |
| 646 |
|
| 647 |
- Fixed a crash in the ``unhashable-member`` checker when using a ``lambda`` as |
| 648 |
a dict key. |
| 649 |
|
| 650 |
Closes #7453 (`#7453 <https://github.com/pylint-dev/pylint/issues/7453>`_) |
| 651 |
|
| 652 |
- Add ``mailcap`` to deprecated modules list. |
| 653 |
|
| 654 |
Closes #7457 (`#7457 <https://github.com/pylint-dev/pylint/issues/7457>`_) |
| 655 |
|
| 656 |
- Fix a crash in the ``modified-iterating-dict`` checker involving instance |
| 657 |
attributes. |
| 658 |
|
| 659 |
Closes #7461 (`#7461 <https://github.com/pylint-dev/pylint/issues/7461>`_) |
| 660 |
|
| 661 |
- ``invalid-class-object`` does not crash anymore when ``__class__`` is |
| 662 |
assigned alongside another variable. |
| 663 |
|
| 664 |
Closes #7467 (`#7467 <https://github.com/pylint-dev/pylint/issues/7467>`_) |
| 665 |
|
| 666 |
- ``--help-msg`` now accepts a comma-separated list of message IDs again. |
| 667 |
|
| 668 |
Closes #7471 (`#7471 <https://github.com/pylint-dev/pylint/issues/7471>`_) |
| 669 |
|
| 670 |
- Allow specifying non-builtin exceptions in the ``overgeneral-exception`` |
| 671 |
option |
| 672 |
using an exception's qualified name. |
| 673 |
|
| 674 |
Closes #7495 (`#7495 <https://github.com/pylint-dev/pylint/issues/7495>`_) |
| 675 |
|
| 676 |
- Report ``no-self-argument`` rather than ``no-method-argument`` for methods |
| 677 |
with variadic arguments. |
| 678 |
|
| 679 |
Closes #7507 (`#7507 <https://github.com/pylint-dev/pylint/issues/7507>`_) |
| 680 |
|
| 681 |
- Fixed an issue where ``syntax-error`` couldn't be raised on files with |
| 682 |
invalid encodings. |
| 683 |
|
| 684 |
Closes #7522 (`#7522 <https://github.com/pylint-dev/pylint/issues/7522>`_) |
| 685 |
|
| 686 |
- Fix false positive for ``redefined-outer-name`` when aliasing ``typing`` |
| 687 |
e.g. as ``t`` and guarding imports under ``t.TYPE_CHECKING``. |
| 688 |
|
| 689 |
Closes #7524 (`#7524 <https://github.com/pylint-dev/pylint/issues/7524>`_) |
| 690 |
|
| 691 |
- Fixed a crash of the ``modified_iterating`` checker when iterating on a set |
| 692 |
defined as a class attribute. |
| 693 |
|
| 694 |
Closes #7528 (`#7528 <https://github.com/pylint-dev/pylint/issues/7528>`_) |
| 695 |
|
| 696 |
- Use ``py-version`` to determine if a message should be emitted for messages |
| 697 |
defined with ``max-version`` or ``min-version``. |
| 698 |
|
| 699 |
Closes #7569 (`#7569 <https://github.com/pylint-dev/pylint/issues/7569>`_) |
| 700 |
|
| 701 |
- Improve ``bad-thread-instantiation`` check to warn if ``target`` is not |
| 702 |
passed in as a keyword argument |
| 703 |
or as a second argument. |
| 704 |
|
| 705 |
Closes #7570 (`#7570 <https://github.com/pylint-dev/pylint/issues/7570>`_) |
| 706 |
|
| 707 |
- Fixes edge case of custom method named ``next`` raised an astroid error. |
| 708 |
|
| 709 |
Closes #7610 (`#7610 <https://github.com/pylint-dev/pylint/issues/7610>`_) |
| 710 |
|
| 711 |
- Fixed a multi-processing crash that prevents using any more than 1 thread on |
| 712 |
MacOS. |
| 713 |
|
| 714 |
The returned module objects and errors that were cached by the linter plugin |
| 715 |
loader |
| 716 |
cannot be reliably pickled. This means that ``dill`` would throw an error |
| 717 |
when |
| 718 |
attempting to serialise the linter object for multi-processing use. |
| 719 |
|
| 720 |
Closes #7635. (`#7635 <https://github.com/pylint-dev/pylint/issues/7635>`_) |
| 721 |
|
| 722 |
- Fix crash that happened when parsing files with unexpected encoding starting |
| 723 |
with 'utf' like ``utf13``. |
| 724 |
|
| 725 |
Closes #7661 (`#7661 <https://github.com/pylint-dev/pylint/issues/7661>`_) |
| 726 |
|
| 727 |
- Fix a crash when a child class with an ``__init__`` method inherits from a |
| 728 |
parent class with an ``__init__`` class attribute. |
| 729 |
|
| 730 |
Closes #7742 (`#7742 <https://github.com/pylint-dev/pylint/issues/7742>`_) |
| 731 |
|
| 732 |
- Fix ``valid-metaclass-classmethod-first-arg`` default config value from "cls" |
| 733 |
to "mcs" |
| 734 |
which would cause both a false-positive and false-negative. |
| 735 |
|
| 736 |
Closes #7782 (`#7782 <https://github.com/pylint-dev/pylint/issues/7782>`_) |
| 737 |
|
| 738 |
- Fixes a crash in the ``unnecessary_list_index_lookup`` check when using |
| 739 |
``enumerate`` with ``start`` and a class attribute. |
| 740 |
|
| 741 |
Closes #7821 (`#7821 <https://github.com/pylint-dev/pylint/issues/7821>`_) |
| 742 |
|
| 743 |
- Fixes a crash in ``stop-iteration-return`` when the ``next`` builtin is |
| 744 |
called without arguments. |
| 745 |
|
| 746 |
Closes #7828 (`#7828 <https://github.com/pylint-dev/pylint/issues/7828>`_) |
| 747 |
|
| 748 |
- When pylint exit due to bad arguments being provided the exit code will now |
| 749 |
be the expected ``32``. |
| 750 |
|
| 751 |
Refs #7931 (`#7931 <https://github.com/pylint-dev/pylint/issues/7931>`_) |
| 752 |
|
| 753 |
- Fixes a ``ModuleNotFound`` exception when running pylint on a Django project |
| 754 |
with the ``pylint_django`` plugin enabled. |
| 755 |
|
| 756 |
Closes #7938 (`#7938 <https://github.com/pylint-dev/pylint/issues/7938>`_) |
| 757 |
|
| 758 |
- Fixed a crash when inferring a value and using its qname on a slice that was |
| 759 |
being incorrectly called. |
| 760 |
|
| 761 |
Closes #8067 (`#8067 <https://github.com/pylint-dev/pylint/issues/8067>`_) |
| 762 |
|
| 763 |
- Use better regex to check for private attributes. |
| 764 |
|
| 765 |
Refs #8081 (`#8081 <https://github.com/pylint-dev/pylint/issues/8081>`_) |
| 766 |
|
| 767 |
- Fix issue with new typing Union syntax in runtime context for Python 3.10+. |
| 768 |
|
| 769 |
Closes #8119 (`#8119 <https://github.com/pylint-dev/pylint/issues/8119>`_) |
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
Other Changes |
| 774 |
------------- |
| 775 |
|
| 776 |
- Pylint now provides basic support for Python 3.11. |
| 777 |
|
| 778 |
Closes #5920 (`#5920 <https://github.com/pylint-dev/pylint/issues/5920>`_) |
| 779 |
|
| 780 |
- Update message for ``abstract-method`` to include child class name. |
| 781 |
|
| 782 |
Closes #7124 (`#7124 <https://github.com/pylint-dev/pylint/issues/7124>`_) |
| 783 |
|
| 784 |
- Update Pyreverse's dot and plantuml printers to detect when class methods are |
| 785 |
abstract and show them with italic font. |
| 786 |
For the dot printer update the label to use html-like syntax. |
| 787 |
|
| 788 |
Closes #7346 (`#7346 <https://github.com/pylint-dev/pylint/issues/7346>`_) |
| 789 |
|
| 790 |
- The ``docparams`` extension now considers typing in Numpy style docstrings |
| 791 |
as "documentation" for the ``missing-param-doc`` message. |
| 792 |
|
| 793 |
Refs #7398 (`#7398 <https://github.com/pylint-dev/pylint/issues/7398>`_) |
| 794 |
|
| 795 |
- Relevant ``DeprecationWarnings`` are now raised with ``stacklevel=2``, so |
| 796 |
they have the callsite attached in the message. |
| 797 |
|
| 798 |
Closes #7463 (`#7463 <https://github.com/pylint-dev/pylint/issues/7463>`_) |
| 799 |
|
| 800 |
- Add a ``minimal`` option to ``pylint-config`` and its toml generator. |
| 801 |
|
| 802 |
Closes #7485 (`#7485 <https://github.com/pylint-dev/pylint/issues/7485>`_) |
| 803 |
|
| 804 |
- Add method name to the error messages of ``no-method-argument`` and |
| 805 |
``no-self-argument``. |
| 806 |
|
| 807 |
Closes #7507 (`#7507 <https://github.com/pylint-dev/pylint/issues/7507>`_) |
| 808 |
|
| 809 |
- Prevent leaving the pip install cache in the Docker image. |
| 810 |
|
| 811 |
Refs #7544 (`#7544 <https://github.com/pylint-dev/pylint/issues/7544>`_) |
| 812 |
|
| 813 |
- Add a keyword-only ``compare_constants`` argument to ``safe_infer``. |
| 814 |
|
| 815 |
Refs #7626 (`#7626 <https://github.com/pylint-dev/pylint/issues/7626>`_) |
| 816 |
|
| 817 |
- Add ``default_enabled`` option to optional message dict. Provides an option |
| 818 |
to disable a checker message by default. |
| 819 |
To use a disabled message, the user must enable it explicitly by adding the |
| 820 |
message to the ``enable`` option. |
| 821 |
|
| 822 |
Refs #7629 (`#7629 <https://github.com/pylint-dev/pylint/issues/7629>`_) |
| 823 |
|
| 824 |
- Sort ``--generated-rcfile`` output. |
| 825 |
|
| 826 |
Refs #7655 (`#7655 <https://github.com/pylint-dev/pylint/issues/7655>`_) |
| 827 |
|
| 828 |
- epylint is now deprecated and will be removed in pylint 3.0.0. All emacs and |
| 829 |
flymake related |
| 830 |
files were removed and their support will now happen in an external |
| 831 |
repository : |
| 832 |
https://github.com/emacsorphanage/pylint. |
| 833 |
|
| 834 |
Closes #7737 (`#7737 <https://github.com/pylint-dev/pylint/issues/7737>`_) |
| 835 |
|
| 836 |
- Adds test for existing preferred-modules configuration functionality. |
| 837 |
|
| 838 |
Refs #7957 (`#7957 <https://github.com/pylint-dev/pylint/issues/7957>`_) |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
Internal Changes |
| 843 |
---------------- |
| 844 |
|
| 845 |
- Add and fix regression tests for plugin loading. |
| 846 |
|
| 847 |
This shores up the tests that cover the loading of custom plugins as affected |
| 848 |
by any changes made to the ``sys.path`` during execution of an ``init-hook``. |
| 849 |
Given the existing contract of allowing plugins to be loaded by fiddling with |
| 850 |
the path in this way, this is now the last bit of work needed to close Github |
| 851 |
issue #7264. |
| 852 |
|
| 853 |
Closes #7264 (`#7264 <https://github.com/pylint-dev/pylint/issues/7264>`_) |