← Back to team overview

divmod-dev team mailing list archive

[Bug 907742] Re: Add support for ignoring some warnings

 

** Changed in: pocket-lint
       Status: Fix Committed => Fix Released

-- 
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 Released
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