From 7d84a322afb129045b5c82790bad56b7d7f4fbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 5 Aug 2021 06:59:00 +0200 Subject: 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 --- doc/faq.rst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'doc/faq.rst') 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? -- cgit v1.2.1