Skip to content

Comments

refactor(forks): Make Fork Pydantic-Compatible#1686

Merged
marioevz merged 3 commits intomainfrom
make-fork-pydantic-compatible
Jun 4, 2025
Merged

refactor(forks): Make Fork Pydantic-Compatible#1686
marioevz merged 3 commits intomainfrom
make-fork-pydantic-compatible

Conversation

@marioevz
Copy link
Member

🗒️ Description

Modifies Fork type definition to make it pydantic-friendly, and can now be serialized (into a string) and parsed back into the correct object:

class BlockchainTest(BaseModel):
    fork: Fork = Field(..., alias="network")

instead of:

class BlockchainTest(BaseModel):
    fork: str = Field(..., alias="network")

And the conversion happens on the fly in both directions everywhere.

🔗 Related Issues

None.

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.

@marioevz marioevz added type:refactor Type: Refactor scope:fw Scope: Framework (evm|tools|forks|pytest) labels May 30, 2025
@marioevz marioevz requested a review from danceratopz May 30, 2025 19:18
Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

Really nice! Makes so much sense.

I just removed a one-line reference to blockchain_test_network_name in the docs.

Shame we can't quite get rid of the fixture class get_fork() method (due to potentially multi-fork state fixtures). We could apply some pydantic, if we strictly only supported single-fork state test fixtures, but it's nice to be able to maintain the ability to load multi-fork state test fixtures.

@marioevz marioevz merged commit 315d975 into main Jun 4, 2025
25 checks passed
@marioevz marioevz deleted the make-fork-pydantic-compatible branch June 4, 2025 14:01
kclowes pushed a commit to kclowes/execution-spec-tests that referenced this pull request Oct 20, 2025
* refactor(forks): Pydantic-friendly `Fork` type

* fix(tests): Bad import

* docs(forks): remove `blockchain_test_network_name` from docs

---------

Co-authored-by: danceratopz <danceratopz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:fw Scope: Framework (evm|tools|forks|pytest) type:refactor Type: Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants