Debian Codegraph @

doc/whatsnew/2/2.11/summary.rst

raw
1 :Release: 2.11
2 :Date: 2021-09-16
3
4 Summary -- Release highlights
5 =============================
6
7 In 2.11, we added a new default checker to advise using f-string as it's
8 the most efficient way of formatting strings right now. You can use
9 `pyupgrade`_, `ruff`_ or `flynt`_ to migrate your old ``%`` and ``format()`` automatically.
10
11 We added a new extension ``SetMembershipChecker`` that will advise the
12 use of set for membership test, as it's more performant than lists or tuples.
13 The ``CodeStyleChecker`` also got some love, check it out if you're not already
14 using it.
15
16 We fixed some long standing bugs, false positives, or false negatives and
17 we added small quality of life options like ``min-similarity-lines`` that
18 disable the duplication check when set to 0.
19
20 Under the hood the code for both pylint and astroid is progressively more typed,
21 which could be helpful to you if you're using them as libraries. In order for
22 this new typing to make more sense and stay simple, we deprecated some functions
23 or type that will be removed in the next major version. This is an ongoing effort.
24
25 The future ``possible-forgotten-f-prefix`` check still had too much false positives,
26 and is delayed again. Check the `possible-forgotten-f-prefix`_ issue if you want
27 to provide knowledge or use case :)
28
29 .. _possible-forgotten-f-prefix: https://github.com/pylint-dev/pylint/pull/4787
30 .. _pyupgrade: https://github.com/asottile/pyupgrade
31 .. _flynt: https://github.com/ikamensh/flynt
32 .. _ruff: https://docs.astral.sh/ruff/
33
34 New checkers
35 ============
36
37 * Added ``consider-using-f-string``: Emitted when .format() or '%' is being used to format a string.
38
39 Closes #3592
40
41 Removed checkers
42 ================
43
44 * The python3 porting mode checker and its ``py3k`` option were removed. You can still find it in older pylint
45 versions.
46
47 Extensions
48 ==========
49
50 * Added new extension ``SetMembershipChecker`` with ``use-set-for-membership`` check:
51 Emitted when using an in-place defined ``list`` or ``tuple`` to do a membership test. ``sets`` are better optimized for that.
52
53 Closes #4776
54
55 CodeStyleChecker
56 ----------------
57
58 * Added ``consider-using-assignment-expr``: Emitted when an assignment is directly followed by an if statement
59 and both can be combined by using an assignment expression ``:=``. Requires Python 3.8
60
61 Closes #4862
62
63
64 Other Changes
65 =============
66
67 * Added ``py-version`` config key (if ``[MAIN]`` section). Used for version dependent checks.
68 Will default to whatever Python version pylint is executed with.
69
70 * The ``invalid-name`` message is now more detailed when using multiple naming style regexes.
71
72 * Fix false positive for ``consider-using-with`` if a context manager is assigned to a
73 variable in different paths of control flow (e. g. if-else clause).
74
75 Closes #4751
76
77 * Fix false positive for ``function-redefined`` for simple type annotations
78
79 Closes #4936
80
81 * Fix false positive for ``protected-access`` if a protected member is used in type hints of function definitions
82
83 * Fix false positive ``dict-iter-missing-items`` for dictionaries only using tuples as keys
84
85 Closes #3282
86
87 * The ``unspecified-encoding`` checker now also checks calls to ``pathlib.Path().read_text()``
88 and ``pathlib.Path().write_text()``
89
90 Closes #4945
91
92 * Fix false positive ``superfluous-parens`` for tuples created with inner tuples
93
94 Closes #4907
95
96 * Fix false positive ``unused-private-member`` for accessing attributes in a class using ``cls``
97
98 Closes #4849
99
100 * Extended ``consider-using-in`` check to work for attribute access.
101
102 * Setting ``min-similarity-lines`` to 0 now makes the similarty checker stop checking for duplicate code
103
104 Closes #4901
105
106 * Fix a bug where pylint complained if the cache's parent directory does not exist
107
108 Closes #4900
109
110 * The ``global-variable-not-assigned`` checker now catches global variables that are never reassigned in a
111 local scope and catches (reassigned) functions
112
113 Closes #1375
114 Closes #330
115
116 * The ``consider-iterating-dictionary`` checker now also considers membership checks
117
118 Closes #4069