Skip to main content

Module coverage

Module coverage 

Source
Expand description

Signature annotation-slot coverage + Any/decorator analysis — the Python analog of fxrank-lang-ts’s coverage.rs. The project thesis (“types lower the score”) made operational for gradual-typed Python: we measure how much of a function’s signature is explicitly annotated (its boundary), so the boundary-containment discount in analyze_unit can shift contained effects down when the boundary is honest, and void the discount when Any poisons it.

§Slots (spec §“Signature coverage”)

A “slot” is one declared boundary position: each parameter (excluding self/cls — convention never annotates them), plus one return slot. *args / **kwargs are one slot each (a typed star-param counts; an untyped one degrades coverage — the escape-hatch rule). A slot is typed iff it carries an explicit annotation whose top-level type is not Any. t = typed slots, S = total slots → None (t = 0), Partial (0 < t < S), Full (t = S).

§Any poison (two cases, spec §“Poison & confidence rules”)

  • Signature (x: Any, -> Any) → that slot is untyped and any_in_signature is set (an Any-typed boundary is a non-boundary).
  • Body (cast(Any, …), an Any-annotated local) → any_in_body is set; analyze_unit forces the boundary shift to 0 (the discount is voided).

Both cases drive a type.escape risk in analyze_unit.

§Decorators (spec §“Poison & confidence rules”)

An unknown / dynamic decorator (outside a known-pure allowlist) does not degrade coverage — the written annotations are real signal — but lowers the function’s confidence (“typed, but a wrapper may be lying”).

Top-level only. Any detection is shallow: a parameter typed list[Any] or dict[str, Any] counts as typed (its top-level type is list/dict, not the bare Any name). Matching the Milestone-A scope, we do not descend into subscript type arguments.

Structs§

Coverage
Annotation-slot coverage + Any/decorator signals for one function unit.

Functions§

of
Compute the annotation-slot coverage + Any/decorator signals of unit.