Skip to content

Commit a75c186

Browse files
Merge branch 'main' into f-strings-variable
2 parents 2259aaf + 676f484 commit a75c186

File tree

127 files changed

+2284
-712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2284
-712
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
- --remove-duplicate-keys
2222
- --remove-unused-variables
2323
- repo: https://github.com/asottile/pyupgrade
24-
rev: v2.23.1
24+
rev: v2.23.3
2525
hooks:
2626
- id: pyupgrade
2727
args: [--py36-plus]
@@ -85,7 +85,7 @@ repos:
8585
args: []
8686
require_serial: true
8787
additional_dependencies: ["types-pkg_resources==0.1.3", "types-toml==0.1.3"]
88-
exclude: tests/functional/|tests/input|tests/extensions/data|tests/regrtest_data/|tests/data/|doc/|bin/
88+
exclude: tests/functional/|tests/input|tests(/.*)*/data|tests/regrtest_data/|tests/data/|tests(/.*)+/conftest.py|doc/|bin/
8989
- repo: https://github.com/pre-commit/mirrors-prettier
9090
rev: v2.3.2
9191
hooks:

CONTRIBUTORS.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ contributors:
508508

509509
* Maksym Humetskyi (mhumetskyi): contributor
510510
- Fixed ignored empty functions by similarities checker with "ignore-signatures" option enabled
511+
- Ignore function decorators signatures as well by similarities checker with "ignore-signatures" option enabled
511512

512513
* Daniel Dorani (doranid): contributor
513514

@@ -529,3 +530,7 @@ contributors:
529530
* Daniel van Noord (DanielNoord): contributor
530531

531532
* Michal Vasilek: contributor
533+
534+
* Kai Mueller (kasium): contributor
535+
536+
* Sam Vermeiren (PaaEl): contributor

ChangeLog

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,31 @@ Release date: TBA
1212
..
1313
Put bug fixes that should not wait for a new minor version here
1414

15+
* pyreverse: add option to produce colored output.
16+
17+
Closes #4488
18+
19+
* pyreverse: add output in PlantUML format.
20+
21+
Closes #4498
22+
23+
* ``consider-using-with`` is no longer triggered if a context manager is returned from a function.
24+
25+
Closes #4748
26+
27+
* pylint does not crash with a traceback anymore when a file is problematic. It
28+
creates a template text file for opening an issue on the bug tracker instead.
29+
The linting can go on for other non problematic files instead of being impossible.
30+
1531
* pyreverse: Show class has-a relationships inferred from the type-hint
1632

1733
Closes #4744
1834

35+
* Fixed a crash when importing beyond the top level package during ``import-error``
36+
message creation
37+
38+
Closes #4775
39+
1940
* Added ``ignored-parents`` option to the design checker to ignore specific
2041
classes from the ``too-many-ancestors`` check (R0901).
2142

@@ -48,10 +69,6 @@ Release date: TBA
4869

4970
Closes #4365
5071

51-
* ``CodeStyleChecker``
52-
53-
* Extended ``consider-using-tuple`` check to cover ``in`` comparisons.
54-
5572
* Added ``forgotten-debug-statement``: Emitted when ``breakpoint``, ``pdb.set_trace`` or ``sys.breakpointhook`` calls are found
5673

5774
Closes #3692
@@ -79,6 +96,63 @@ Release date: TBA
7996
Closes #3608
8097
Closes #4346
8198

99+
* Added ``format-string-without-interpolation`` checker: Emitted when formatting is applied to a string without any variables to be replaced
100+
101+
Closes #4042
102+
103+
104+
* Refactor of ``--list-msgs`` & ``--list-msgs-enabled``: both options now show whether messages are emittable with the current interpreter.
105+
106+
Closes #4778
107+
108+
* Fix false negative for ``used-before-assignment`` when the variable is assigned
109+
in an exception handler, but used outside of the handler.
110+
111+
Closes #626
112+
113+
* Added ``disable-next`` option: allows using `# pylint: disable-next=msgid` to disable a message for the following line
114+
115+
Closes #1682
116+
117+
* Added ``redundant-u-string-prefix`` checker: Emitted when the u prefix is added to a string
118+
119+
Closes #4102
120+
121+
* Fixed ``cell-var-from-loop`` checker: handle cell variables in comprehensions within functions,
122+
and function default argument expressions. Also handle basic variable shadowing.
123+
124+
Closes #2846
125+
Closes #3107
126+
127+
* Fixed bug with ``cell-var-from-loop`` checker: it no longer has false negatives when
128+
both ``unused-variable`` and ``used-before-assignment`` are disabled.
129+
130+
* Fix false postive for ``invalid-all-format`` if the list or tuple builtin functions are used
131+
132+
Closes #4711
133+
134+
* Config files can now contain environment variables
135+
136+
Closes #3839
137+
138+
* Fix false-positive ``used-before-assignment`` with an assignment expression in a ``Return`` node
139+
140+
Closes #4828
141+
142+
* Added ``use-sequence-for-iteration``: Emitted when iterating over an in-place defined ``set``.
143+
144+
* ``CodeStyleChecker``
145+
146+
* Limit ``consider-using-tuple`` to be emitted only for in-place defined ``lists``.
147+
148+
* Emit ``consider-using-tuple`` even if list contains a ``starred`` expression.
149+
150+
* Ignore decorators lines by similarities checker when ignore signatures flag enabled
151+
152+
Closes #4839
153+
154+
* Allow ``true`` and ``false`` values in ``pylintrc`` for better compatibility with ``toml`` config.
155+
82156

83157
What's New in Pylint 2.9.6?
84158
===========================

doc/development_guide/contribute.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Please take the time to check if it is already in the issue tracker at
1616
https://github.com/PyCQA/pylint
1717

1818
If you cannot find it in the tracker, create a new issue there or discuss your
19-
problem on the [email protected] mailing list or using the discord server https://discord.gg/kFebW799.
19+
problem on the [email protected] mailing list or using the discord
20+
server https://discord.gg/Egy6P8AMB5.
2021

2122
The code-quality mailing list is also a nice place to provide feedback about
2223
Pylint, since it is shared with other tools that aim at improving the quality of

doc/faq.rst

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ Everything should be explained on :ref:`installation`.
3030
2.2 What kind of versioning system does Pylint use?
3131
---------------------------------------------------
3232

33-
Pylint uses the git distributed version control system. The URL of the
34-
repository is: https://github.com/PyCQA/pylint . To get the latest version of
35-
Pylint from the repository, simply invoke ::
33+
Pylint uses git. To get the latest version of Pylint from the repository, simply invoke ::
3634

3735
git clone https://github.com/PyCQA/pylint
3836

@@ -60,8 +58,7 @@ The supported running environment since Pylint 2.7.X is Python 3.6+.
6058
-----------------------------------------------------------------
6159

6260
Pylint expects the name of a package or module as its argument. As a
63-
convenience,
64-
you can give it a file name if it's possible to guess a module name from
61+
convenience, you can give it a file name if it's possible to guess a module name from
6562
the file's path using the python path. Some examples :
6663

6764
"pylint mymodule.py" should always work since the current working
@@ -73,16 +70,16 @@ or if "directory" is in the python path.
7370

7471
"pylint /whatever/directory/mymodule.py" will work if either:
7572

76-
- "/whatever/directory" is in the python path
73+
- "/whatever/directory" is in the python path
7774

78-
- your cwd is "/whatever/directory"
75+
- your cwd is "/whatever/directory"
7976

80-
- "directory" is a python package and "/whatever" is in the python
77+
- "directory" is a python package and "/whatever" is in the python
8178
path
8279

8380
- "directory" is an implicit namespace package and is in the python path.
8481

85-
- "directory" is a python package and your cwd is "/whatever" and so
82+
- "directory" is a python package and your cwd is "/whatever" and so
8683
on...
8784

8885
3.2 Where is the persistent data stored to compare between successive runs?
@@ -106,13 +103,13 @@ localized using the following rules:
106103
3.3 How do I find the option name (for pylintrc) corresponding to a specific command line option?
107104
--------------------------------------------------------------------------------------------------------
108105

109-
You can always generate a sample pylintrc file with --generate-rcfile
106+
You can generate a sample pylintrc file with --generate-rcfile
110107
Every option present on the command line before this will be included in
111108
the rc file
112109

113110
For example::
114111

115-
pylint --disable=bare-except,invalid-name --class-rgx='[A-Z][a-z]+' --generate-rcfile
112+
pylint --disable=bare-except,invalid-name --class-rgx='[A-Z][a-z]+' --generate-rcfile
116113

117114
3.4 I'd rather not run Pylint from the command line. Can I integrate it with my editor?
118115
---------------------------------------------------------------------------------------
@@ -123,12 +120,24 @@ Much probably. Read :ref:`ide-integration`
123120
4. Message Control
124121
==================
125122

126-
4.1 Is it possible to locally disable a particular message?
123+
4.1 How to disable a particular message?
127124
-----------------------------------------------------------
128125

129-
Yes, this feature has been added in Pylint 0.11. This may be done by
130-
adding "#pylint: disable=some-message,another-one" at the desired block level
131-
or at the end of the desired line of code
126+
For a single line : Add ``#pylint: disable=some-message,another-one`` at the
127+
end of the desired line of code. Since Pylint 2.10 you can also use
128+
``#pylint: disable-next=...`` on the line just above the problem.
129+
``...`` in the following example is a short hand for the list of
130+
messages you want to disable.
131+
132+
For larger disable : You can add ``#pylint: disable=...`` at the block level to
133+
disable for the block. It's possible to enable for the reminder of the block
134+
with ``#pylint: enable=...`` A block is either a scope (say a function, a module),
135+
or a multiline statement (try, finally, if statements, for loops).
136+
`It's currently impossible to disable inside an else block`_
137+
138+
Read :ref:`message-control` for details and examples.
139+
140+
.. _`It's currently impossible to disable inside an else block`: https://github.com/PyCQA/pylint/issues/872
132141

133142
4.2 Is there a way to disable a message for a particular module only?
134143
---------------------------------------------------------------------
@@ -137,25 +146,21 @@ Yes, you can disable or enable (globally disabled) messages at the
137146
module level by adding the corresponding option in a comment at the
138147
top of the file: ::
139148

140-
# pylint: disable=wildcard-import, method-hidden
141-
# pylint: enable=too-many-lines
149+
# pylint: disable=wildcard-import, method-hidden
150+
# pylint: enable=too-many-lines
142151

143152
4.3 How can I tell Pylint to never check a given module?
144153
--------------------------------------------------------
145154

146-
With Pylint < 0.25, add "#pylint: disable-all" at the beginning of the
147-
module. Pylint 0.26.1 and up have renamed that directive to
148-
"#pylint: skip-file" (but the first version will be kept for backward
149-
compatibility).
155+
Add ``#pylint: skip-file`` at the beginning of the module.
150156

151157
In order to ease finding which modules are ignored an Information-level message
152-
`file-ignored` is emitted. With recent versions of Pylint, if you use the old
153-
syntax, an additional `deprecated-disable-all` message is emitted.
158+
`file-ignored` is emitted.
154159

155160
4.4 Do I have to remember all these numbers?
156161
--------------------------------------------
157162

158-
No, starting from 0.25.3, you can use symbolic names for messages::
163+
No, you can use symbolic names for messages::
159164

160165
# pylint: disable=fixme, line-too-long
161166

@@ -191,6 +196,10 @@ for not being included as default messages. But most of the disabled
191196
messages are from the Python 3 porting checker, which is disabled by
192197
default. It needs special activation with the ``--py3k`` flag.
193198

199+
You can see the plugin you need to explicitly `load in the technical reference`_
200+
201+
.. _`load in the technical reference`: http://pylint.pycqa.org/en/latest/technical_reference/extensions.html?highlight=load%20plugin
202+
194203
4.8 I am using another popular linter alongside pylint. Which messages should I disable to avoid duplicates?
195204
------------------------------------------------------------------------------------------------------------
196205

doc/release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ So, you want to release the `X.Y.Z` version of pylint ?
88
pinned to the latest version.
99
2. Install the release dependencies `pip3 install pre-commit tbump`
1010
3. Bump the version by using `tbump X.Y.Z --no-tag --no-push`
11-
4. Check the result
11+
4. Check the result (Do `git diff vX.Y.Z-1 ChangeLog doc/whatsnew/` in particular).
1212
5. Move back to a dev version for pylint with `tbump`:
1313

1414
```bash

doc/tutorial.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ needed a bit more info. We can see the second line is: ::
153153

154154
"simplecaesar.py:1:0: C0114: Missing module docstring (missing-module-docstring)"
155155

156-
This basically means that line 1 violates a convention ``C0114``. It's telling me I really should have a docstring. I agree, but what if I didn't fully understand what rule I violated. Knowing only that I violated a convention
156+
This basically means that line 1 violates a convention ``C0114``. It's telling me I really should have a docstring.
157+
I agree, but what if I didn't fully understand what rule I violated. Knowing only that I violated a convention
157158
isn't much help if I'm a newbie. Another piece of information there is the
158159
message symbol between parens, ``missing-module-docstring`` here.
159160

doc/user_guide/message-control.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ The pragma controls can disable / enable:
3939

4040
a, b = ... # pylint: disable=unbalanced-tuple-unpacking
4141

42+
* All the violations on the following line
43+
44+
.. sourcecode:: python
45+
46+
# pylint: disable-next=unbalanced-tuple-unpacking
47+
a, b = ...
48+
4249
* All the violations in a single scope
4350

4451
.. sourcecode:: python
@@ -179,6 +186,14 @@ Here's an example with all these rules in a single place:
179186
print(self.bla)
180187
print(self.blop)
181188

189+
def meth9(self):
190+
"""test next line disabling"""
191+
# no error
192+
# pylint: disable-next=no-member
193+
print(self.bla)
194+
# error
195+
print(self.blop)
196+
182197

183198
Detecting useless disables
184199
--------------------------

doc/whatsnew/2.10.rst

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,33 @@ New checkers
3232

3333
Closes #2507
3434

35+
* Added ``use-sequence-for-iteration``: Emitted when iterating over an in-place defined ``set``.
36+
37+
3538

3639
Extensions
3740
==========
3841

3942
* ``CodeStyleChecker``
4043

41-
* Extended ``consider-using-tuple`` check to cover ``in`` comparisons.
44+
* Limit ``consider-using-tuple`` to be emitted only for in-place defined ``lists``.
45+
46+
* Emit ``consider-using-tuple`` even if list contains a ``starred`` expression.
4247

4348

4449
Other Changes
4550
=============
4651

52+
* pyreverse now permit to produce colored generated diagram by using the ``colorized`` option.
53+
54+
* Pyreverse - add output in PlantUML format
55+
56+
* ``consider-using-with`` is no longer triggered if a context manager is returned from a function.
57+
58+
* pylint does not crash with a traceback anymore when a file is problematic. It
59+
creates a template text file for opening an issue on the bug tracker instead.
60+
The linting can go on for other non problematic files instead of being impossible.
61+
4762
* Pyreverse - Show class has-a relationships inferred from type-hints
4863

4964
* Performance of the Similarity checker has been improved.
@@ -65,3 +80,33 @@ Other Changes
6580
Closes #3249
6681
Closes #3608
6782
Closes #4346
83+
84+
* Refactor of ``--list-msgs`` & ``--list-msgs-enabled``: both options now show whether messages are emittable with the current interpreter.
85+
86+
Closes #4778
87+
88+
* Fix false negative for ``used-before-assignment`` when the variable is assigned
89+
in an exception handler, but used outside of the handler.
90+
91+
Closes #626
92+
93+
* Added ``disable-next`` option: allows using `# pylint: disable-next=msgid` to disable a message for the following line
94+
95+
Closes #1682
96+
97+
* Added ``format-string-without-interpolation`` checker: Emitted when formatting is applied to a string without any variables to be replaced
98+
99+
Closes #4042
100+
101+
* Added ``redundant-u-string-prefix`` checker: Emitted when the u prefix is added to a string
102+
103+
Closes #4102
104+
105+
* Fixed ``cell-var-from-loop`` checker: handle cell variables in comprehensions within functions,
106+
and function default argument expressions. Also handle basic variable shadowing.
107+
108+
Closes #2846
109+
Closes #3107
110+
111+
* Fixed bug with ``cell-var-from-loop`` checker: it no longer has false negatives when
112+
both ``unused-variable`` and ``used-before-assignment`` are disabled.

0 commit comments

Comments
 (0)