2
2
3
3
import os
4
4
from collections import OrderedDict , defaultdict
5
+ from itertools import chain
5
6
from pathlib import Path
6
- from typing import TYPE_CHECKING , Any , Iterator , Sequence , TypeVar
7
+ from typing import TYPE_CHECKING , Any , Iterable , Iterator , Sequence , TypeVar
7
8
8
9
from .sets import ConfigSet , CoreConfigSet , EnvConfigSet
9
10
22
23
class Config :
23
24
"""Main configuration object for tox."""
24
25
25
- def __init__ (
26
+ def __init__ ( # noqa: PLR0913 # <- no way around many args
26
27
self ,
27
28
config_source : Source ,
28
29
options : Parsed ,
29
30
root : Path ,
30
31
pos_args : Sequence [str ] | None ,
31
32
work_dir : Path ,
33
+ extra_envs : Iterable [str ],
32
34
) -> None :
33
35
self ._pos_args = None if pos_args is None else tuple (pos_args )
34
36
self ._work_dir = work_dir
35
37
self ._root = root
36
38
self ._options = options
39
+ self ._extra_envs = extra_envs
37
40
38
41
self ._overrides : OverrideMap = defaultdict (list )
39
42
for override in options .override :
@@ -78,7 +81,7 @@ def src_path(self) -> Path:
78
81
79
82
def __iter__ (self ) -> Iterator [str ]:
80
83
""":return: an iterator that goes through existing environments"""
81
- return self ._src .envs (self .core )
84
+ return chain ( self ._src .envs (self .core ), self . _extra_envs )
82
85
83
86
def sections (self ) -> Iterator [Section ]:
84
87
yield from self ._src .sections ()
@@ -91,7 +94,7 @@ def __contains__(self, item: str) -> bool:
91
94
return any (name for name in self if name == item )
92
95
93
96
@classmethod
94
- def make (cls , parsed : Parsed , pos_args : Sequence [str ] | None , source : Source ) -> Config :
97
+ def make (cls , parsed : Parsed , pos_args : Sequence [str ] | None , source : Source , extra_envs : Iterable [ str ] ) -> Config :
95
98
"""Make a tox configuration object."""
96
99
# root is the project root, where the configuration file is at
97
100
# work dir is where we put our own files
@@ -106,6 +109,7 @@ def make(cls, parsed: Parsed, pos_args: Sequence[str] | None, source: Source) ->
106
109
pos_args = pos_args ,
107
110
root = root ,
108
111
work_dir = work_dir ,
112
+ extra_envs = extra_envs ,
109
113
)
110
114
111
115
@property
0 commit comments