Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

A lot of our modules start with:

try:
    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/bar.py:14: 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.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

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

# NOQA

(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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...