Skip to content

refactor(language): a translation policy and a bound's side name the values they can be, rather than being a string - #350

Merged
FBumann merged 1 commit into
refactor/literal-vocabulariesfrom
refactor/policy-and-side-vocabularies
Sep 1, 2026
Merged

refactor(language): a translation policy and a bound's side name the values they can be, rather than being a string#350
FBumann merged 1 commit into
refactor/literal-vocabulariesfrom
refactor/policy-and-side-vocabularies

Conversation

@FBumann

@FBumann FBumann commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Prompt: I think we could improve type hints etc more! Narrowing them from str to literals for example.

Note

The following content was generated by AI.

Stacked on #345 — review that first; this diff is the last two lines of it.

Two more closed vocabularies that were open in the annotation. _Step.policy was a str keying _TRANSLATIONS, and _is_open's side was a str keying _OPEN — both are now TranslationPolicy and BoundSide, and both tables are typed by them.

Verified: pixi run ci — lint, 1003 tests, mkdocs build --strict, 27 documents compiled. Each guard was checked by breaking it; output below.

The guards, broken

A policy the table has no row for — _Step(by, 'wrapp'):

ERROR Argument `Literal['wrapp']` is not assignable to parameter `policy` with type `Literal['edge', 'plain', 'wrap']` in function `_Step.__init__` [bad-argument-type]

A misspelled bound side — else 'uppper':

ERROR `Literal['lower', 'uppper']` is not assignable to `Literal['lower', 'upper']` [bad-assignment]
Split out of this one

OperatorName for OPERATOR_SPELLINGS / Format.operators / Walk.op was written and then pulled back out, because it costs 30 duplicated string literals next to the 30-row spelling table and the two directions are already covered by tests. It gets its own PR on top of this one, so it can be turned down without taking these two with it.

…values they can be, rather than being a string

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hdxai54hc4LwxFQBqMM8jF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant