fix: restore import on Python 3.10-3.13 - #6
Merged
Conversation
Installing 1.1.0 and running any command raised, before doing any work:
TypeError: 'function' object is not subscriptable
mistune resolves tokens to renderer methods by name, so TypstRenderer has to
define one called `list`, which shadows the builtin inside the class body. The
`tokens: list[dict]` annotation added to `load_footnotes` in 1.1.0 was then
evaluated against that method while the class was being created. Python 3.14
defers annotation evaluation, which is why this never surfaced in development;
every supported version below it failed on import. Adding
`from __future__ import annotations` keeps annotations unevaluated everywhere.
Two more source-level fixes, both reachable from ordinary Markdown:
Square brackets now escape to `\[` and `\]`. Typst reads a bare `]` as a
stray closing delimiter, so a line like "close it with ] here" aborted the
compile. The citation pattern moves to `_CITATION` and matches the escaped
form so `[@key]` still resolves against a bibliography.
A leading `---` block is only treated as front matter when it actually holds
key/value pairs. A document opening with a horizontal rule previously had
everything up to the next `---` silently dropped from the PDF.
Covered by regression tests for each, verified on 3.10 through 3.14.
The 1.1.0 import crash shipped because the only environment it ever ran in was Python 3.14, where deferred annotations hid it. Two jobs now guard that: the suite runs on every supported version and platform, and a smoke job installs the built package and drives the CLI from a clean directory, which is the exact path that failed for users.
Route reviews to the repository owner, note math expressions and Mermaid diagrams on the roadmap after user requests, and advertise Python 3.14 now that it is covered by CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Installing 1.1.0 and running any command raised, before doing any work:
mistune resolves tokens to renderer methods by name, so TypstRenderer has to
define one called
list, which shadows the builtin inside the class body. Thetokens: list[dict]annotation added toload_footnotesin 1.1.0 was thenevaluated against that method while the class was being created. Python 3.14
defers annotation evaluation, which is why this never surfaced in development;
every supported version below it failed on import. Adding
from __future__ import annotationskeeps annotations unevaluated everywhere.Two more source-level fixes, both reachable from ordinary Markdown:
Square brackets now escape to
\[and\]. Typst reads a bare]as astray closing delimiter, so a line like "close it with ] here" aborted the
compile. The citation pattern moves to
_CITATIONand matches the escapedform so
[@key]still resolves against a bibliography.A leading
---block is only treated as front matter when it actually holdskey/value pairs. A document opening with a horizontal rule previously had
everything up to the next
---silently dropped from the PDF.Covered by regression tests for each, verified on 3.10 through 3.14.