Skip to content

Write generated docs as UTF-8 in typer utils docs --output - #1946

Closed
lenamonj wants to merge 1 commit into
fastapi:masterfrom
lenamonj:fix-docs-output-encoding
Closed

Write generated docs as UTF-8 in typer utils docs --output#1946
lenamonj wants to merge 1 commit into
fastapi:masterfrom
lenamonj:fix-docs-output-encoding

Conversation

@lenamonj

Copy link
Copy Markdown

Closes #1881.

typer <app> utils docs --output FILE writes the generated Markdown with output.write_text(clean_docs), which goes through the platform's default encoding. On interpreters whose locale encoding is not UTF-8 (cp1252 on Windows being the common case), any help text holding a character that encoding cannot represent raises UnicodeEncodeError - reproduced today on Linux with LC_ALL=C PYTHONUTF8=0 against the emoji example from #1881.

The fix is the one #1881 asks for: write the file as UTF-8 explicitly, which matches how the docs are meant to be consumed (Markdown tooling assumes UTF-8) and makes the output independent of the machine that generated it.

Includes a regression test that runs utils docs --output in a subprocess under a forced ASCII locale and asserts the file is written and round-trips the non-ASCII help text.

lenamonj added a commit to lenamonj/jeffy-loop that referenced this pull request Aug 31, 2026
The first 3-for-3 wave. CLI11: 1 run, 9 iterations, 3 Mediums, empty-High
close in round 1. typer: 1 run, 11 iterations, 2 Highs (hash-seed app
selection; unencoded file IO closed as a class) - the encoding fix is
upstream as fastapi/typer#1946, closing their open #1881. mimalloc: 3
runs, 28 iterations, 16 findings including a zeroing allocator that
returned uninitialized memory, two unlinkable exported symbols, and a
pkg-config includedir that built nothing; one High re-scored to Medium
mid-run with its derivation published.

Corpus 54 -> 57 across 13 languages. All scoreboard markers re-derived;
pie re-rendered (Python 13, C++ 4, C 3). validate.sh: 315/315 green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCT5TPf6uidh4Y8AQtMzaJ

@svlandeg svlandeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing, violates user contribution guidelines.

Closes #1881.

1881 is a PR, you don't close a PR with another PR, you review and discuss the first one rather than opening duplicates and exponentially increasing our work load.

Thanks.

@svlandeg svlandeg closed this Aug 31, 2026
@lenamonj

Copy link
Copy Markdown
Author

I mistook #1881 for an issue rather than an open PR. That's my error, I apologize.

Nothing further needed from my side - #1881 already carries the fix. Sorry
for the noise.

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.

3 participants