6
6
from tox .config .loader .replacer import MatchRecursionError , ReplaceReference , load_posargs , replace , replace_env
7
7
from tox .config .loader .stringify import stringify
8
8
9
- from ._api import TomlTypes
10
9
from ._validate import validate
11
10
12
11
if TYPE_CHECKING :
16
15
from tox .config .sets import ConfigSet
17
16
from tox .config .source .toml_pyproject import TomlSection
18
17
18
+ from ._api import TomlTypes
19
+
19
20
20
21
class Unroll :
21
22
def __init__ (self , conf : Config | None , loader : TomlLoader , args : ConfigLoadArgs ) -> None :
@@ -39,7 +40,7 @@ def __call__(self, value: TomlTypes, depth: int = 0) -> TomlTypes: # noqa: C901
39
40
for val in value : # apply replacement for every entry
40
41
got = self (val , depth )
41
42
if isinstance (val , dict ) and val .get ("replace" ) and val .get ("extend" ):
42
- res_list .extend (cast (List [Any ], got ))
43
+ res_list .extend (cast (" List[Any]" , got ))
43
44
else :
44
45
res_list .append (got )
45
46
value = res_list
@@ -49,16 +50,16 @@ def __call__(self, value: TomlTypes, depth: int = 0) -> TomlTypes: # noqa: C901
49
50
if replace_type == "posargs" and self .conf is not None :
50
51
got_posargs = load_posargs (self .conf , self .args )
51
52
return (
52
- [self (v , depth ) for v in cast (List [str ], value .get ("default" , []))]
53
+ [self (v , depth ) for v in cast (" List[str]" , value .get ("default" , []))]
53
54
if got_posargs is None
54
55
else list (got_posargs )
55
56
)
56
57
if replace_type == "env" :
57
58
return replace_env (
58
59
self .conf ,
59
60
[
60
- cast (str , validate (value ["name" ], str )),
61
- cast (str , validate (self (value .get ("default" , "" ), depth ), str )),
61
+ cast (" str" , validate (value ["name" ], str )),
62
+ cast (" str" , validate (self (value .get ("default" , "" ), depth ), str )),
62
63
],
63
64
self .args ,
64
65
)
@@ -73,9 +74,9 @@ def __call__(self, value: TomlTypes, depth: int = 0) -> TomlTypes: # noqa: C901
73
74
74
75
def _replace_ref (self , value : dict [str , TomlTypes ], depth : int ) -> TomlTypes :
75
76
if self .conf is not None and (env := value .get ("env" )) and (key := value .get ("key" )):
76
- return cast (TomlTypes , self .conf .get_env (cast (str , env ))[cast (str , key )])
77
+ return cast (" TomlTypes" , self .conf .get_env (cast (" str" , env ))[cast (" str" , key )])
77
78
if of := value .get ("of" ):
78
- validated_of = cast (List [str ], validate (of , List [str ]))
79
+ validated_of = cast (" List[str]" , validate (of , List [str ]))
79
80
loaded = self .loader .load_raw_from_root (self .loader .section .SEP .join (validated_of ))
80
81
return self (loaded , depth )
81
82
return value
0 commit comments