Accessibility contract checks for templates.
Checks:
a11y_interactive: htmx URL attrs on non-interactive elementsa11y_label: form fields without associated labelsa11y_alt: images without alt attributea11y_heading: heading levels that skipa11y_landmark: layout templates missing
contracts.rules_accessibility
| 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
Warn about htmx URL attrs on non-interactive elements without role/tabindex.
Replace Kida expressions with a wildcard sentinel for matching.
Warn when form fields lack an associated label.
Valid associations (any one is sufficient):
<label for="id">matching the element'sid- The element is wrapped…
Warn when tags lack an alt attribute.
Warn when heading levels skip (e.g. h1 → h3 with no h2).
Warn when layout templates have no
check_accessibility
function
def check_accessibility(source: str, template_name: str) -> list[ContractIssue]
Warn about htmx URL attrs on non-interactive elements without role/tabindex.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— | |
template_name
|
str
|
— |
_normalize_for_matching
function
def _normalize_for_matching(value: str) -> str
Replace Kida expressions with a wildcard sentinel for matching.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value
|
str
|
— |
check_label_association
function
def check_label_association(source: str, template_name: str) -> list[ContractIssue]
Warn when form fields lack an associated label.
Valid associations (any one is sufficient):
<label for="id">matching the element'sid- The element is wrapped inside a
<label>tag - The element has
aria-labeloraria-labelledby
Exempt elements:
<input type="hidden|submit|button|image|reset">
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— | |
template_name
|
str
|
— |
check_image_alt
function
def check_image_alt(source: str, template_name: str) -> list[ContractIssue]
Warn when tags lack an alt attribute.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— | |
template_name
|
str
|
— |
check_heading_order
function
def check_heading_order(source: str, template_name: str) -> list[ContractIssue]
Warn when heading levels skip (e.g. h1 → h3 with no h2).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
source
|
str
|
— | |
template_name
|
str
|
— |
check_landmarks
function
def check_landmarks(layout_sources: dict[str, str]) -> list[ContractIssue]
Warn when layout templates have no
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
layout_sources
|
dict[str, str]
|
— | Mapping of layout template name → source for templates that serve as layouts (contain ``{% block %}``). Only layout templates are checked because pages inherit their landmark structure from the layout. |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/rules_accessibility.py:1