Check that every noqa and type: ignore comment names a code and gives a reason

Aperta
#4,182 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@anth-volk ci sta già lavorando.

Dal 4/11/2026.

  • #4183 di @anth-volk — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
20/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Read docs/engineering/skills/rules-registry.md and step 2.7 of the code-quality plan, then inspect rules/registry.toml and the existing rules under rules/. Build the suppression check around the listed noqa and type: ignore forms, with current violations recorded in a shrinking baseline under rules/baselines/. Done means the ratcheted rule is registered and detects missing codes or reasons; pull request #4183 is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What

Add a quality guard that fails on any inline suppression comment that doesn't name what it suppresses and say why:

  • a noqa comment, line-level or file-level (# ruff: noqa, # flake8: noqa), must list its ruff codes;
  • a type: ignore comment must list its mypy error codes in brackets;
  • each must be followed by a reason, as # noqa: CODE # reason or # type: ignore[code] # reason.

Today's comments without a reason go in a baseline file under rules/baselines/, which can only shrink.

Why

docs/engineering/skills/rules-registry.md already says every suppression gives its reason after the code, and the doc-only rule api.process.agents-suppress-as-last-resort asks agents to suppress only as a last resort. Nothing checks either. Ruff's PGH003 and PGH004 reject a suppression without a code, but nothing rejects one without a reason: 21 noqa comments, one file-level # ruff: noqa: E402 and all 10 type: ignore comments have none today.

This is the suppression check in step 2.7 of the code-quality plan, registered in rules/registry.toml as a ratcheted rule beside api.process.agents-suppress-as-last-resort.

Lingua principale
Python
Stelle
18
Fork
33
Merge medio
2g 21h
PR unite (30g)
93

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PolicyEngine/policyengine-api

Tutte le issue di PolicyEngine/policyengine-api

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.