The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(skills): collapse the pooled-else-fresh branches of _ssrf_safe_http_get
kshitijk4poor8f4db9396fec
diff --git a/tools/skills_hub.py b/tools/skills_hub.pyindex c1f71a7e847..430afe1481c 100644--- a/tools/skills_hub.py+++ b/tools/skills_hub.py@@ -15,7 +15,7 @@ import jsonimport loggingimport timefrom contextvars import ContextVar-from contextlib import ExitStack, contextmanager+from contextlib import ExitStack, contextmanager, nullcontextfrom datetime import datetime, timezonefrom pathlib import Pathfrom typing import Any, Dict, Iterator, List, Optional@@ -120,11 +120,13 @@ def _skills_hub_http_get(url: str, **kwargs: Any) -> httpx.Response:def _ssrf_safe_http_get(url: str, *, timeout: int = _DEFAULT_HTTP_TIMEOUT,headers: Optional[Dict[str, str]] = None) -> httpx.Response:"""Fetch one URL with connect-time SSRF validation and no automatic redirects."""- client = _skills_hub_http_client.get()- if client is not None:- return client.get(url, timeout=timeout, headers=headers)- with create_ssrf_safe_client(timeout=timeout, follow_redirects=False) as client:- return client.get(url, headers=headers)+ cm = (+ nullcontext(client)+ if (client := _skills_hub_http_client.get()) is not None+ else create_ssrf_safe_client(timeout=timeout, follow_redirects=False)+ )+ with cm as c:+ return c.get(url, timeout=timeout, headers=headers)def _guarded_http_get(url: str, *, timeout: int = 20,