From 5bfcd3ce29db2f0cbb5619de1be82612c34266d4 Mon Sep 17 00:00:00 2001 From: Ayush Arora Date: Sat, 12 Sep 2026 02:03:24 +0530 Subject: [PATCH] refactor(proxy): use dict comprehension and inline mutable-ok annotations for config models --- litellm/proxy/proxy_server.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 626c53a8327..481e4fb95fe 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -6443,12 +6443,14 @@ class ProxyConfig: added_count = 0 for model in config_models: try: - raw_litellm_params = copy.deepcopy(model.get("litellm_params", {})) - for k, v in raw_litellm_params.items(): - if isinstance(v, str) and v.startswith("os.environ/"): - raw_litellm_params[k] = get_secret(v) + raw_litellm_params = { # mutable-ok: resolved copy for router upsert + k: (get_secret(v) if isinstance(v, str) and v.startswith("os.environ/") else v) + for k, v in copy.deepcopy( + model.get("litellm_params") or dict() + ).items() # mutable-ok: safe fallback + } - model_info_dict = copy.deepcopy(model.get("model_info", {})) + model_info_dict = copy.deepcopy(model.get("model_info") or dict()) # mutable-ok: isolated info dict model_id = model_info_dict.get("id", None) if model_id is None: model_id = llm_router.generate_model_id(