Skip to content

ruff:ignore should be processed as a pragma in contains_pragma_comment #5260

Description

@A5rocks

Describe the bug

ruff:ignore is not processed as a pragma.

To Reproduce

For example, take this code:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 5  # ruff:ignore[bweh]

And run it with these arguments:

$ black x.py

The resulting output is:

--- x.py        2026-07-26 00:36:44.849442+00:00
+++ x.py        2026-07-26 00:36:45.724865+00:00
@@ -1 +1,3 @@
-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = 5  # ruff: ignore[bweh]
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = (
+    5  # ruff: ignore[bweh]
+)

Expected behavior

No reformatting (which is what happens if you replace this with type: ignore).

Environment

  • Black's version: 26.5.1
  • OS and Python version: macOS CPython 3.14.2

Additional context

This is probably going to become more popular as ruff has a rule in preview that converts all noqa to ruff:ignore. See https://docs.astral.sh/ruff/rules/noqa-comments/

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions