Hypermedia contracts checker orchestration.
contracts.checker
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Build the declared schema snapshot from a migrations directory, or None.
Mirrorschirp.app._build_contract_schemafor the fallback snapshot
builder. ReturnsNonefor db-less apps so…
Return the user module that owns handler, when discoverable.
Collect template paths referenced from Python route-handler modules.
Scans the full module source (not just the handler body) so helpers like
Fragment(_TOAST_TEMPLATE, ...)and…
Single pass over router.routes. Returns (referenced_templates, referenced_route_paths).
Templates whose route handler passesdefer_blocks=to Suspense.
Those handlers bypass auto-discovery, so the templates they render are
exempt from thesuspense_defercheck. Conservative…
Return every registered signal/derived producer name for the snapshot.
Return every session-scoped signal/derived name for contract checks.
Attach logical aliases to built-in diagnostics for one physical source.
Return derived signals whose deps span global and session audiences.
Validate app route/template contract consistency.
_build_contract_schema
function
def _build_contract_schema(migrations_dir: str | None) -> SchemaSnapshot | None
Build the declared schema snapshot from a migrations directory, or None.
Mirrorschirp.app._build_contract_schemafor the fallback snapshot
builder. ReturnsNone for db-less apps so the datashape contract is
a silent no-op, and swallows malformed-migration errors (data is optional).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
migrations_dir
|
str | None
|
— |
_handler_module
function
def _handler_module(handler: object) -> types.ModuleType | None
Return the user module that owns handler, when discoverable.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
handler
|
object
|
— |
_python_template_references
function
def _python_template_references(router: object) -> set[str]
Collect template paths referenced from Python route-handler modules.
Scans the full module source (not just the handler body) so helpers like
Fragment(_TOAST_TEMPLATE, ...) and module-level _FOO = "bar.html"
constants count as references for dead-template detection.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
router
|
object
|
— |
_route_prepass
function
def _route_prepass(router: object, kida_env: Environment | None, result: CheckResult) -> tuple[set[str], set[str]]
Single pass over router.routes. Returns (referenced_templates, referenced_route_paths).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
router
|
object
|
— | |
kida_env
|
Environment | None
|
— | |
result
|
CheckResult
|
— |
_collect_defer_blocks_templates
function
def _collect_defer_blocks_templates(router: object) -> frozenset[str]
Templates whose route handler passesdefer_blocks=to Suspense.
Those handlers bypass auto-discovery, so the templates they render are
exempt from thesuspense_defercheck. Conservative by design: any
handler source containing adefer_blocks=kwarg exempts every template
that handler references via aSuspense(...)-style call.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
router
|
object
|
— |
_signal_names
function
def _signal_names(app: App) -> frozenset[str]
Return every registered signal/derived producer name for the snapshot.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
app
|
App
|
— |
_session_signal_names
function
def _session_signal_names(app: App) -> frozenset[str]
Return every session-scoped signal/derived name for contract checks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
app
|
App
|
— |
_issue_with_template_aliases
function
def _issue_with_template_aliases(issue: ContractIssue, aliases_by_canonical: dict[str, tuple[str, ...]]) -> ContractIssue
Attach logical aliases to built-in diagnostics for one physical source.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
issue
|
ContractIssue
|
— | |
aliases_by_canonical
|
dict[str, tuple[str, ...]]
|
— |
_mixed_audience_derived_names
function
def _mixed_audience_derived_names(app: App) -> frozenset[str]
Return derived signals whose deps span global and session audiences.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
app
|
App
|
— |
check_hypermedia_surface
function
def check_hypermedia_surface(app: App, *, deploy: bool = False) -> CheckResult
Validate app route/template contract consistency.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
app
|
App
|
— | The frozen app whose hypermedia surface is validated. |
deploy
|
bool
|
False
|
When True, run env-aware rules (secret_key, allowed_hosts, debug/metrics/sentry, security_stack, csp_nonce) against a production-posture *view* of the config so deploy-blocking misconfigurations escalate to ERROR exactly as they would in production. The view is a shallow copy with ``env="production"`` set via ``object.__setattr__`` (the config is frozen+slotted, and ``dataclasses.replace`` would re-run ``__post_init__`` and raise on the very empty-secret_key case we want to *report*). The user's real ``app.config`` is never mutated. Tighten-only: a genuinely deploy-ready app still passes. |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/checker.py:1