Repository navigation
fix: run server-stored State, Pydantic Events and the test suite on PyPy and free-threaded 3.14 - #709
Merged
Merged
Conversation
The weekly PyPy job failed for three reasons: - `InMemoryCache` sized State entries with `sys.getsizeof`, which always raises `TypeError` on PyPy, so a component whose State is kept on the server failed to render there. Entries are now counted by their UTF-8 size where `getsizeof` gives no size; CPython is unchanged. - PyPy has no `_tracemalloc`, so every test module that imported `tracemalloc` failed to load. Those modules now import it from `tests/_memory.py`, and the tests that measure memory skip on PyPy. - PyPy writes the annotation `tuple[()]` as "tuple[]" when it compiles a module from a syntax tree, as pytest's assert rewriting does, so the test State class names the type through a module alias. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- On free-threaded Python 3.14 a new thread copies the context variables of the thread that starts it. The Pydantic v1 test that checks another thread's validation started its thread inside the validation scope, so the thread hit the scope's limits. It now starts the thread first. - The concurrent messages test expected `on_messages_loaded` to run once, but the hook's documented contract allows one run per thread when threads load the messages at the same time. - The State budget replay test runs on PyPy again and skips only its process-memory bound there. - The workflow kept a comment inside its folded pytest command, which turned the options after it into a shell comment. The options it hid repeated pytest defaults and pyproject.toml, so they are removed and the comment moves above the step. - The sub-path comment and the web frameworks page now say that a thread started on free-threaded Python sees the request that started it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Events decided whether the installed pydantic-core supports its bounded validator copy by reading `SchemaValidator`'s signature. PyPy cannot read the signature of a compiled class, so Events refused every Pydantic class there with "needs Pydantic 2.13.0 or newer". It now builds a tiny validator with the keyword it needs instead. On PyPy the 300-model nesting test then uses all the runner's memory and crashes its worker, so it skips there until #708 is investigated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The weekly run on PyPy and free-threaded CPython 3.14 (
py--alt-interpreters.yml) has failed since it started. This PR fixes the causes that could be pinned down. The rest are tracked in #708 (v1.1). Refs #585. It does not close #585, because #708 is still open.Product fixes (changelog entries)
InMemoryCachesized State entries withsys.getsizeof, which always raisesTypeErroron PyPy. Every component withState._storage = "server"failed to render there (since 0.7.0). Entries are now counted by their UTF-8 size whengetsizeofgives no size. CPython is unchanged.SchemaValidator's signature. PyPy cannot read the signature of a compiled class, so Events refused every Pydantic State and event data class with "needs Pydantic 2.13.0 or newer" although 2.14.1 was installed. Events now builds a tiny validator with the_use_prebuiltkeyword instead. A probe run on PyPy went from 298 failing tests to 4 with this fix.Test and CI fixes
_tracemalloc, so 9 test modules failed to import. They import it fromtests/_memory.py. Tests that measure memory skip on PyPy. The State budget replay test still runs there and skips only its memory bound.from __future__ import annotations, PyPy compilestuple[()]to the texttuple[]when pytest rewrites asserts. The test names the type through an alias. A user hits the same thing only with a State dataclass that has atuple[()]field and is defined inside their own pytest test module on PyPy: that class loses its type check.-X thread_inherit_context=1on CPython 3.14 found no other test with this problem. The sub-path code comment and the "Your own threads" note on the web frameworks page now describe this behavior.on_messages_loadedto run once. The hook's documented contract allows one run per thread when two threads load the messages at the same time, which happened once on 3.14t. The test now accepts that.-rfE -o faulthandler_timeout=600into a shell comment. Both options only repeated pytest's default andpyproject.toml, so they are removed and the comment moves above the step.test_a_chain_of_nested_models_deeper_than_the_nesting_limit_is_refuseduses all 16 GB of the runner and crashes its worker. It skips on PyPy until PyPy and free-threaded test failures left after #585 #708 is resolved.Left for v1.1 (#708)
test_a_class_made_at_run_time_can_be_freed(a Pydantic class stays alive aftergc.collect()), and the JetBrains fixture test in citry_lsp.Earlier weekly runs on
main(42629897066, 41453907909) passed on 3.14t. The 3.14t failures here come from tests added since then (item 5) and a rare race (item 6).Checks
-X thread_inherit_context=1: all passed.--platform linux, andscripts/validate.py: all pass. The Rust phases were not run because nothing undercrates/changed.Review
Independent reviewers checked the changes, with separate prose passes and a docs cold read of the web frameworks paragraph and the changelog. Changes made from their findings:
finally, so a failure cannot leave pytest waiting for the thread at exit._storage = "server"and lead with the outcome._memory.py, and the new docstring.🤖 Generated with Claude Code