How to suppress a warning in one line for pylint and Flake8 at the same time

Question:

I would like to ignore a specific line in static code analysis.

For Flake8, I’d use the syntax # noqa: F401.

For pylint, I’d use the syntax # pylint: disable=unused-import.

As I am working on a code generation framework, I would like the code to support both linters.
Is there a way to combine both directives such that both of them are correctly detected?

Asked By: jraufeisen

||

Answers:

both of these combinations work for me:

import os  # noqa: F401 # pylint_disable=unused-import
import sys  # pylint_disable=unused-import # noqa: F401
Answered By: anthony sottile

I was having similar issue. Having used pylint initially, I had that directive first which caused errors. Reversing the order so that flake8 is first worked for me.

# noqa: 501  pylint: disable=unused-argument
Answered By: Todd Smith
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.