6

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?

jraufeisen
  • 3,005
  • 7
  • 27
  • 43

2 Answers2

11

both of these combinations work for me:

import os  # noqa: F401 # pylint:disable=unused-import
import sys  # pylint:disable=unused-import # noqa: F401
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
0

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
Todd Smith
  • 91
  • 1
  • 6