From e45a37bfef5470069dbb9fad56685553cfd5a820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Wed, 8 Apr 2026 18:29:21 +0200 Subject: [PATCH 1/2] Remove the `Execute.discover` setter dead code The setter was never used and causes just another confusion. Do not override the return type and include usage explanation. This is just one little step to make this area less confusing. --- tmt/steps/execute/__init__.py | 18 ++++++++++-------- tmt/steps/execute/upgrade.py | 14 ++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tmt/steps/execute/__init__.py b/tmt/steps/execute/__init__.py index d15f7eb387..598805aa4d 100644 --- a/tmt/steps/execute/__init__.py +++ b/tmt/steps/execute/__init__.py @@ -34,7 +34,7 @@ from tmt.steps.context.reboot import RebootContext from tmt.steps.context.restart import RestartContext from tmt.steps.context.restraint import RestraintContext -from tmt.steps.discover import Discover, DiscoverPlugin, DiscoverStepData +from tmt.steps.discover import Discover from tmt.utils import ( Command, CommandOutput, @@ -54,6 +54,7 @@ import tmt.base.plan import tmt.result import tmt.steps.discover + from tmt.steps.discover.fmf import DiscoverFmf # Test data and checks directory names TEST_DATA = 'data' @@ -694,18 +695,19 @@ def go( logger.verbose('exit-first', self.data.exit_first, 'green', level=2) @property - def discover(self) -> Discover: + def discover(self) -> Union[Discover, 'DiscoverFmf']: """ - Return discover plugin instance + Return discover step or discover plugin instance + + This is used for iterating over discovered tests and setting the + workdir. During the upgrade phase of the upgrade plugin it + returns instance of DiscoverFmf with upgrade tasks. + + FIXME: Find a way how to handle this more cleanly. """ - # This is necessary so that upgrade plugin can inject a fake discover return self.step.plan.discover - @discover.setter - def discover(self, plugin: Optional[DiscoverPlugin[DiscoverStepData]]) -> None: - self._discover = plugin - def prepare_tests(self, guest: Guest, logger: tmt.log.Logger) -> list[TestInvocation]: """ Prepare discovered tests for testing diff --git a/tmt/steps/execute/upgrade.py b/tmt/steps/execute/upgrade.py index 005a90a7d4..17aa80063b 100644 --- a/tmt/steps/execute/upgrade.py +++ b/tmt/steps/execute/upgrade.py @@ -236,21 +236,19 @@ def __init__(self, **kwargs: Any) -> None: super().__init__(**kwargs) self._discover_upgrade: Optional[DiscoverFmf] = None - @property # type:ignore[override] + @property def discover(self) -> Union[Discover, DiscoverFmf]: """ - Return discover plugin instance + Return discover step or discover plugin instance + + If we are in the second phase (upgrade), take tests from our + fake discover plugin. """ - # If we are in the second phase (upgrade), take tests from our fake - # discover plugin. if self._discover_upgrade: return self._discover_upgrade - return self.step.plan.discover - @discover.setter - def discover(self, plugin: Optional[DiscoverPlugin[DiscoverStepData]]) -> None: - self._discover = plugin + return self.step.plan.discover @property def tasks( From ba2337816cde83d74b8a9e94591c85554ecfa6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Prchl=C3=ADk?= Date: Thu, 9 Apr 2026 18:54:35 +0200 Subject: [PATCH 2/2] squash: return missing import --- tmt/steps/execute/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmt/steps/execute/__init__.py b/tmt/steps/execute/__init__.py index 598805aa4d..cbde36a79a 100644 --- a/tmt/steps/execute/__init__.py +++ b/tmt/steps/execute/__init__.py @@ -34,7 +34,7 @@ from tmt.steps.context.reboot import RebootContext from tmt.steps.context.restart import RestartContext from tmt.steps.context.restraint import RestraintContext -from tmt.steps.discover import Discover +from tmt.steps.discover import Discover, DiscoverPlugin from tmt.utils import ( Command, CommandOutput,