diff --git a/zhenxun/utils/http_utils.py b/zhenxun/utils/http_utils.py index f31dac14..9df95112 100644 --- a/zhenxun/utils/http_utils.py +++ b/zhenxun/utils/http_utils.py @@ -37,17 +37,12 @@ def get_async_client(proxies=None, **kwargs): try: return httpx.AsyncClient(proxies=proxies, **kwargs) except TypeError: - return httpx.AsyncClient( - mounts={ - "http://": httpx.AsyncHTTPTransport(proxy=proxies.get("http")) - if proxies - else None, - "https://": httpx.AsyncHTTPTransport(proxy=proxies.get("https")) - if proxies - else None, - }, - **kwargs, - ) + return httpx.AsyncClient(mounts={ + k: v for k, v in { + "http://": httpx.AsyncHTTPTransport(proxy=proxies.get("http")) if proxies else None, + "https://": httpx.AsyncHTTPTransport(proxy=proxies.get("https")) if proxies else None + }.items() if v is not None + }, **kwargs) class AsyncHttpx: