-1

In VSCode flake8 ignore _ unused error just like this

try:
   pass
except Exception as _:
   pass

then flake8 show a error '_' unused

admin
  • 169
  • 1
  • 6

1 Answers1

-2
  1. delete /Lib/site-packages/flake8/__pycache__ floder
  2. edit /Lib/site-packages/flake8/plugins/pyflakes.py run function
  3. reopen your py file, edit it and save
    • before modification
    def run(self):
        """Run the plugin."""
        for message in self.messages:
            col = getattr(message, "col", 0)
            yield (
                message.lineno,
                col,
                "{} {}".format(
                    FLAKE8_PYFLAKES_CODES.get(type(message).__name__, "F999"),
                    message.message % message.message_args,
                ),
                message.__class__,
            )

  • after modification
    def run(self):
        """Run the plugin."""
        for message in self.messages:
            col = getattr(message, "col", 0)
            if ('F841' in FLAKE8_PYFLAKES_CODES.get(
                    type(message).__name__, "F999")
                    and "'_'" in message.message_args):
                yield (
                    message.lineno,
                    col,
                    "{} {}".format(
                        FLAKE8_PYFLAKES_CODES.get(
                            type(message).__name__, "F999"),
                        message.message % message.message_args,
                    ),
                    message.__class__,
                )

admin
  • 169
  • 1
  • 6