22
33import os
44from collections import OrderedDict , defaultdict
5+ from itertools import chain
56from pathlib import Path
6- from typing import TYPE_CHECKING , Any , Iterator , Sequence , TypeVar
7+ from typing import TYPE_CHECKING , Any , Iterable , Iterator , Sequence , TypeVar
78
89from .sets import ConfigSet , CoreConfigSet , EnvConfigSet
910
2223class Config :
2324 """Main configuration object for tox."""
2425
25- def __init__ (
26+ def __init__ ( # noqa: PLR0913 # <- no way around many args
2627 self ,
2728 config_source : Source ,
2829 options : Parsed ,
2930 root : Path ,
3031 pos_args : Sequence [str ] | None ,
3132 work_dir : Path ,
33+ extra_envs : Iterable [str ],
3234 ) -> None :
3335 self ._pos_args = None if pos_args is None else tuple (pos_args )
3436 self ._work_dir = work_dir
3537 self ._root = root
3638 self ._options = options
39+ self ._extra_envs = extra_envs
3740
3841 self ._overrides : OverrideMap = defaultdict (list )
3942 for override in options .override :
@@ -78,7 +81,7 @@ def src_path(self) -> Path:
7881
7982 def __iter__ (self ) -> Iterator [str ]:
8083 """: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 )
8285
8386 def sections (self ) -> Iterator [Section ]:
8487 yield from self ._src .sections ()
@@ -91,7 +94,7 @@ def __contains__(self, item: str) -> bool:
9194 return any (name for name in self if name == item )
9295
9396 @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 :
9598 """Make a tox configuration object."""
9699 # root is the project root, where the configuration file is at
97100 # 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) ->
106109 pos_args = pos_args ,
107110 root = root ,
108111 work_dir = work_dir ,
112+ extra_envs = extra_envs ,
109113 )
110114
111115 @property
0 commit comments