feat(spec-tool): enforce @final on leaf dataclasses#2965
Merged
Conversation
Add a `FinalDecoratorHygiene` lint rule that flags any leaf dataclass (a `@dataclass` or `@slotted_freezable` class never used as a base) that is missing `@final`. Marking leaf dataclasses `@final` lets `mypyc` bypass the vtable for method calls and property accessors. The rule scans the whole specification once at the first fork position: every fork's modules plus the shared modules such as `ethereum.state` and `ethereum.trace`, including each package's `__init__.py`. Register the rule in `vulture_whitelist.py` since lints are discovered dynamically.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2965 +/- ##
===================================================
+ Coverage 90.06% 90.50% +0.43%
===================================================
Files 488 535 +47
Lines 29562 32700 +3138
Branches 2686 3011 +325
===================================================
+ Hits 26626 29595 +2969
- Misses 2457 2588 +131
- Partials 479 517 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
🗒️ Description
Follow-up to #2934. Add a
FinalDecoratorHygienerule toethereum-spec-lintthat enforces@finalon leaf dataclasses across the specification.PR #2934 added
@finalto leaf dataclasses (@dataclassand@slotted_freezableclasses that are never subclassed) somypyccan bypass the vtable for method calls and property accessors. This rule keeps that coverage from drifting as new forks are copied forward or new dataclasses are added.The rule:
@final. Classes that are subclassed are skipped because they are not leaves, as are non-dataclass types such as enums, protocols, exceptions, and constant namespaces.ethereum.stateandethereum.trace, including each package's__init__.py.vulture_whitelist.py, since lints are discovered dynamically.Note: Because the check is a whole-specification invariant, it runs once at the first fork position, so diagnostics are grouped under the earliest fork's header (
frontier). Each message names the full module path, for exampleethereum.forks.amsterdam.state_tracker, so the location is unambiguous.Example output:

🔗 Related Issues or PRs
Related to #2934.
✅ Checklist
just statictype(scope):.Cute Animal Picture