@@ -80,7 +80,7 @@ class Loader(Convert[T]):
80
80
81
81
def __init__ (self , section : Section , overrides : list [Override ]) -> None :
82
82
self ._section = section
83
- self .overrides = {o .key : o for o in overrides }
83
+ self .overrides : dict [ str , Override ] = {o .key : o for o in overrides }
84
84
self .parent : Loader [Any ] | None = None
85
85
86
86
@property
@@ -130,18 +130,24 @@ def load( # noqa: PLR0913
130
130
from tox .config .set_env import SetEnv
131
131
132
132
override = self .overrides .get (key )
133
- if override and not override .append :
134
- return _STR_CONVERT .to (override .value , of_type , factory )
135
- raw = self .load_raw (key , conf , args .env_name )
133
+ if override :
134
+ converted_override = _STR_CONVERT .to (override .value , of_type , factory )
135
+ if not override .append :
136
+ return converted_override
137
+ try :
138
+ raw = self .load_raw (key , conf , args .env_name )
139
+ except KeyError :
140
+ if override :
141
+ return converted_override
142
+ raise
136
143
converted = self .build (key , of_type , factory , conf , raw , args )
137
144
if override and override .append :
138
- appends = _STR_CONVERT .to (override .value , of_type , factory )
139
- if isinstance (converted , list ) and isinstance (appends , list ):
140
- converted += appends
141
- elif isinstance (converted , dict ) and isinstance (appends , dict ):
142
- converted .update (appends )
143
- elif isinstance (converted , SetEnv ) and isinstance (appends , SetEnv ):
144
- converted .update (appends , override = True )
145
+ if isinstance (converted , list ) and isinstance (converted_override , list ):
146
+ converted += converted_override
147
+ elif isinstance (converted , dict ) and isinstance (converted_override , dict ):
148
+ converted .update (converted_override )
149
+ elif isinstance (converted , SetEnv ) and isinstance (converted_override , SetEnv ):
150
+ converted .update (converted_override , override = True )
145
151
else :
146
152
msg = "Only able to append to lists and dicts"
147
153
raise ValueError (msg )
0 commit comments