fix: restore daily CI under pytest 9.1 + brainstate 0.5 typed API#102
Merged
Conversation
The scheduled daily CI began failing on the frozen commit d0627d4 due to dependency drift, not source regressions. Three independent root causes are addressed here (all braintrace-side); a fourth was an upstream saiunit bug fixed in saiunit/brainunit 0.5.1 and needs no change here. 1. pytest 9.1.0 parametrize collection error pytest 9.1.0 parses a trailing comma in a single-arg parametrize id ('cls,') as two values, tripping ParameterSet length validation and erroring collection with "GraphNodeMeta has no len()". Drop the trailing commas (module_info_test, hidden_group_test, hid_param_op_test, hidden_pertubation_test). 2. 154 mypy errors from brainstate's new py.typed API brainstate 0.4+ ships type information, exposing its typed surface to mypy. Adopt it properly in source: route PyTree through braintrace's existing alias, centralize an as_size_tuple() helper in _typing, drop FlattedDict subscripts, and add boundary asserts/casts. Minimal # type: ignore only where brainstate's typing makes it unavoidable (hidden Module.__init__, saiunit Unit|Quantity, treedef-as-PyTree). 3. conv test expectations for brainstate 0.5.0 brainstate 0.5.0 hardened conv validation from bare assert to ValueError and changed padding-tuple semantics to one value per spatial dim. Update the affected _conv_test expectations accordingly. Verified locally: full suite 1367 passed / 0 failed (2 xfailed), mypy clean (51 files), wheel+sdist build with py.typed shipped (PEP 561).
Reviewer's GuideRestores daily CI under pytest 9.1 and brainstate 0.5 by tightening braintrace’s typing around brainstate’s new typed API, normalizing size handling in RNN/readout layers, relaxing FlattedDict/PyTree generics in ETrace internals, updating conv tests for changed validation semantics, and fixing pytest parametrize collections; includes small robustness tweaks (docstring guards, explicit casts/asserts) and a type-annotated algorithm registry. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the RNN modules,
self.in_size/self.out_sizeare already normalized via_as_size_tuplein__init__, but many later calls (e.g. toLinearand_forget_bias) re-wrap these attributes with_as_size_tupleon every use; consider normalizing once and either using the attributes directly or caching their last dimension in a local variable to reduce repetition and improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the RNN modules, `self.in_size`/`self.out_size` are already normalized via `_as_size_tuple` in `__init__`, but many later calls (e.g. to `Linear` and `_forget_bias`) re-wrap these attributes with `_as_size_tuple` on every use; consider normalizing once and either using the attributes directly or caching their last dimension in a local variable to reduce repetition and improve readability.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Merged
chaoming0625
added a commit
that referenced
this pull request
Jun 18, 2026
Bump version to 0.2.1 and add changelog entry for the brainstate 0.5 / pytest 9.1 dependency-compatibility maintenance release (#102). Co-authored-by: Chaoming Wang <wcm.brainsim@gmail.com>
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.
Summary
The scheduled daily CI began failing on the frozen commit
d0627d4purely from upstream dependency drift (CI was green 2026-06-01, red from 2026-06-02 on the same commit). Diagnosis found four independent root causes; this PR fixes the three braintrace-side ones. The fourth was an upstreamsaiunitbug, now fixed insaiunit/brainunit0.5.1 — no braintrace change required.GraphNodeMeta has no len())'cls,'trailing comma as 2 valuespy.typedassert→ValueError) + padding-tuple semantics_conv_testexpectationssaiunit0.4.0str-mantissa guard crashed JAX 0.10.1'scustom_vjperror-rendering for any unit-carrying outputDetails
ParameterSet._for_parametrizelength check treats a single-arg id with a trailing comma ('cls,') as two parameters. Removed the trailing commas (module_info_test,hidden_group_test,hid_param_op_test,hidden_pertubation_test).PyTreethrough braintrace's existing alias, centralized anas_size_tuple()helper in_typing, droppedFlattedDictsubscripts, and added boundary asserts/casts.# type: ignoreonly where brainstate's typing makes it unavoidable (hiddenModule.__init__, saiunitUnit|Quantity, treedef-as-PyTree).ValueError(not bareassert) for invalid groups/padding-string/in_size, and interprets an int padding tuple as one value per spatial dim. Updated the affected expectations only.tree_unflatten(out_tree, [aval.str_short() …])(string leaves) before the structure-match check; saiunit 0.4.0's newstr-mantissa guard crashed on those strings for everycustom_vjpcarrying aQuantity. Fixed in saiunit by lettingtree_unflattenround-trip placeholder leaves.Verification (local, mirrors CI)
pytest braintrace/→ 1367 passed, 3 skipped, 2 xfailed, 0 failedmypy braintrace→ Success: no issues found in 51 source filespython -m build→ wheel + sdist build; py.typed shipped in both (PEP 561)🤖 Generated with Claude Code
Summary by Sourcery
Restore compatibility with newer pytest and the typed brainstate/brainunit stack by tightening typing, normalizing size handling, and aligning tests with updated runtime validation and PyTree semantics.
Bug Fixes:
Enhancements: