Skip to content

Drop step-specific "base Click command" implementations#4457

Open
happz wants to merge 4 commits intomainfrom
base-command-to-base-plugin-class
Open

Drop step-specific "base Click command" implementations#4457
happz wants to merge 4 commits intomainfrom
base-command-to-base-plugin-class

Conversation

@happz
Copy link
Contributor

@happz happz commented Jan 4, 2026

They are not that different, each step class just used different step name, and that was it. Dropping the base_command method from Step-like classes, replacing them with a shared implementation.

Also, --how now prints allowed/known plugins as possible choices. I was editing the help text, and this felt like a natural change of the option.

Pull Request Checklist

  • implement the feature

@happz happz added this to planning Jan 4, 2026
@happz happz added code | cli Changes related to the command line interface code | style Code style changes not affecting functionality code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. ci | full test Pull request is ready for the full test execution labels Jan 4, 2026
@github-project-automation github-project-automation bot moved this to backlog in planning Jan 4, 2026
@happz happz moved this from backlog to implement in planning Jan 4, 2026
@happz happz force-pushed the base-command-to-base-plugin-class branch from 8af29bc to b5373c7 Compare January 4, 2026 20:15
@LecrisUT LecrisUT self-assigned this Jan 5, 2026
Copy link
Contributor

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

LGTM, just 2 minor issues.

@LecrisUT LecrisUT removed their assignment Jan 7, 2026
@happz happz force-pushed the base-command-to-base-plugin-class branch from b5373c7 to d9fc940 Compare February 13, 2026 10:33
@happz happz moved this from implement to review in planning Feb 13, 2026
@happz happz force-pushed the base-command-to-base-plugin-class branch from d9fc940 to d76bcd0 Compare February 25, 2026 21:55
@happz happz force-pushed the base-command-to-base-plugin-class branch 2 times, most recently from 1268e00 to 48e6368 Compare March 2, 2026 08:40
happz added 4 commits March 13, 2026 09:58
They are not that different, each step class just used different step
name, and that was it. Dropping the `base_command` method from
`Step`-like classes, replacing them with a shared implementation.

Also, `--how` now prints allowed/known plugins as possible choices. I
was editing the help text, and this felt like a natural change of the
option.
@happz happz force-pushed the base-command-to-base-plugin-class branch from 48e6368 to 3e49a3b Compare March 13, 2026 09:02
@therazix therazix self-assigned this Mar 13, 2026
thrix

This comment was marked as outdated.

thrix

This comment was marked as outdated.

Copy link
Contributor

@thrix thrix left a comment

Choose a reason for hiding this comment

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

Code Review: Drop step-specific "base Click command" implementations

Reviewed against commit 3e49a3b.

Summary

Clean refactoring that consolidates 7 near-identical base_command() implementations (one per step plugin class) into a single shared implementation in BasePlugin. Removes ~220 lines of boilerplate. The shared version uses a new _step_class ClassVar backlink to derive the step name, and enhances --how to show available plugins as choices in the metavar.

Issues

1. Execute step gains PHASE_OPTIONS — functional change (medium)

The shared base_command() always applies @tmt.steps.PHASE_OPTIONS. However, the original execute step was the only step (out of 7) that did NOT use PHASE_OPTIONS. This means execute now gains --insert, --update, --update-missing, --allowed-how, --name, and --order CLI options it didn't have before. This contradicts the code | no functional change label. See inline comment.

2. Unrelated FileSystemPath/Package re-exports in tmt/steps/provision/__init__.py (minor)

These imports from tmt.package_managers are added as re-exports but nothing in the codebase imports them from tmt.steps.provision. Unrelated to the base_command refactoring. See inline comment.

Observations (no action needed)

  • The --how help text is now generic (f'Use specified method for {step_name} phase.') instead of step-specific (e.g., 'Use specified method for environment preparation.'). Minor wording change.
  • The --how metavar now lists available plugins (e.g., beaker|connect|container|local|virtual) instead of the generic METHOD. Nice improvement.
  • Removal of # type: ignore[type-abstract] in plan.py is correct — base_command was the only remaining abstract method in these plugin base classes, making them non-abstract now.
  • The module-level XPlugin._step_class = X assignments are well-documented and all 7 steps are covered.

Verdict

The refactoring is clean and correct. The main concern is issue #1 — the execute step gaining new CLI options should be acknowledged (and the no functional change label reconsidered) or handled explicitly.

Generated-by: Claude Code

context.obj.steps.add(step_name)
cls._step_class.store_cli_invocation(context)

return base_command
Copy link
Contributor

Choose a reason for hiding this comment

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

The shared implementation always applies @tmt.steps.PHASE_OPTIONS. However, the original execute step was the only step (out of 7) that did not have PHASE_OPTIONS — it only had --how. This means execute now gains --insert, --update, --update-missing, --allowed-how, --name, and --order CLI options it didn't have before.

This may be intentional and desirable (no obvious reason execute should lack them), but it's a functional change worth acknowledging — the PR is labeled code | no functional change.

Generated-by: Claude Code

Comment on lines +30 to +34
from tmt.package_managers import (
FileSystemPath as FileSystemPath,
)
from tmt.package_managers import (
Package as Package,
Copy link
Contributor

Choose a reason for hiding this comment

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

These FileSystemPath and Package re-exports are unrelated to the base_command refactoring — nothing currently imports them from tmt.steps.provision. Should this be in a separate commit or dropped?

Generated-by: Claude Code

@psss psss added this to the 1.70 milestone Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci | full test Pull request is ready for the full test execution code | cli Changes related to the command line interface code | no functional change "No Functional Change" intended. Patch should not change tmt's behavior in any way. code | style Code style changes not affecting functionality

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

5 participants