`ruff:ignore` should be processed as a pragma in `contains_pragma_comment`
Author: A5rocksCreated Jul 26, 2026Updated Sep 13, 2026
LabelsT: bug
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.pyThe 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/
Source: psf/black