Skip to content

Build the surrogate probe with chr so mypy can cache it - #23

Merged
trissim merged 2 commits into
mainfrom
fix/mypy-surrogate-literal
Oct 25, 2026
Merged

trissim merged 2 commits into
mainfrom
fix/mypy-surrogate-literal

Conversation

@trissim

@trissim trissim commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Since #21 shipped py.typed, mypy analyses NRA inside its users. CPythonClassConstructionField.DOCUMENTATION (native_compilation.py:4199) held the literal "\ud800". mypy 2.3.0 infers Literal['\ud800'], then crashes writing it to its UTF-8 cache:

File "mypy/cache.py", line 355, in write_literal
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed

That took down agent-comms' TypeErrors measure on OpenHCSDev/agent-comms#3170. chr(0xD800) is the same value, and mypy types it as str.

Proof: reproduced from an empty cache with mypy 2.3.0 and NRA 3fc2f08. With this branch installed, mypy completes (no traceback), and tests/test_native_class_metadata_values.py plus tests/test_documentation_store.py pass (29).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q8rVa3cPyXzpCKyR8XvM8W

CPythonClassConstructionField.DOCUMENTATION probed CPython with the
literal "\ud800". Since py.typed, mypy analyses NRA for its users, infers
Literal['\ud800'] for the enum value and crashes writing it to its UTF-8
cache (mypy 2.3.0, INTERNAL ERROR in cache.write_literal), which took
agent-comms' TypeErrors measure down. chr(0xD800) is the same value and
types as str.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8rVa3cPyXzpCKyR8XvM8W
Copilot AI balanced review requested due to automatic review settings October 25, 2026 02:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@trissim
trissim merged commit 11b9da3 into main Oct 25, 2026
3 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.

2 participants