Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 569
JoRa Avatar asked Jan 25 '26 08:01

JoRa


1 Answers

both of these combinations work for me:

import os  # noqa: F401 # pylint:disable=unused-import
import sys  # pylint:disable=unused-import # noqa: F401
like image 125
Anthony Sottile Avatar answered Jan 26 '26 20:01

Anthony Sottile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!