Skip to content

tests: mypy has no MODULE_PROVIDERS entry, so a visible gate on it is impossible and the guard dies on a bare KeyError #779

Description

@JarryShaw

Surfaced by #777's cross-review, which tried to add a visible HAS_MYPY gate to tests/vendor/test_vendor_reg_apptype_generator_unit.py and could not.

mypy has no MODULE_PROVIDERS entry. Confirmed on origin/main (110381b63): grep -n "'mypy'" tests/_dependency_gates.py returns nothing. It ships in Pipfile [dev-packages] and in no pyproject.toml extra, so nothing in the provider table describes it.

Consequence: a skipUnless-shaped gate on mypy cannot be added at all. Measured — adding HAS_MYPY = importlib.util.find_spec('mypy') is not None plus @unittest.skipUnless to that test file alone, touching nothing else, makes python -m unittest tests.test_tier_guard.DependencyGateCoverageTests report Ran 9 tests ... FAILED (failures=2, errors=4). Root cause is a bare KeyError: 'mypy' at tests/_dependency_gates.py:682:

providers = MODULE_PROVIDERS[module.partition('.')[0]]

unconditional, and upstream of any DEPENDENCY_GATE_EXCLUSIONS filtering — so no in-test exclusion rescues it. The same bare subscript appears at :635 and :1315.

Two defects, not one.

  1. The missing entry. mypy needs a MODULE_PROVIDERS entry, and probably a DEPENDENCY_GATE_EXCLUSIONS one too, since mypy is a lint-tier tool and gating a test on it should not demand it be added to a pytest install line.
  2. The diagnostic. A missing entry surfaces as an opaque KeyError from a table lookup, with nothing naming the fix. _gates_of (:1008-1021) walks only node.decorator_list for skipUnless calls, so the guard's whole purpose is to audit gates — and the first thing it does with an unrecognised one is crash. It should say which module is unknown and that a MODULE_PROVIDERS entry is what it wants. Compare :1239-1241, which already produces exactly that kind of message for a related case.

Why this matters beyond mypy. #777 was pushed into the inline try/except ImportError: self.skipTest(...) form instead, which works but is invisible to the guard by construction — it is not a decorator, so _gates_of never sees it. That is the "dark test" hazard #745 named and #766 records another instance of: the guard can only audit the gate shape that this table makes possible. Every tool in [dev-packages] but no extra has the same hole.

Blocked on #774, which owns tests/_dependency_gates.py (head 1b63e9899, worker live). Checkable blocker: #774 merged.

Activity

  1. added
    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)
    testPull requests that add or correct tests (test: subject prefix)
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Sep 25, 2026
  2. JarryShaw commented on Sep 25, 2026

    @JarryShaw
    OwnerAuthor

    Unblocked — #774 merged at 12:15:52Z as 35a79016b, so tests/_dependency_gates.py is free. Dispatching.

    Note for whoever picks this up: #766 now waits on this issue rather than on #774, because both want _dependency_gates.py and two agents editing it would clobber each other. So the MODULE_PROVIDERS entry for mypy and the bare-KeyError diagnostic land here first; #766's HAS_ISORT gate follows.

  3. added
    wipWork in flight - a covering PR is open or an agent is actively on it
    and removed
    blockedDeferred pending another issue or decision; see the last comment for what unblocks it
    on Sep 25, 2026
  4. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Sep 25, 2026
  5. added this to the 1.5 milestone on Oct 6, 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

    bugIssues reporting a defect (set by the bug report template; a default, not an assessment)testPull requests that add or correct tests (test: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions