Skip to content

refactor: make ScriptsTypes a Protocol - #3609

Merged
mkoura merged 1 commit into
masterfrom
scripts_types_protocol
Aug 13, 2026
Merged

refactor: make ScriptsTypes a Protocol#3609
mkoura merged 1 commit into
masterfrom
scripts_types_protocol

Conversation

@mkoura

@mkoura mkoura commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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.

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.
@mkoura
mkoura requested a review from saratomaz as a code owner August 13, 2026 06:47
@mkoura
mkoura requested a lite review from Copilot and removed request for saratomaz August 13, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 ScriptsTypes into a Protocol and replace stub implementations with a shared NotImplementedError message constant.
  • Update prepare_scripts_files signatures to use scriptsdir: FileType | None = None and adapt LocalScripts to forward an empty-string default where required.
  • Remove the ScriptsTypes() placeholder instance from ClusterType and replace it with an annotation, while keeping concrete initialization in LocalCluster/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.

@mkoura
mkoura merged commit 276a243 into master Aug 13, 2026
4 checks passed
@mkoura
mkoura deleted the scripts_types_protocol branch August 13, 2026 08:24
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.

2 participants