divmod-dev team mailing list archive
-
divmod-dev team
-
Mailing list archive
-
Message #00259
[Bug 907742] Re: Add support for ignoring some warnings
@sinzui: Can you link to the changeset? I am curious to see *how* this
was implemented. Sorry if the link is already available somewhere, but I
could noit find it :\
I would really like this feature as well, but more fine-grained as
proposed. For example, pylint allows you to disable a specific error-
code (see http://www.logilab.org/card/pylint_manual#messages-control).
Or, the Java @SuppressWarnings annotation also allows you to ignore
specific warnings.
I find the proposed solution to simply ignore pyflakes altogether is a
bit like a "except Exception": You might miss other errors ;)
--
You received this bug notification because you are a member of Divmod-
dev, which is the registrant for Pyflakes.
https://bugs.launchpad.net/bugs/907742
Title:
Add support for ignoring some warnings
Status in Pocket-Lint:
Fix Committed
Status in Pyflakes:
New
Bug description:
It would be nice if pyflakes would provide an option for ignoring some
warnings.
For example I have this code:
try:
from setproctitle import setproctitle
except ImportError:
setproctitle = lambda t: None # pyflakes:ignore
And pyflakes will complain that setproctitle is redefined.
Maybe this is a bad code and this kind of things should be never ignored, but I just want to know if such a feature is wanted in pyflakes.
Here is a workaround for implementing pyflakes:ignore
class PocketLintPyFlakesChecker(PyFlakesChecker):
'''PocketLint checker for pyflakes.
This is here to work around some of the pyflakes problems.
Beside the AST tree, it is also initialized with the plain text content
of the file.
'''
def __init__(self, tree, filename='(none)', text=None):
self.text = text
if self.text:
self.text = self.text.split('\n')
super(PocketLintPyFlakesChecker, self).__init__(
tree=tree, filename=filename)
def report(self, messageClass, *args, **kwargs):
text_lineno = args[0] - 1
if self.text[text_lineno].find('pyflakes:ignore') >= 0:
return
self.messages.append(messageClass(self.filename, *args, **kwargs))
To manage notifications about this bug go to:
https://bugs.launchpad.net/pocket-lint/+bug/907742/+subscriptions
References