Module

utils.typo_suggestions

Typo suggestion utilities for Kida error messages.

Provides suggest_closest() for "Did you mean?" hints when a name is not found but a similar name exists. Used by compiler (filters, tests), loaders (template names), and runtime (UndefinedError).

Functions

suggest_closest 4 list[str]
Return closest matching names for typo suggestions. Uses difflib.get_close_mat…
def suggest_closest(name: str, candidates: Iterable[str], *, limit: int = 3, cutoff: float = 0.6) -> list[str]

Return closest matching names for typo suggestions.

Uses difflib.get_close_matches with configurable cutoff. Returns up tolimitmatches, or empty list if none close enough.

Parameters
Name Type Description
name str

The unknown name (e.g. filter name, variable name)

candidates Iterable[str]

Valid names to match against (e.g. env._filters.keys())

limit int

Max number of suggestions to return

Default:3
cutoff float

Similarity threshold (0.0-1.0). 0.6 is reasonable for typos.

Default:0.6
Returns
list[str]