Template source scanners used by contracts checker.
contracts.template_scan
| 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
One statically knowable programmatic HTTP QUERY client call.
Private scan mapping that iterates canonical names and resolves aliases.
Canonical built-in scan inputs derived from logical loader names.
Loaded logical sources with private loader provenance.
Return the remainder of one call, stopping at its balanced).
Return POST only when form has method='post', otherwise GET.
Extract (attr_name, url, method_override) from template source.
Extract literal, browser-proven QUERY calls from template scripts.
Chirp does not publish a declarativehx-queryattribute. This scanner intentionally recognizes only the programmatic Fetch…
Extract URL paths from href= attributes and macro keyword arguments.
Used for orphan-route detection: catches<a href="/team">, macro calls
likesidebar_link("/team", ...),…
Extract legacy action= contract names from template call arguments.
Extract static hx-target selector values from source.
Extract static id= values from source.
Extract static template references from Kida template tags.
Resolve a Kida cross-template reference for contract bookkeeping.
Kida 0.8 lets templates use./ and ../references relative to the
caller, plus@alias/namespace…
Extract id values from fragment_island() macro calls.
Extract id values from wizard_form() macro calls.
Extract id values from elements that have hx-disinherit.
Extract #id values from hx-target when element is mutating.
Extractsrc= attribute values from <htmx-partial>elements.
Values are normalized to URL paths suitable for route matching:
query strings and fragments are stripped, and…
Load one logical template while retaining loader provenance.
Load logical template sources and their private provenance.
Load all logical template sources for the public contract snapshot.
QueryClientReference
class
One statically knowable programmatic HTTP QUERY client call.
_LoadedTemplateSource
class
CanonicalTemplateSources
class
Private scan mapping that iterates canonical names and resolves aliases.
CanonicalTemplateScan
class
Canonical built-in scan inputs derived from logical loader names.
TemplateSourceInventory
class
Loaded logical sources with private loader provenance.
_javascript_call_suffix
function
def _javascript_call_suffix(source: str, start: int) -> str
Return the remainder of one call, stopping at its balanced).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— | |
start
|
int
|
— |
get_form_method
function
def get_form_method(source: str, action_pos: int) -> str | None
Return POST only when form has method='post', otherwise GET.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— | |
action_pos
|
int
|
— |
extract_targets_from_source
function
def extract_targets_from_source(source: str) -> list[tuple[str, str, str | None]]
Extract (attr_name, url, method_override) from template source.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_query_client_references
function
def extract_query_client_references(source: str) -> tuple[QueryClientReference, ...]
Extract literal, browser-proven QUERY calls from template scripts.
Chirp does not publish a declarativehx-queryattribute. This scanner
intentionally recognizes only the programmatic Fetch andhtmx.ajax
forms covered by the QUERY browser contract, and only when the URL and
method are literal. Dynamic headers remain unknown instead of becoming a
false-positive media-type diagnostic.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_href_references
function
def extract_href_references(source: str) -> set[str]
Extract URL paths from href= attributes and macro keyword arguments.
Used for orphan-route detection: catches<a href="/team">, macro calls
likesidebar_link("/team", ...), and keyword args like href="/login".
Returns base paths (query strings and fragments stripped).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_legacy_action_contracts
function
def extract_legacy_action_contracts(source: str) -> set[str]
Extract legacy action= contract names from template call arguments.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_hx_target_selectors
function
def extract_hx_target_selectors(source: str) -> list[str]
Extract static hx-target selector values from source.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_static_ids
function
def extract_static_ids(source: str) -> set[str]
Extract static id= values from source.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_template_references
function
def extract_template_references(source: str) -> set[str]
Extract static template references from Kida template tags.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
resolve_template_reference
function
def resolve_template_reference(reference: str, caller: str, template_aliases: Mapping[str, str] | None = None) -> str
Resolve a Kida cross-template reference for contract bookkeeping.
Kida 0.8 lets templates use./ and ../references relative to the
caller, plus@alias/namespace prefixes. Chirp's contract rules compare
references against the root-relative names returned by loaders, so keep the
same canonicalization here.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
reference
|
str
|
— | |
caller
|
str
|
— | |
template_aliases
|
Mapping[str, str] | None
|
None
|
extract_fragment_island_ids
function
def extract_fragment_island_ids(source: str) -> set[str]
Extract id values from fragment_island() macro calls.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_wizard_form_ids
function
def extract_wizard_form_ids(source: str) -> set[str]
Extract id values from wizard_form() macro calls.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_ids_with_disinherit
function
def extract_ids_with_disinherit(source: str) -> set[str]
Extract id values from elements that have hx-disinherit.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_mutation_target_ids
function
def extract_mutation_target_ids(source: str) -> set[str]
Extract #id values from hx-target when element is mutating.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
extract_htmx_partial_sources
function
def extract_htmx_partial_sources(source: str) -> list[str]
Extractsrc= attribute values from <htmx-partial>elements.
Values are normalized to URL paths suitable for route matching:
query strings and fragments are stripped, and only leading-/paths
are kept. Results are deduplicated while preserving order.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— |
_load_one
function
def _load_one(loader: Any, name: str) -> _LoadedTemplateSource | None
Load one logical template while retaining loader provenance.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
loader
|
Any
|
— | |
name
|
str
|
— |
load_template_inventory
function
def load_template_inventory(kida_env: Any) -> TemplateSourceInventory
Load logical template sources and their private provenance.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
kida_env
|
Any
|
— |
load_template_sources
function
def load_template_sources(kida_env: Any) -> dict[str, str]
Load all logical template sources for the public contract snapshot.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
kida_env
|
Any
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/template_scan.py:1