| 1 |
:Release: 2.14 |
| 2 |
:Date: 2022-06-01 |
| 3 |
|
| 4 |
Summary -- Release highlights |
| 5 |
============================= |
| 6 |
|
| 7 |
With 2.14 ``pylint`` only supports Python version 3.7.2 and above. |
| 8 |
|
| 9 |
We introduced several new checks among which ``duplicate-value`` for sets, |
| 10 |
``comparison-of-constants``, and checks related to lambdas. We removed ``no-init`` and |
| 11 |
made ``no-self-use`` optional as they were too opinionated. We also added an option |
| 12 |
to generate a toml configuration: ``--generate-toml-config``. |
| 13 |
|
| 14 |
We migrated to ``argparse`` from ``optparse`` and refactored the configuration handling |
| 15 |
thanks to Daniƫl van Noord. On the user side it should change the output of the |
| 16 |
``--help`` command, and some inconsistencies and bugs should disappear. The behavior |
| 17 |
between options set in a config file versus on the command line will be more consistent. For us, |
| 18 |
it will permit to maintain this part of the code easily in the future. |
| 19 |
|
| 20 |
As a result of the refactor there are a lot of internal deprecations. If you're a library |
| 21 |
maintainer that depends on pylint, please verify that you're ready for pylint 3.0 |
| 22 |
by activating deprecation warnings. |
| 23 |
|
| 24 |
We continued the integration of ``pylint-error`` and are now at 33%!. We still welcome any community effort |
| 25 |
to help review, integrate, and add good/bad examples <https://github.com/pylint-dev/pylint/issues/5953>`_. This should be doable |
| 26 |
without any ``pylint`` or ``astroid`` knowledge, so this is the perfect entrypoint if you want |
| 27 |
to contribute to ``pylint`` or open source without any experience with our code! |
| 28 |
|
| 29 |
New checkers |
| 30 |
============ |
| 31 |
|
| 32 |
* Added new checker ``comparison-of-constants``. |
| 33 |
|
| 34 |
Closes #6076 |
| 35 |
|
| 36 |
* Added new checker ``typevar-name-mismatch``: TypeVar must be assigned to a variable with the same name as its name argument. |
| 37 |
|
| 38 |
Closes #5224 |
| 39 |
|
| 40 |
* ``invalid-enum-extension``: Used when a class tries to extend an inherited Enum class. |
| 41 |
|
| 42 |
Closes #5501 |
| 43 |
|
| 44 |
* Added new checker ``typevar-double-variance``: The "covariant" and "contravariant" keyword arguments |
| 45 |
cannot both be set to "True" in a TypeVar. |
| 46 |
|
| 47 |
Closes #5895 |
| 48 |
|
| 49 |
* Add new check ``unnecessary-dunder-call`` for unnecessary dunder method calls. |
| 50 |
|
| 51 |
Closes #5936 |
| 52 |
|
| 53 |
* ``unnecessary-lambda-assignment``: Lambda expression assigned to a variable. |
| 54 |
Define a function using the "def" keyword instead. |
| 55 |
``unnecessary-direct-lambda-call``: Lambda expression called directly. |
| 56 |
Execute the expression inline instead. |
| 57 |
|
| 58 |
Closes #5976 |
| 59 |
|
| 60 |
* ``potential-index-error``: Emitted when the index of a list or tuple exceeds its length. |
| 61 |
This checker is currently quite conservative to avoid false positives. We welcome |
| 62 |
suggestions for improvements. |
| 63 |
|
| 64 |
Closes #578 |
| 65 |
|
| 66 |
* Added new checker ``unnecessary-list-index-lookup`` for indexing into a list while |
| 67 |
iterating over ``enumerate()``. |
| 68 |
|
| 69 |
Closes #4525 |
| 70 |
|
| 71 |
* Added new message called ``duplicate-value`` which identifies duplicate values inside sets. |
| 72 |
|
| 73 |
Closes #5880 |
| 74 |
|
| 75 |
* Added the ``super-without-brackets`` checker, raised when a super call is missing its brackets. |
| 76 |
|
| 77 |
Closes #4008 |
| 78 |
|
| 79 |
Removed checkers |
| 80 |
================ |
| 81 |
|
| 82 |
* The ``no-init`` (W0232) warning has been removed. It's ok to not have an ``__init__`` in a class. |
| 83 |
|
| 84 |
Closes #2409 |
| 85 |
|
| 86 |
* Removed the ``assign-to-new-keyword`` message as there are no new keywords in the supported Python |
| 87 |
versions any longer. |
| 88 |
|
| 89 |
Closes #4683 |
| 90 |
|
| 91 |
* Moved ``no-self-use`` check to optional extension. |
| 92 |
You now need to explicitly enable this check using |
| 93 |
``load-plugins=pylint.extensions.no_self_use``. |
| 94 |
|
| 95 |
Closes #5502 |
| 96 |
|
| 97 |
|
| 98 |
Extensions |
| 99 |
========== |
| 100 |
|
| 101 |
* ``RedefinedLoopNameChecker`` |
| 102 |
|
| 103 |
* Added optional extension ``redefined-loop-name`` to emit messages when a loop variable |
| 104 |
is redefined in the loop body. |
| 105 |
|
| 106 |
Closes #5072 |
| 107 |
|
| 108 |
* ``DocStringStyleChecker`` |
| 109 |
|
| 110 |
* Re-enable checker ``bad-docstring-quotes`` for Python <= 3.7. |
| 111 |
|
| 112 |
Closes #6087 |
| 113 |
|
| 114 |
* ``NoSelfUseChecker`` |
| 115 |
|
| 116 |
* Added ``no-self-use`` check, previously enabled by default. |
| 117 |
|
| 118 |
Closes #5502 |
| 119 |
|
| 120 |
|
| 121 |
Other Changes |
| 122 |
============= |
| 123 |
|
| 124 |
* Started ignoring underscore as a local variable for ``too-many-locals``. |
| 125 |
|
| 126 |
Closes #6488 |
| 127 |
|
| 128 |
* Pylint can now be installed with an extra-require called ``spelling`` (``pip install pylint[spelling]``). |
| 129 |
This will add ``pyenchant`` to pylint's dependencies. You will still need to install the |
| 130 |
requirements for ``pyenchant`` (the ``enchant`` library and any dictionaries) yourself. You will also |
| 131 |
need to set the ``spelling-dict`` option. |
| 132 |
|
| 133 |
Refs #6462 |
| 134 |
|
| 135 |
* Improved wording of the message of ``deprecated-module`` |
| 136 |
|
| 137 |
Closes #6169 |
| 138 |
|
| 139 |
* ``Pylint`` now requires Python 3.7.2 or newer to run. |
| 140 |
|
| 141 |
Closes #4301 |
| 142 |
|
| 143 |
* We made a greater effort to reraise failures stemming from the ``astroid`` |
| 144 |
library as ``AstroidError``, with the effect that pylint emits ``astroid-error`` |
| 145 |
rather than merely ``fatal``. Regardless, please report any such issues you encounter! |
| 146 |
|
| 147 |
* We have improved our recognition of inline disable and enable comments. It is |
| 148 |
now possible to disable ``bad-option-value`` inline (as long as you disable it before |
| 149 |
the bad option value is raised, i.e. ``disable=bad-option-value,bad-message`` not ``disable=bad-message,bad-option-value`` ) as well as certain other |
| 150 |
previously unsupported messages. |
| 151 |
|
| 152 |
Closes #3312 |
| 153 |
|
| 154 |
* The main checker name is now ``main`` instead of ``master``. The configuration does not need to be updated as sections' name are optional. |
| 155 |
|
| 156 |
Closes #5467 |
| 157 |
|
| 158 |
* Update ``invalid-slots-object`` message to show bad object rather than its inferred value. |
| 159 |
|
| 160 |
Closes #6101 |
| 161 |
|
| 162 |
* Fixed a crash in the ``not-an-iterable`` checker involving multiple starred expressions |
| 163 |
inside a call. |
| 164 |
|
| 165 |
Closes #6372 |
| 166 |
|
| 167 |
* Fixed a crash in the ``unused-private-member`` checker involving chained private attributes. |
| 168 |
|
| 169 |
Closes #6709 |
| 170 |
|
| 171 |
* Disable spellchecking of mypy rule names in ignore directives. |
| 172 |
|
| 173 |
Closes #5929 |
| 174 |
|
| 175 |
* ``implicit-str-concat`` will now be raised on calls like ``open("myfile.txt" "a+b")`` too. |
| 176 |
|
| 177 |
Closes #6441 |
| 178 |
|
| 179 |
* Fix a failure to respect inline disables for ``fixme`` occurring on the last line |
| 180 |
of a module when pylint is launched with ``--enable=fixme``. |
| 181 |
|
| 182 |
* Removed the broken ``generate-man`` option. |
| 183 |
|
| 184 |
Closes #5283 |
| 185 |
Closes #1887 |
| 186 |
|
| 187 |
* Fixed failure to enable ``deprecated-module`` after a ``disable=all`` |
| 188 |
by making ``ImportsChecker`` solely responsible for emitting ``deprecated-module`` instead |
| 189 |
of sharing responsibility with ``StdlibChecker``. (This could have led to double messages.) |
| 190 |
|
| 191 |
* Added the ``generate-toml-config`` option. |
| 192 |
|
| 193 |
Refs #5462 |
| 194 |
|
| 195 |
* ``bad-option-value`` will be emitted whenever a configuration value or command line invocation |
| 196 |
includes an unknown message. |
| 197 |
|
| 198 |
Closes #4324 |
| 199 |
|
| 200 |
* Added the ``unrecognized-option`` message. Raised if we encounter any unrecognized options. |
| 201 |
|
| 202 |
Closes #5259 |
| 203 |
|
| 204 |
* Fix false negative for ``bad-string-format-type`` if the value to be formatted is passed in |
| 205 |
as a variable holding a constant. |
| 206 |
|
| 207 |
* The concept of checker priority has been removed. |
| 208 |
|
| 209 |
* The ``cache-max-size-none`` checker has been renamed to ``method-cache-max-size-none``. |
| 210 |
|
| 211 |
Closes #5670 |
| 212 |
|
| 213 |
* The ``method-cache-max-size-none`` checker will now also check ``functools.cache``. |
| 214 |
|
| 215 |
Closes #5670 |
| 216 |
|
| 217 |
* ``BaseChecker`` classes now require the ``linter`` argument to be passed. |
| 218 |
|
| 219 |
* The ``set_config_directly`` decorator has been removed. |
| 220 |
|
| 221 |
* Don't report ``useless-super-delegation`` for the ``__hash__`` method in classes that also override the ``__eq__`` method. |
| 222 |
|
| 223 |
Closes #3934 |
| 224 |
|
| 225 |
* Fix falsely issuing ``useless-suppression`` on the ``wrong-import-position`` checker. |
| 226 |
|
| 227 |
Closes #5219 |
| 228 |
|
| 229 |
* Fixed false positive ``no-member`` for Enums with self-defined members. |
| 230 |
|
| 231 |
Closes #5138 |
| 232 |
|
| 233 |
* Fix false negative for ``no-member`` when attempting to assign an instance |
| 234 |
attribute to itself without any prior assignment. |
| 235 |
|
| 236 |
Closes #1555 |
| 237 |
|
| 238 |
* Changed message type from ``redefined-outer-name`` to ``redefined-loop-name`` |
| 239 |
(optional extension) for redefinitions of outer loop variables by inner loops. |
| 240 |
|
| 241 |
Closes #5608 |
| 242 |
|
| 243 |
* By default the similarity checker will now ignore imports and ignore function signatures when computing |
| 244 |
duplication. If you want to keep the previous behaviour set ``ignore-imports`` and ``ignore-signatures`` to ``False``. |
| 245 |
|
| 246 |
* Pylint now expands the user path (i.e. ``~`` to ``home/yusef/``) and expands environment variables (i.e. ``home/$USER/$project`` |
| 247 |
to ``home/yusef/pylint`` for ``USER=yusef`` and ``project=pylint``) for pyreverse's ``output-directory``, |
| 248 |
``import-graph``, ``ext-import-graph``, ``int-import-graph`` options, and the spell checker's ``spelling-private-dict-file`` |
| 249 |
option. |
| 250 |
|
| 251 |
Refs #6493 |
| 252 |
|
| 253 |
* Don't emit ``unsubscriptable-object`` for string annotations. |
| 254 |
Pylint doesn't check if class is only generic in type stubs only. |
| 255 |
|
| 256 |
Closes #4369 and #6523 |
| 257 |
|
| 258 |
* Fix pyreverse crash ``RuntimeError: dictionary changed size during iteration`` |
| 259 |
|
| 260 |
Refs #6612 |
| 261 |
|
| 262 |
* Fix syntax for return type annotations in MermaidJS diagrams produced with ``pyreverse``. |
| 263 |
|
| 264 |
Closes #6467 |
| 265 |
|
| 266 |
* Fix type annotations of class and instance attributes using the alternative union syntax in ``pyreverse`` diagrams. |
| 267 |
|
| 268 |
* Fix bug where it writes a plain text error message to stdout, invalidating output formats. |
| 269 |
|
| 270 |
Closes #6597 |
| 271 |
|
| 272 |
* The refactoring checker now also raises 'consider-using-a-generator' messages for |
| 273 |
``max()``, ``min()`` and ``sum()``. |
| 274 |
|
| 275 |
Refs #6595 |
| 276 |
|
| 277 |
* Update ranges for ``using-constant-test`` and ``missing-parentheses-for-call-in-test`` |
| 278 |
error messages. |
| 279 |
|
| 280 |
* Don't emit ``no-member`` inside type annotations with |
| 281 |
``from __future__ import annotations``. |
| 282 |
|
| 283 |
Closes #6594 |
| 284 |
|
| 285 |
* Fix ``unexpected-special-method-signature`` false positive for ``__init_subclass__`` methods with one or more arguments. |
| 286 |
|
| 287 |
Closes #6644 |
| 288 |
|
| 289 |
|
| 290 |
Deprecations |
| 291 |
============ |
| 292 |
|
| 293 |
* The ``ignore-mixin-members`` option has been deprecated. You should now use the new |
| 294 |
``ignored-checks-for-mixins`` option. |
| 295 |
|
| 296 |
Closes #5205 |
| 297 |
|
| 298 |
* ``interfaces.implements`` has been deprecated and will be removed in 3.0. Please use standard inheritance |
| 299 |
patterns instead of ``__implements__``. |
| 300 |
|
| 301 |
Refs #2287 |
| 302 |
|
| 303 |
* All ``Interface`` classes in ``pylint.interfaces`` have been deprecated. You can subclass |
| 304 |
the respective normal classes to get the same behaviour. The ``__implements__`` functionality |
| 305 |
was based on a rejected PEP from 2001: |
| 306 |
https://peps.python.org/pep-0245/ |
| 307 |
|
| 308 |
Closes #2287 |
| 309 |
|
| 310 |
* ``MapReduceMixin`` has been deprecated. ``BaseChecker`` now implements ``get_map_data`` and |
| 311 |
``reduce_map_data``. If a checker actually needs to reduce data it should define ``get_map_data`` |
| 312 |
as returning something different than ``None`` and let its ``reduce_map_data`` handle a list |
| 313 |
of the types returned by ``get_map_data``. |
| 314 |
An example can be seen by looking at ``pylint/checkers/similar.py``. |
| 315 |
|
| 316 |
|
| 317 |
* The ``config`` attribute of ``BaseChecker`` has been deprecated. You can use ``checker.linter.config`` |
| 318 |
to access the global configuration object instead of a checker-specific object. |
| 319 |
|
| 320 |
Refs #5392 |
| 321 |
|
| 322 |
* The ``level`` attribute of ``BaseChecker`` has been deprecated: everything is now |
| 323 |
displayed in ``--help``, all the time. |
| 324 |
|
| 325 |
Refs #5392 |
| 326 |
|
| 327 |
* The ``set_option`` method of ``BaseChecker`` has been deprecated. You can use ``checker.linter.set_option`` |
| 328 |
to set an option on the global configuration object instead of a checker-specific object. |
| 329 |
|
| 330 |
Refs #5392 |
| 331 |
|
| 332 |
* The ``options_providers`` attribute of ``ArgumentsManager`` has been deprecated. |
| 333 |
|
| 334 |
Refs #5392 |
| 335 |
|
| 336 |
* Fix saving of persistent data files in environments where the user's cache |
| 337 |
directory and the linted file are on a different drive. |
| 338 |
|
| 339 |
Closes #6394 |
| 340 |
|
| 341 |
* The ``method-cache-max-size-none`` checker will now also check ``functools.cache``. |
| 342 |
|
| 343 |
* The ``config`` attribute of ``PyLinter`` is now of the ``argparse.Namespace`` type instead of |
| 344 |
``optparse.Values``. |
| 345 |
|
| 346 |
Refs #5392 |
| 347 |
|
| 348 |
* ``UnsupportedAction`` has been deprecated. |
| 349 |
|
| 350 |
Refs #5392 |
| 351 |
|
| 352 |
* ``OptionsManagerMixIn`` has been deprecated. |
| 353 |
|
| 354 |
Refs #5392 |
| 355 |
|
| 356 |
* ``OptionParser`` has been deprecated. |
| 357 |
|
| 358 |
Refs #5392 |
| 359 |
|
| 360 |
* ``Option`` has been deprecated. |
| 361 |
|
| 362 |
Refs #5392 |
| 363 |
|
| 364 |
* ``OptionsProviderMixIn`` has been deprecated. |
| 365 |
|
| 366 |
Refs #5392 |
| 367 |
|
| 368 |
* ``ConfigurationMixIn`` has been deprecated. |
| 369 |
|
| 370 |
* The ``option_groups`` attribute of ``PyLinter`` has been deprecated. |
| 371 |
|
| 372 |
Refs #5392 |
| 373 |
|
| 374 |
* ``get_global_config`` has been deprecated. You can now access all global options from |
| 375 |
``checker.linter.config``. |
| 376 |
|
| 377 |
Refs #5392 |
| 378 |
|
| 379 |
* ``OptionsManagerMixIn`` has been replaced with ``ArgumentsManager``. ``ArgumentsManager`` is considered |
| 380 |
private API and most methods that were public on ``OptionsManagerMixIn`` have now been deprecated and will |
| 381 |
be removed in a future release. |
| 382 |
|
| 383 |
Refs #5392 |
| 384 |
|
| 385 |
* ``OptionsProviderMixIn`` has been replaced with ``ArgumentsProvider``. ``ArgumentsProvider`` is considered |
| 386 |
private API and most methods that were public on ``OptionsProviderMixIn`` have now been deprecated and will |
| 387 |
be removed in a future release. |
| 388 |
|
| 389 |
Refs #5392 |
| 390 |
|
| 391 |
* ``pylint.pyreverse.ASTWalker`` has been removed, as it was only used internally by a single child class. |
| 392 |
|
| 393 |
Refs #6712 |
| 394 |
|
| 395 |
* ``pyreverse``: Resolving and displaying implemented interfaces that are defined by the ``__implements__`` |
| 396 |
attribute has been deprecated and will be removed in 3.0. |
| 397 |
|
| 398 |
Refs #6713 |
| 399 |
|
| 400 |
* ``is_class_subscriptable_pep585_with_postponed_evaluation_enabled`` has been deprecated. |
| 401 |
Use ``is_postponed_evaluation_enabled(node) and is_node_in_type_annotation_context(node)`` |
| 402 |
instead. |
| 403 |
|
| 404 |
Refs #6536 |