Classes
SupportsContextAnalysis
4
▼
Minimal template protocol needed by context contract checks.
SupportsContextAnalysis
4
▼
Minimal template protocol needed by context contract checks.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str | None
|
— |
Methods
depends_on
0
frozenset[str]
▼
depends_on
0
frozenset[str]
▼
def depends_on(self) -> frozenset[str]
Returns
frozenset[str]
list_defs
0
list[str]
▼
list_defs
0
list[str]
▼
def list_defs(self) -> list[str]
Returns
list[str]
list_blocks
0
list[str]
▼
list_blocks
0
list[str]
▼
def list_blocks(self) -> list[str]
Returns
list[str]
ContextContractIssue
8
▼
Machine-readable context contract finding.
ContextContractIssue
8
▼
Machine-readable context contract finding.
Attributes
| Name | Type | Description |
|---|---|---|
code |
Literal['K-CTX-001', 'K-CTX-002']
|
— |
severity |
Literal['error', 'warning']
|
— |
path |
str
|
— |
message |
str
|
— |
template_name |
str | None
|
— |
lineno |
int | None
|
— |
col_offset |
int | None
|
— |
suggestion |
str | None
|
— |
Functions
_flatten_mapping
2
set[str]
▼
Return dotted paths available from a nested mapping contract.
_flatten_mapping
2
set[str]
▼
def _flatten_mapping(mapping: Mapping[str, Any], prefix: str = '') -> set[str]
Parameters
| Name | Type | Description |
|---|---|---|
mapping |
Mapping[str, Any] |
|
prefix |
str |
Default:''
|
Returns
set[str]
_normalize_paths
1
set[str]
▼
Normalize context contract input into dotted paths.
_normalize_paths
1
set[str]
▼
def _normalize_paths(paths_or_mapping: Iterable[str] | Mapping[str, Any] | None) -> set[str]
Parameters
| Name | Type | Description |
|---|---|---|
paths_or_mapping |
Iterable[str] | Mapping[str, Any] | None |
Returns
set[str]
check_context_contract
5
list[ContextContractIssu…
▼
Compare template dependencies against a provided context contract.
``provided`…
check_context_contract
5
list[ContextContractIssu…
▼
def check_context_contract(template: SupportsContextAnalysis, provided: Iterable[str] | Mapping[str, Any], *, optional: Iterable[str] | Mapping[str, Any] | None = None, globals: Iterable[str] | Mapping[str, Any] | None = None, check_extra: bool = False) -> list[ContextContractIssue]
Compare template dependencies against a provided context contract.
provided is route/framework data. globalsare values guaranteed by
the environment or adapter. Both accept dotted-path iterables or nested
mappings. Top-level keys do not satisfy dotted paths unless the exact dotted
path is present; usetemplate.validate_context()for legacy top-level
checks.
Parameters
| Name | Type | Description |
|---|---|---|
template |
SupportsContextAnalysis |
|
provided |
Iterable[str] | Mapping[str, Any] |
|
optional |
Iterable[str] | Mapping[str, Any] | None |
Default:None
|
globals |
Iterable[str] | Mapping[str, Any] | None |
Default:None
|
check_extra |
bool |
Default:False
|
Returns
list[ContextContractIssue]