How do I get Pyflakes to ignore a statement?


A lot of our modules start with:

    import json
except ImportError:
    from django.utils import simplejson as json  # Python 2.4 fallback.

...and it"s the only Pyflakes warning in the entire file:

foo/ redefinition of unused "json" from line 12

How can I get Pyflakes to ignore this?

(Normally I"d go read the docs but the link is broken. If nobody has an answer, I"ll just read the source.)

Answer rating: 227

If you can use flake8 instead - which wraps pyflakes as well as the pep8 checker - a line ending with


(in which the space is significant - 2 spaces between the end of the code and the #, one between it and the NOQA text) will tell the checker to ignore any errors on that line.

Get Solution for free from DataCamp guru