contracts.rules_accessibility

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

Accessibility contract checks for templates.

Checks:

  • a11y_interactive: htmx URL attrs on non-interactive elements
  • a11y_label: form fields without associated labels
  • a11y_alt: images without alt attribute
  • a11y_heading: heading levels that…

Accessibility contract checks for templates.

Checks:

  • a11y_interactive: htmx URL attrs on non-interactive elements
  • a11y_label: form fields without associated labels
  • a11y_alt: images without alt attribute
  • a11y_heading: heading levels that skip
  • a11y_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

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's id
  • The element is wrapped inside a<label>tag
  • The element hasaria-label or aria-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

or role="main" landmark.

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