22
22
23
23
import logging
24
24
25
+ from typing import TYPE_CHECKING
26
+
25
27
from molecule import util
26
28
27
29
30
+ if TYPE_CHECKING :
31
+ from molecule .scenario import Scenario
32
+
33
+
28
34
LOG = logging .getLogger (__name__ )
29
35
30
36
@@ -42,7 +48,7 @@ def __init__(self, configs, scenario_name=None) -> None: # type: ignore[no-unty
42
48
self ._scenario_name = scenario_name
43
49
self ._scenarios = self .all
44
50
45
- def next (self ): # type: ignore[no-untyped-def] # noqa: ANN201, D102
51
+ def next (self ) -> Scenario : # noqa: D102
46
52
if not self ._scenarios :
47
53
raise StopIteration
48
54
return self ._scenarios .pop (0 )
@@ -54,14 +60,14 @@ def __iter__(self): # type: ignore[no-untyped-def] # noqa: ANN204
54
60
__next__ = next # Python 3.X compatibility
55
61
56
62
@property
57
- def all (self ): # type: ignore[no-untyped-def] # noqa: ANN201
63
+ def all (self ) -> list [ Scenario ]:
58
64
"""Return a list containing all scenario objects.
59
65
60
66
Returns:
61
67
list
62
68
"""
63
69
if self ._scenario_name :
64
- scenarios = self ._filter_for_scenario () # type: ignore[no-untyped-call]
70
+ scenarios = self ._filter_for_scenario ()
65
71
self ._verify () # type: ignore[no-untyped-call]
66
72
67
73
return scenarios
@@ -70,7 +76,7 @@ def all(self): # type: ignore[no-untyped-def] # noqa: ANN201
70
76
scenarios .sort (key = lambda x : x .directory )
71
77
return scenarios
72
78
73
- def print_matrix (self ): # type: ignore[no-untyped-def] # noqa: ANN201, D102
79
+ def print_matrix (self ) -> None : # noqa: D102
74
80
msg = "Test matrix"
75
81
LOG .info (msg )
76
82
@@ -94,7 +100,7 @@ def _verify(self): # type: ignore[no-untyped-def] # noqa: ANN202
94
100
msg = f"Scenario '{ self ._scenario_name } ' not found. Exiting."
95
101
util .sysexit_with_message (msg )
96
102
97
- def _filter_for_scenario (self ): # type: ignore[no-untyped-def] # noqa: ANN202
103
+ def _filter_for_scenario (self ) -> list [ Scenario ]:
98
104
"""Find the scenario matching the provided scenario name and returns a list.
99
105
100
106
Returns:
0 commit comments