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

未关闭
#4,182 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@anth-volk 已经在做这个了。

开始于 2026年11月4日。

  • #4183 来自 @anth-volk —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
20/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
停滞
技术栈
python

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
18
派生
33
平均合并
2 天 21 小时
30 天内合并 PR
93

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PolicyEngine/policyengine-api 的其他 Issue

查看 PolicyEngine/policyengine-api 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。