summaryrefslogtreecommitdiff
path: root/doc/whatsnew/2/2.11/summary.rst
blob: 39851b0e85fc2e00e27c6acb568de1a926fe5016 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
:Release: 2.11
:Date: 2021-09-16

Summary -- Release highlights
=============================

In 2.11, we added a new default checker to advise using f-string as it's
the most efficient way of formatting strings right now. You can use
`pyupgrade`_ or `flynt`_ to migrate your old ``%`` and ``format()`` automatically.

We added a new extension ``SetMembershipChecker`` that will advise the
use of set for membership test, as it's more performant than lists or tuples.
The ``CodeStyleChecker`` also got some love, check it out if you're not already
using it.

We fixed some long standing bugs, false positives, or false negatives and
we added small quality of life options like ``min-similarity-lines`` that
disable the duplication check when set to 0.

Under the hood the code for both pylint and astroid is progressively more typed,
which could be helpful to you if you're using them as libraries. In order for
this new typing to make more sense and stay simple, we deprecated some functions
or type that will be removed in the next major version. This is an ongoing effort.

The future ``possible-forgotten-f-prefix`` check still had too much false positives,
and is delayed again. Check the `possible-forgotten-f-prefix`_ issue if you want
to provide knowledge or use case :)

.. _possible-forgotten-f-prefix: https://github.com/PyCQA/pylint/pull/4787
.. _pyupgrade: https://github.com/asottile/pyupgrade
.. _flynt: https://github.com/ikamensh/flynt


New checkers
============

* Added ``consider-using-f-string``: Emitted when .format() or '%' is being used to format a string.

  Closes #3592

Removed checkers
================

* The python3 porting mode checker and it's ``py3k`` option were removed. You can still find it in older pylint
  versions.

Extensions
==========

* Added new extension ``SetMembershipChecker`` with ``use-set-for-membership`` check:
  Emitted when using an in-place defined ``list`` or ``tuple`` to do a membership test. ``sets`` are better optimized for that.

  Closes #4776

CodeStyleChecker
----------------

* Added ``consider-using-assignment-expr``: Emitted when an assignment is directly followed by an if statement
  and both can be combined by using an assignment expression ``:=``. Requires Python 3.8

  Closes #4862


Other Changes
=============

* Added ``py-version`` config key (if ``[MAIN]`` section). Used for version dependent checks.
  Will default to whatever Python version pylint is executed with.

* The ``invalid-name`` message is now more detailed when using multiple naming style regexes.

* Fix false positive for ``consider-using-with`` if a context manager is assigned to a
  variable in different paths of control flow (e. g. if-else clause).

  Closes #4751

* Fix false positive for ``function-redefined`` for simple type annotations

  Closes #4936

* Fix false positive for ``protected-access`` if a protected member is used in type hints of function definitions

* Fix false positive ``dict-iter-missing-items`` for dictionaries only using tuples as keys

  Closes #3282

* The ``unspecified-encoding`` checker now also checks calls to ``pathlib.Path().read_text()``
  and ``pathlib.Path().write_text()``

  Closes #4945

* Fix false positive ``superfluous-parens`` for tuples created with inner tuples

  Closes #4907

* Fix false positive ``unused-private-member`` for accessing attributes in a class using ``cls``

  Closes #4849

* Extended ``consider-using-in`` check to work for attribute access.

* Setting ``min-similarity-lines`` to 0 now makes the similarty checker stop checking for duplicate code

  Closes #4901

* Fix a bug where pylint complained if the cache's parent directory does not exist

  Closes #4900

* The ``global-variable-not-assigned`` checker now catches global variables that are never reassigned in a
  local scope and catches (reassigned) functions

  Closes #1375
  Closes #330

* The ``consider-iterating-dictionary`` checker now also considers membership checks

  Closes #4069