Skip to content

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

Merged
FBumann merged 1 commit into
mainfrom
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#354
FBumann merged 1 commit into
mainfrom
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.

Re-opened against main. #350 carried this same commit but was based on refactor/literal-vocabularies, so merging it landed the change on that branch rather than on main#345 had already gone in as a squash. The branch is now rebased onto main and holds one commit.

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 on the rebased branch — 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]
What is not here

OperatorName for OPERATOR_SPELLINGS / Format.operators / Walk.op is #352, stacked on this branch. It was split out because it costs 30 duplicated string literals next to the 30-row spelling table, and both directions are already covered by tests — so it can be turned down without taking these two with it.

refactor/literal-vocabularies now holds a merge commit that is on no other branch. It is yours to delete when convenient; I did not touch 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
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 math-spec | 🛠️ Build #34337155 | 📁 Comparing 8598892 against latest (3dbd9b2)

  🔍 Preview build  

3 files changed
± CHANGELOG/index.html
± reference/math_spec/boundedness/index.html
± reference/math_spec/typesetting/walk/index.html

@FBumann
FBumann merged commit d212157 into main Sep 1, 2026
5 checks passed
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