divmod-dev team mailing list archive
-
divmod-dev team
-
Mailing list archive
-
Message #00262
[Bug 907742] Re: Add support for ignoring some warnings
Adi extended PyFlakesChecker to accept the raw text of the module being checked. The report() method looks of the line number of warning/error and in the text and looks for "# pyflakes:ignore". The report returns early if the comment is present.
https://code.launchpad.net/~adiroiban/pocket-lint/907742/+merge/102882
--
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