refactor: make ScriptsTypes a Protocol - #3609
Merged
Merged
Conversation
The base class carried no shared behavior, only stubs raising NotImplementedError. As a structural Protocol: - The unread `type` attribute and `LOCAL`/`TESTNET` constants are dropped. - `TestnetScripts` gets an explicit `gen_split_topology_files` override that raises `NotImplementedError`, preserving the old inherited-stub behavior. - `ClusterType.cluster_scripts` is a class-level annotation instead of a placeholder `ScriptsTypes()` instance, and the union annotation collapses to the single protocol name.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the “cluster scripts” abstraction from a stub-only base class into a structural typing.Protocol, simplifying typing while preserving the previous runtime “not implemented” behavior where needed.
Changes:
- Convert
ScriptsTypesinto aProtocoland replace stub implementations with a sharedNotImplementedErrormessage constant. - Update
prepare_scripts_filessignatures to usescriptsdir: FileType | None = Noneand adaptLocalScriptsto forward an empty-string default where required. - Remove the
ScriptsTypes()placeholder instance fromClusterTypeand replace it with an annotation, while keeping concrete initialization inLocalCluster/TestnetCluster.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cardano_node_tests/utils/cluster_scripts.py | Replaces the stub base class with a Protocol, adjusts method signatures, and adds an explicit “not supported” override for testnet split topology generation. |
| cardano_node_tests/utils/cluster_nodes.py | Removes the placeholder ScriptsTypes() instance and relies on typed cluster_scripts initialized in concrete cluster type constructors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
The base class carried no shared behavior, only stubs raising NotImplementedError. As a structural Protocol:
typeattribute andLOCAL/TESTNETconstants are dropped.TestnetScriptsgets an explicitgen_split_topology_filesoverride that raisesNotImplementedError, preserving the old inherited-stub behavior.ClusterType.cluster_scriptsis a class-level annotation instead of a placeholderScriptsTypes()instance, and the union annotation collapses to the single protocol name.