Skip to content

refactor: PEP 695 generic syntax for SSZ collections and Store#744

Merged
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/pep695-ssz-store
May 21, 2026
Merged

refactor: PEP 695 generic syntax for SSZ collections and Store#744
tcoratger merged 1 commit into
leanEthereum:mainfrom
tcoratger:refactor/pep695-ssz-store

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

Convert SSZVector, SSZList, and lstar.Store to PEP 695 generic syntax. The bounds now live inline in the class header, dropping three module-level TypeVar blocks and the Generic and TypeVar imports across two files.

  • types/collections.py: class SSZVector[T: SSZType](SSZModel) and class SSZList[T: SSZType](SSZModel).
  • forks/lstar/store.py: class Store[StateT: Container, BlockT: Container](StrictBaseModel). StateT and BlockT are now class-scoped, so they also leave __all__ (confirmed unused outside the file).

Pydantic 2.12 emits identical __pydantic_generic_metadata__ under both syntaxes, so the element-type recovery helper in collections.py keeps working unchanged. Verified with a probe before editing.

Test plan

  • ruff check src/lean_spec/types/collections.py src/lean_spec/forks/lstar/store.py — clean.
  • Pydantic metadata probe: parameterised PEP 695 subclass produces the same {'origin': ..., 'args': (...), 'parameters': ()} shape as old-style Generic[T].

🤖 Generated with Claude Code

Convert SSZVector, SSZList, and the lstar Store to PEP 695 generic
syntax. The bounds (T: SSZType, StateT/BlockT: Container) now live
inline in the class header, dropping three module-level TypeVar
blocks and the Generic and TypeVar imports across two files.

Pydantic 2.12 emits identical __pydantic_generic_metadata__ under
both syntaxes, so the element-type recovery helper in collections
is unaffected. StateT and BlockT also leave __all__ since they are
now class-scoped and unused outside the file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit d6844a0 into leanEthereum:main May 21, 2026
13 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.

1 participant