contracts.utils

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

Utility helpers shared by contract rules.

Utility helpers shared by contract rules.

contracts.utils

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

edit_distance
function
def edit_distance(a: str, b: str) -> int

Levenshtein distance between two strings.

Parameters

Name Type Default Description
a str
b str
closest_match
function
def closest_match(target: str, values: set[str], *, max_dist: int) -> str | None

Return closest string within max_dist, or None.

Parameters

Name Type Default Description
target str
values set[str]
max_dist int
closest_id
function
def closest_id(target: str, ids: set[str], *, max_dist: int = 3) -> str | None

Closest ID match ignoring case.

Parameters

Name Type Default Description
target str
ids set[str]
max_dist int 3
closest_field
function
def closest_field(target: str, fields: set[str], *, max_dist: int = 2) -> str | None

Closest form field candidate.

Parameters

Name Type Default Description
target str
fields set[str]
max_dist int 2

View source · /home/runner/work/chirp/chirp/site/../src/chirp/contracts/utils.py:1