Debian Codegraph @

doc/whatsnew/2/2.12/summary.rst

raw
1 :Release: 2.12
2 :Date: 2021-11-24
3
4 Summary -- Release highlights
5 =============================
6
7 In 2.12, we introduced a new option ``py-version`` that permits to analyse code for a python
8 version that may differ from your current python interpreter. This does not affect all checkers but
9 permits, for example, to check for python 3.5 code smells (using f-string's) while using pylint with python 3.6.
10 The minimum version to run pylint is now 3.6.2, while the last working version for python 3.6.0
11 and 3.6.1 was pylint 2.9.3.
12
13 On top of fixing a lot of false positives and bugs, we also added new default checks, like
14 ``use-implicit-booleaness-not-comparison``, ``overridden-final-method``, and ``useless-with-lock``.
15 There's also better check for TOML configurations.
16
17 Lastly, in addition to the information we already had about start line and start column,
18 we introduced new information about the end line and end column of messages. This
19 will permit to have more precise visual clue in IDE like in pylint for vs-code. The default
20 will stay the same to not break compatibility but it can be retrieved by adding ``end_line``
21 and ``end_column`` to the ``--msg-template`` option. For better result stick to python 3.8+.
22
23 The checker for Yoda conditions is now an extension, you might want to enable it if you were
24 relying on this check. There's also a new extension checker, ``consider-using-any-or-all`` that
25 detects for loops that could be replaced by any or all, entirely contributed by @areveny,
26 welcome to the team !
27
28 New checkers
29 ============
30
31 * Added ``missing-any-param-doc`` triggered when a function has neither parameter nor parameter type
32 documentation. Undocumented parameters are now being properly identified. A warning might start to
33 appear unexpectedly if ``missing-param-doc`` and ``missing-type-doc`` were disabled, as a new message
34 ``missing-any-param-doc`` will be emitted instead.
35
36 Closes #3799
37
38 typing.final
39 ------------
40
41 * Added ``overridden-final-method``: Emitted when a method which is annotated with ``typing.final`` is overridden
42
43 * Added ``subclassed-final-class``: Emitted when a class which is annotated with ``typing.final`` is subclassed
44
45 Closes #3197
46
47 * Created new ``UnsupportedVersionChecker`` checker class that includes checks for features
48 not supported by all versions indicated by a ``py-version``.
49
50 * Added ``using-f-string-in-unsupported-version`` checker. Issued when ``py-version``
51 is set to a version that does not support f-strings (< 3.6)
52
53 * Added new checker ``use-implicit-booleaness-not-comparison``: Emitted when
54 collection literal comparison is being used to check for emptiness.
55
56 Closes #4774
57
58 * Added ``using-final-decorator-in-unsupported-version`` checker. Issued when ``py-version``
59 is set to a version that does not support typing.final (< 3.8)
60
61 * Added new checker ``useless-with-lock`` to find incorrect usage of with statement and threading module locks.
62 Emitted when ``with threading.Lock():`` is used instead of ``with lock_instance:``.
63
64 Closes #5208
65
66 * A new ``bad-configuration-section`` checker was added that will emit for misplaced option
67 in pylint's top level namespace for toml configuration. Top-level dictionaries or option defined
68 in the wrong section will still silently not be taken into account, which is tracked in a
69 follow-up issue.
70
71 Follow-up in #5259
72
73 * ``MessageTest`` of the unittest ``testutil`` now requires the ``confidence`` attribute
74 to match the expected value. If none is provided it is set to ``UNDEFINED``.
75
76 * ``add_message`` of the unittest ``testutil`` now actually handles the ``col_offset`` parameter
77 and allows it to be checked against actual output in a test.
78
79 Extensions
80 ==========
81
82 * Added an optional extension ``consider-using-any-or-all``: Emitted when a ``for`` loop only
83 produces a boolean and could be replaced by ``any`` or ``all`` using a generator. Also suggests
84 a suitable any/all statement if it is concise.
85
86 Closes #5008
87
88 * Moved ``misplaced-comparison-constant`` to its own extension ``comparison_placement``.
89 This checker was opinionated and now no longer a default. It can be reactived by adding
90 ``pylint.extensions.comparison_placement`` to ``load-plugins`` in your config.
91
92 Closes #1064
93
94 Other Changes
95 =============
96
97 * Fix ``install graphiz`` message which isn't needed for puml output format.
98
99 * ``pylint`` no longer crashes when checking assignment expressions within if-statements
100
101 Closes #5178
102
103 * Added configuration option ``exclude-too-few-public-methods`` to allow excluding
104 classes from the ``min-public-methods`` checker.
105
106 Closes #3370
107
108 * Fix ``accept-no-yields-doc`` and ``accept-no-return-doc`` not allowing missing ``yield`` or
109 ``return`` documentation when a docstring is partially correct
110
111 Closes #5223
112
113 * Fix ``simplify-boolean-expression`` when condition can be inferred as False.
114
115 Closes #5200
116
117 * Fix exception when pyreverse parses ``property function`` of a class.
118
119 * Improve and flatten ``unused-wildcard-import`` message
120
121 Closes #3859
122
123 * In length checker, ``len-as-condition`` has been renamed as
124 ``use-implicit-booleaness-not-len`` in order to be consistent with
125 ``use-implicit-booleaness-not-comparison``.
126
127 * Fixed ``protected-access`` for accessing of attributes and methods of inner classes
128
129 Closes #3066
130
131 * Update ``literal-comparison``` checker to ignore tuple literals
132
133 Closes #3031
134
135 * The functional ``testutils`` now accept ``end_lineno`` and ``end_column``. Expected
136 output files without these will trigger a ``DeprecationWarning``. Expected output files
137 can be easily updated with the ``python tests/test_functional.py --update-functional-output`` command.
138
139 * The functional ``testutils`` now correctly check the distinction between ``HIGH`` and
140 ``UNDEFINED`` confidence. Expected output files without defined ``confidence`` levels will now
141 trigger a ``DeprecationWarning``. Expected output files can be easily updated with the
142 ``python tests/test_functional.py --update-functional-output`` command.
143
144 * The functional test runner now supports the option ``min_pyver_end_position`` to control on which python
145 versions the ``end_lineno`` and ``end_column`` attributes should be checked. The default value is 3.8.
146
147 * ``undefined-variable`` now correctly flags variables which only receive a type annotations
148 and never get assigned a value
149
150 Closes #5140
151
152 * ``undefined-variable`` now correctly considers the line numbering and order of classes
153 used in metaclass declarations
154
155 Closes #4031
156
157 * ``used-before-assignment`` now correctly considers references to classes as type annotation
158 or default values in first-level methods
159
160 Closes #3771
161
162 * ``undefined-variable`` and ``unused-variable`` now correctly trigger for assignment expressions
163 in functions defaults
164
165 Refs #3688
166
167 * ``self-cls-assignment`` now also considers tuple assignment
168
169 * ``undefined-variable`` now correctly triggers for assignment expressions in if ... else statements
170 This includes a basic form of control flow inference for if ... else statements using
171 constant boolean values
172
173 Closes #3688
174
175 * Fix crash for ``unused-private-member`` when checking private members on ``__class__``
176
177 Closes #5261
178
179 * Fix double emitting of ``not-callable`` on inferable ``properties``
180
181 Closes #4426
182
183 * Support configuring mixin class pattern via ``mixin-class-rgx``
184
185 * Normalize the input to the ``ignore-paths`` option to allow both Posix and
186 Windows paths
187
188 Closes #5194
189
190 * ``missing-param-doc`` now correctly parses asterisks for variable length and
191 keyword parameters
192
193 Closes #3733
194
195 * ``missing-param-doc`` now correctly handles Numpy parameter documentation without
196 explicit typing
197
198 Closes #5222
199
200 * The ``--jobs`` parameter now falls back to 1 if the host operating system does not
201 have functioning shared semaphore implementation.
202
203 Closes #5216
204
205 * Crashes when a list is encountered in a toml configuration do not happen anymore.
206
207 Closes #4580
208
209 * Fix crash for ``protected-access`` on (outer) class traversal
210
211 * Fix ``useless-super-delegation`` false positive when default keyword argument is a variable.
212
213 * Make yn validator case insensitive, to allow for ``True`` and ``False`` in config files.
214
215 * The last version compatible with python '3.6.0' and '3.6.1' is pylint '2.9.3'. We did not
216 realize that when adding incompatible typing at the time, and all versions since are broken
217 for this interpreter. 2.12.0 meta-information will permit to download pylint on those
218 interpreters but the installation will fail and tell you to install '2.9.3' instead.
219 pylint 2.12.1 will require python >= 3.6.2.
220
221 Closes #5171
222 Follow-up in #5065
223
224 * Added the ``--enable-all-extensions`` command line option. It will load all available extensions
225 which can be listed by running ``--list-extensions``
226
227 * It is now recommended to do ``pylint`` development on ``Python`` 3.8 or higher. This
228 allows using the latest ``ast`` parser.
229
230 * All standard jobs in the ``pylint`` CI now run on ``Python`` 3.8 by default. We still
231 support python 3.6 and 3.7 and run tests for those interpreters.
232
233 * Fix crash on ``open()`` calls when the ``mode`` argument is not a simple string.
234
235 Fixes part of #5321
236
237 * Add ability to add ``end_line`` and ``end_column`` to the ``--msg-template`` option.
238 With the standard ``TextReporter`` this will add the line and column number of the
239 end of a node to the output of Pylint. If these numbers are unknown, they are represented
240 by an empty string.
241
242 * Introduced primer tests and a configuration tests framework. The helper classes available in
243 ``pylint/testutil/`` are still unstable and might be modified in the near future.
244
245 Closes #4412 #5287
246
247 * Add ``endLine`` and ``endColumn`` keys to output of ``JSONReporter``.
248
249 Closes #5380
250
251 * Fix false negative for ``consider-iterating-dictionary`` during membership checks encapsulated in iterables
252 or ``not in`` checks
253
254 Closes #5323