PY-TYPE0004 · prohibited_annotation
Count prohibited universal types in every Python annotation position.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Inspect function parameters and returns, annotated variables and attributes, PEP 695 and
explicit TypeAlias values, generic bases, type-parameter bounds and defaults, nested
generic arguments, string annotations, and type comments. Resolve direct and aliased imports
from typing, typing_extensions, and builtins. Bare object resolves to the built-in
unless a lexical binding conservatively shadows it. Each prohibited occurrence contributes
one to the result. Configure any subset of Any and object through prohibited.
Evidence
Section titled “Evidence”Each finding identifies the resolved universal type and the annotation source line. Nested occurrences remain separate evidence because each can require a different replacement. The value is the number of prohibited universal types across every annotation position.
Exceptions
Section titled “Exceptions”Unresolved names, wildcard imports, and names with another binding in the same lexical scope are not reported. Values outside annotation positions are ignored. External stub boundaries can disable one prohibition or the complete rule when their published contract requires it.
Examples
Section titled “Examples”Bad
`from typing import Any as Dynamic`, `payload: list[Dynamic]`, `value: object`, and`class Adapter(Protocol[Any])` contain prohibited universal types.
Goodpayload: Mapping[str, JsonValue] describes a capability. After object = DomainRoot,
value: object is conservatively treated as the project type rather than the built-in.
References
Section titled “References”- Cites “Python typing specification”,
Any. Open reference - Cites “The Python Standard Library”,
object. Open reference - Generalizes Ruff ANN401 any-type. Open reference
- Cites “Pyright documentation”, advanced type concepts on
UnknownandAny. Open reference