Skip to content

test(cli): suppression comments may not grow unnoticed #849

Closed

Description

@dan-petty

Context & Rationale

Any gate in this repo can be passed by suppressing it.

Current counts:

  • src: 93 type: ignore, 24 # noqa, 13 # nosec, 1 pragma: no cover.
  • tests: 166 type: ignore, 7 # noqa, 3 # nosec.

mypy runs only on src, so warn_unused_ignores never prunes the 166 in tests. These are also unwatched:

  • file-level directives;
  • ruff per-file-ignores;
  • [[tool.mypy.overrides]] blocks;
  • coverage omit.

A grep miscounts: 'nosec' matches inside 'nanosecond' (telemetry/tracer.py:929).

docs/ROADMAP.md:1064 (Type Escape-Hatch Ratchet, P2, no issue) covers blanket ignores and explicit Any, but not counts.

Scope & Deliverables

  • Deliverable:
    • One test in tests/test_architectural_invariants.py counts, with tokenize (comment tokens only), over src and tests:
      • type: ignore;
      • noqa, per rule code;
      • nosec;
      • pragma: no cover;
      • pragma: no mutate;
      • file-level directives.
    • From pyproject.toml it also counts per-file-ignores entries, [[tool.mypy.overrides]] blocks and coverage omit entries.
    • The kinds live in config/constants.py and the ceilings in config/defaults.py, set to the counts at merge. Each check is count ≤ ceiling.
    • The failure message names the kind, the ceiling and the files. It says to fix the cause, or to raise the ceiling with a reason recorded in the task file.
  • Acceptance criteria:
    • The test passes at merge.
    • Adding one # type: ignore to a module in src fails the test, naming the kind, the ceiling and the file.
    • A fixture with 'nanosecond' in a comment is not counted.
    • Removing a suppression keeps the test green.
    • The test runs in at most 1 s, with no new dependency.
  • Key questions:
  • Constraint: Use ≤ so independent PRs merge cleanly, and lower a ceiling whenever you touch its kind.

Strategic Alignment

Activity

  1. added
    type/test
    scope/cli
    priority/p2-medium
    on Oct 1, 2026
  2. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Lines cited at dcafadf.

    After #1107 lands, add ast-grep-ignore markers as one more kind in this item's tokenize pass.

  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #423 and #1347. #1347 caps blind excepts per file, and #423 lowers those caps and adds # noqa: BLE001 markers that this item counts. Found by the 2026-10-08 backlog review.

  4. added this to the v0.2.36 milestone on Oct 14, 2026
  5. dan-petty commented on Oct 14, 2026

    @dan-petty
    OwnerAuthor

    Moved to v0.2.36: v0.2.36 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)

  6. added
    status/in-progress
    on Oct 16, 2026
  7. dan-petty commented on Oct 16, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1590, merged into release/v0.2.36 as 327fbfa.

    Summary

    • Defined suppression comment and configuration waiver kind constants (CONST_SUPPRESSION_KINDS, CONST_COMMENT_SUPPRESSION_KINDS, CONST_PYPROJECT_SUPPRESSION_KINDS) and comment-token regular expressions in src/devops_cli/config/constants.py.
    • Defined DEFAULT_SUPPRESSION_CEILINGS and DEFAULT_NET_CONSTRUCT_SUPPRESSION_CEILING in src/devops_cli/config/defaults.py set to exact merge counts across src/, tests/, and pyproject.toml, and lowered DEFAULT_C901_SUPPRESSION_CEILING from 65 to 51.
    • Added test_suppressions_stay_under_their_ceilings and unit tests in tests/test_architectural_invariants.py that count type: ignore, per-rule-code noqa, nosec, pragma: no cover, pragma: no mutate, file-level directives, and ast-grep-ignore (net-* rule IDs in src/) from tokenize.COMMENT tokens alongside per-file-ignores, [[tool.mypy.overrides]], and coverage omit entries from pyproject.toml.

    Closes #849

    5 file(s) changed.

    How it was verified

    Check runs at 52531b1:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Changed-Test Independence: pass
    • Tests & Coverage: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • Analyze (python): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-849-suppression-comment-ceilings.md:

    • One test in tests/test_architectural_invariants.py counts, with tokenize (comment tokens only), over src and tests: type: ignore, noqa per rule code, nosec, pragma: no cover, pragma: no mutate, file-level directives, and ast-grep-ignore per net-* rule ID (tests/test_architectural_invariants.py::test_suppressions_stay_under_their_ceilings).
    • From pyproject.toml it also counts per-file-ignores entries, [[tool.mypy.overrides]] blocks, and coverage omit entries (tests/test_architectural_invariants.py::test_every_comment_and_pyproject_suppression_kind_is_counted).
    • The kinds live in src/devops_cli/config/constants.py and the ceilings in src/devops_cli/config/defaults.py, set to the counts at merge, with each check enforcing count <= ceiling.
    • Adding one # type: ignore to a module in src fails the test, naming the kind, the ceiling, and the file, and instructing to fix the cause or raise the ceiling with a reason recorded in the task file (tests/test_architectural_invariants.py::test_adding_a_type_ignore_in_src_fails_naming_kind_ceiling_and_file).
    • A fixture with 'nanosecond' in a comment is not counted (tests/test_architectural_invariants.py::test_nanosecond_comment_and_string_literals_are_not_counted).
    • Removing a suppression keeps the test green (tests/test_architectural_invariants.py::test_removing_a_suppression_keeps_the_ceiling_check_green).
    • The test runs in at most 1 s, with no new dependency.
  8. added a commit that references this issue on Oct 17, 2026
  9. removed
    status/in-progress
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/clitype/test

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions