refactor: drop from __future__ import annotations in Pydantic-defining files#759
Merged
tcoratger merged 1 commit intoMay 22, 2026
Merged
Conversation
…g files CLAUDE.md rule R1 bans the lazy-annotations import in files that define Pydantic Container or SSZModel classes; lazy-string annotations break Pydantic's forward-reference resolution. Six audit-flagged files still carried it. state/types.py needed a small adjustment after the drop: three classmethod-like helpers on JustifiedSlots returned the class by name (-> JustifiedSlots). Without future annotations the bare name is undefined at signature evaluation, so they switch to typing.Self which reads cleaner anyway for self-referential factories. R2 (Store = LstarStore alias) is intentionally left alone. The alias is the public generic name that lets subspecs (sync, api, node, ...) reference "the current fork's Store" without importing forks.lstar.*. Removing it would couple subspecs to the concrete fork, defeating the multi-fork architecture (leanEthereum#686). R3 (QUIC random peer-id anti-pattern) needs real libp2p TLS extension parsing and belongs in its own PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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
CLAUDE.md rule R1 bans
from __future__ import annotationsin files that define Pydantic Container or SSZModel classes, because lazy-string annotations break Pydantic's forward-reference resolution. Six audit-flagged files still carried it.forks/lstar/containers/validator.pyforks/lstar/containers/state/types.py— small adjustment alongside the drop: three classmethod-like helpers onJustifiedSlotsreturned the class by name (-> JustifiedSlots). Without future annotations the bare name is undefined at signature evaluation, so they switch totyping.Self, which reads cleaner anyway for self-referential factories.forks/lstar/containers/state/state.pyforks/lstar/containers/attestation/attestation.pyforks/lstar/containers/block/types.pysubspecs/xmss/rand.pyItems deliberately skipped
Store = LstarStorealias inforks/__init__.py) — the audit framed it as a backwards-compat shim, but per Multi-fork architecture: roadmap and tracking issue #686 the alias is the public generic name that lets subspecs (sync/,api/,node/, ...) reference "the current fork's Store" without importingforks.lstar.*. Dropping it would couple subspecs to the concrete fork and defeat the multi-fork architecture.transport/quic/connection.py) — needs real libp2p TLS extension parsing (X.509 extension OID1.3.6.1.4.1.53594.1.1, signature verification over the TLS public key, PeerId derivation). Affects both client and server paths and belongs in its own focused PR.Test plan
ruff check,ruff format --check,ty check— all clean.uv run pytest tests/lean_spec/forks/ tests/lean_spec/subspecs/sync/ tests/lean_spec/subspecs/api/ tests/lean_spec/subspecs/node/ tests/lean_spec/subspecs/xmss/— 455 tests pass.uv run fill tests/consensus/lstar/fc/test_tick_system.py::test_tick_interval_progression_through_full_slot --fork=Lstar— 1 passed in 9.25s.🤖 Generated with Claude Code