Skip to content

Commit bd3c18f

Browse files
happztherazix
authored andcommitted
squash: address comments
1 parent 408ceba commit bd3c18f

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

tmt/result.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import enum
2-
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, cast
2+
from typing import (
3+
TYPE_CHECKING,
4+
Any,
5+
Callable,
6+
Optional,
7+
SupportsIndex,
8+
TypeVar,
9+
Union,
10+
cast,
11+
overload,
12+
)
313

414
import fmf.utils
515

@@ -536,6 +546,26 @@ class Results(list[ResultT]):
536546
the collection as a whole.
537547
"""
538548

549+
@overload
550+
def __getitem__(self, i: SupportsIndex) -> ResultT:
551+
pass
552+
553+
@overload
554+
def __getitem__(self, i: slice) -> 'Results[ResultT]':
555+
pass
556+
557+
def __getitem__(self, i: Union[SupportsIndex, slice]) -> Union[ResultT, 'Results[ResultT]']:
558+
if isinstance(i, slice):
559+
return Results(super().__getitem__(i))
560+
561+
return super().__getitem__(i)
562+
563+
def __add__(self, other: 'Results[ResultT]') -> 'Results[ResultT]': # type: ignore[override]
564+
return Results(super().__add__(other))
565+
566+
def copy(self) -> 'Results[ResultT]':
567+
return Results(super().copy())
568+
539569
def total(self) -> dict[ResultOutcome, int]:
540570
"""
541571
Return dictionary with total stats.

tmt/steps/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ def _load_results(
10051005
self,
10061006
result_class: type[ResultT],
10071007
allow_missing: bool = False,
1008-
) -> tmt.result.Results[ResultT]:
1008+
) -> Results[ResultT]:
10091009
"""
10101010
Load results of this step from the workdir
10111011
"""

tmt/steps/execute/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def prepare_tests(self, guest: Guest, logger: tmt.log.Logger) -> list[TestInvoca
767767
if self.should_run_again:
768768
assert self.parent is not None # narrow type
769769
assert isinstance(self.parent, Execute) # narrow type
770-
self.parent._old_results = Results(self.parent._results[:])
770+
self.parent._old_results = self.parent._results.copy()
771771
self.parent._results.clear()
772772

773773
return invocations
@@ -1342,7 +1342,7 @@ def go(self, force: bool = False) -> None:
13421342

13431343
self._assert_required_tests_executed()
13441344

1345-
def results(self) -> 'tmt.result.Results[tmt.result.Result]':
1345+
def results(self) -> Results[Result]:
13461346
"""
13471347
Results from executed tests
13481348

0 commit comments

Comments
 (0)