From 783bd6e07009bfe873701abd96671df561bdbba2 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 5 Aug 2023 22:22:32 +0100 Subject: [PATCH] ignore unknown env overrides --- tqdm/utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tqdm/utils.py b/tqdm/utils.py index 93f635ad..b2ab9738 100644 --- a/tqdm/utils.py +++ b/tqdm/utils.py @@ -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