Skip to content

Policy

asciilint.policy

Character policy parsing and evaluation.

CharacterPolicy dataclass

Allow/deny policy for Unicode characters.

A character is disallowed when it is outside the configured allowlist or inside the configured denylist. Denylist rules take precedence over allowlist rules.

from_config(*, allowed_chars, allowed_ranges, disallowed_chars, disallowed_ranges) classmethod

Build a policy from config-friendly string values.

is_allowed(char)

Return whether char passes the policy.

violation_reason(char)

Return a short human-readable reason for a disallowed character.

CodePointRange dataclass

Inclusive Unicode code point range.

contains(char)

Return whether char is inside this range.

parse(value) classmethod

Parse a range string.

Supported forms include U+0000-U+007F, 0x20..0x7e, 32-126, a single code point such as U+00A9, or a single literal character.

PolicyError

Bases: ValueError

Raised when a character policy cannot be parsed.

parse_code_point(value)

Parse one Unicode code point from a string.