ignore unknown env overrides

This commit is contained in:
Casper da Costa-Luis 2023-08-05 22:22:32 +01:00
parent 52d78121b1
commit 783bd6e070
No known key found for this signature in database
GPG Key ID: F5126E5FBD2512AD
1 changed files with 8 additions and 7 deletions

View File

@ -75,13 +75,14 @@ def envwrap(prefix, case_sensitive=False, literal_eval=False, is_method=False):
# use `func` signature to infer env override `type` (fallback to `str`)
params = signature(func).parameters
for k in overrides:
param = params[k]
if param.annotation is not param.empty:
typ = param.annotation
# TODO: parse type in {Union, Any, Optional, ...}
else:
typ = str if param.default is None else type(param.default)
overrides[k] = typ(overrides[k])
param = params.get(k, None)
if param is not None:
if param.annotation is not param.empty:
typ = param.annotation
# TODO: parse type in {Union, Any, Optional, ...}
else:
typ = str if param.default is None else type(param.default)
overrides[k] = typ(overrides[k])
return part(func, **overrides)
return wrap