@@ -24,6 +24,12 @@ def __init__(self, value: str) -> None:
24
24
if not equal :
25
25
msg = f"override { value } has no = sign in it"
26
26
raise ArgumentTypeError (msg )
27
+
28
+ self .append = False
29
+ if key .endswith ("+" ): # key += value appends to a list
30
+ key = key [:- 1 ]
31
+ self .append = True
32
+
27
33
self .namespace , _ , self .key = key .rpartition ("." )
28
34
29
35
def __repr__ (self ) -> str :
@@ -117,10 +123,25 @@ def load( # noqa: PLR0913
117
123
:param args: the config load arguments
118
124
:return: the converted type
119
125
"""
120
- if key in self .overrides :
121
- return _STR_CONVERT .to (self .overrides [key ].value , of_type , factory )
126
+ from tox .config .set_env import SetEnv
127
+
128
+ override = self .overrides .get (key )
129
+ if override and not override .append :
130
+ return _STR_CONVERT .to (override .value , of_type , factory )
122
131
raw = self .load_raw (key , conf , args .env_name )
123
- return self .build (key , of_type , factory , conf , raw , args )
132
+ converted = self .build (key , of_type , factory , conf , raw , args )
133
+ if override and override .append :
134
+ appends = _STR_CONVERT .to (override .value , of_type , factory )
135
+ if isinstance (converted , list ) and isinstance (appends , list ):
136
+ converted += appends
137
+ elif isinstance (converted , dict ) and isinstance (appends , dict ):
138
+ converted .update (appends )
139
+ elif isinstance (converted , SetEnv ) and isinstance (appends , SetEnv ):
140
+ converted .update (appends , override = True )
141
+ else :
142
+ msg = "Only able to append to lists and dicts"
143
+ raise ValueError (msg )
144
+ return converted
124
145
125
146
def build ( # noqa: PLR0913
126
147
self ,
0 commit comments