← Back to team overview

divmod-dev team mailing list archive

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

 

Hi,

Right now, pyflakes messages do not have a ID for each message class. In
pylint each message class has its own ID.

I agree that this all or nothing filter can lead to other troubles. I
will check to see if pyflakes developers would like to accept a patch to
pyflakes to add IDs for each message class, and then we can improve the
current pocketlint filter.

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