Skip to content

RUF100 fix removes remaining comment #20762

@adamtheturtle

Description

@adamtheturtle

Summary

I use ruff and pylint.
I used to have to ignore errors for each on the same line, so I added the following ignore:

"""Demonstrate ruff removal of pylint disable."""

import ast


class A(ast.NodeVisitor):
    """Subclass of ast.NodeVisitor."""

    def visit_ImportFrom(  # noqa: N802, pylint: disable=invalid-name
        self,
        node: ast.ImportFrom,
    ) -> None:
        """Override method."""

ruff check --select=ALL ruff_example.py gives:

RUF100 [*] Unused `noqa` directive (unused: `N802`)
  --> ruff_example.py:9:28
   |
 7 |     """Subclass of ast.NodeVisitor."""
 8 |
 9 |     def visit_ImportFrom(  # noqa: N802, pylint: disable=invalid-name
   |                            ^^^^^^^^^^^^
10 |         self,
11 |         node: ast.ImportFrom,
   |
help: Remove unused `noqa` directive

Found 1 error.
[*] 1 fixable with the `--fix` option.

Adding --fix unexpectedly removes the pylint disable part of the comment (meaning that pylint errors).

Version

0.14.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationfixesRelated to suggested fixes for violations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions