summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-08-05 06:59:00 +0200
committerGitHub <noreply@github.com>2021-08-05 06:59:00 +0200
commit7d84a322afb129045b5c82790bad56b7d7f4fbc3 (patch)
treeea159d966f239f763bdae15bdafa16ad15fcdd0f /doc
parent8ea16d4077412f1ce7c4ebee551ff8fc0947f35a (diff)
downloadpylint-git-7d84a322afb129045b5c82790bad56b7d7f4fbc3.tar.gz
Add ``disable-next`` option (#4797)
* Add ``disable-next`` option Adding `# pylint: disable-next=msgid` to your file will disable the message for the next line. This closes #1682 * Add documentation, rorganize the FAQ for disable/enable and add ref to the full doc Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/faq.rst16
-rw-r--r--doc/user_guide/message-control.rst15
-rw-r--r--doc/whatsnew/2.10.rst4
3 files changed, 31 insertions, 4 deletions
diff --git a/doc/faq.rst b/doc/faq.rst
index d679bc286..02e252457 100644
--- a/doc/faq.rst
+++ b/doc/faq.rst
@@ -123,12 +123,20 @@ Much probably. Read :ref:`ide-integration`
4.1 How to disable a particular message?
-----------------------------------------------------------
-Add "#pylint: disable=some-message,another-one" at the desired block level
-or at the end of the desired line of code.
-
-A block is either a scope (say a function, a module), or a multiline statement (Try, Finally, if statements, for loops).
+For a single line : Add ``#pylint: disable=some-message,another-one`` at the
+end of the desired line of code. Since Pylint 2.10 you can also use
+``#pylint: disable-next=...`` on the line just above the problem.
+``...`` in the following example is a short hand for the list of
+messages you want to disable.
+
+For larger disable : You can add ``#pylint: disable=...`` at the block level to
+disable for the block. It's possible to enable for the reminder of the block
+with ``#pylint: enable=...`` A block is either a scope (say a function, a module),
+or a multiline statement (try, finally, if statements, for loops).
`It's currently impossible to disable inside an else block`_
+Read :ref:`message-control` for details and examples.
+
.. _`It's currently impossible to disable inside an else block`: https://github.com/PyCQA/pylint/issues/872
4.2 Is there a way to disable a message for a particular module only?
diff --git a/doc/user_guide/message-control.rst b/doc/user_guide/message-control.rst
index 217b1b556..dafbe2af4 100644
--- a/doc/user_guide/message-control.rst
+++ b/doc/user_guide/message-control.rst
@@ -39,6 +39,13 @@ The pragma controls can disable / enable:
a, b = ... # pylint: disable=unbalanced-tuple-unpacking
+* All the violations on the following line
+
+ .. sourcecode:: python
+
+ # pylint: disable-next=unbalanced-tuple-unpacking
+ a, b = ...
+
* All the violations in a single scope
.. sourcecode:: python
@@ -179,6 +186,14 @@ Here's an example with all these rules in a single place:
print(self.bla)
print(self.blop)
+ def meth9(self):
+ """test next line disabling"""
+ # no error
+ # pylint: disable-next=no-member
+ print(self.bla)
+ # error
+ print(self.blop)
+
Detecting useless disables
--------------------------
diff --git a/doc/whatsnew/2.10.rst b/doc/whatsnew/2.10.rst
index de209d5d2..6622c20fa 100644
--- a/doc/whatsnew/2.10.rst
+++ b/doc/whatsnew/2.10.rst
@@ -71,6 +71,10 @@ Other Changes
Closes #626
+* Add ``disable-next`` option: allows using `# pylint: disable-next=msgid` to disable a message for the following line
+
+ Closes #1682
+
* Added ``format-string-without-interpolation`` checker: Emitted when formatting is applied to a string without any variables to be replaced
Closes #4042