1
0
mirror of https://github.com/ijaric/voice_assistant.git synced 2025-05-24 06:23:28 +00:00

feat: [#47] http_client proxy may not be passed

This commit is contained in:
ksieuk 2023-10-13 15:01:30 +03:00
parent 4b28117055
commit eca38ebe25

View File

@ -8,7 +8,7 @@ import lib.app.split_settings as app_split_settings
class AsyncHttpClient(httpx.AsyncClient):
def __init__(
self,
proxy_settings: app_split_settings.ProxySettings,
proxy_settings: app_split_settings.ProxySettings | None = None,
base_url: str | None = None,
**client_params: typing.Any,
) -> None:
@ -20,7 +20,7 @@ class AsyncHttpClient(httpx.AsyncClient):
super().__init__(base_url=self.base_url, proxies=self.proxies, **client_params) # type: ignore[reportGeneralTypeIssues]
def __get_proxies_from_settings(self) -> dict[str, str] | None:
if not self.proxy_settings.enable:
if not self.proxy_settings or not self.proxy_settings.enable:
return None
proxies = {"all://": self.proxy_settings.dsn}
return proxies