Skip to content

Python · maintainability

no-file-level-escape-hatch-noqa

python:no-file-level-escape-hatch-noqa

File-level Ruff noqa suppresses an escape-hatch rule across the entire file.

Code
SARJ054
Default
error
Fix
none
Languages
python

Why

A file-wide suppression silently authorizes future uses that were never reviewed.

Fix

Suppress each intentional use inline with the exact code and a reason.

Before / after

Executed by this rule’s unit tests.

Before

File suppresses every banned API use

app/service.py · focus
# ruff: noqa: TID251
import os

After

One use is suppressed with a reason

app/service.py · focus
from unittest import mock  # noqa: TID251 — vendor SDK boundary

Limits

  • Detection covers file-level Ruff noqa directives naming configured escape-hatch codes.
  • Inline noqa comments and file-level suppressions for mechanical rules are excluded.