From 5eb26efef4066df65f5b84b10cb805ebcbd645ec Mon Sep 17 00:00:00 2001 From: Dayanne Fernandes Date: Tue, 6 Aug 2024 20:37:43 -0300 Subject: [PATCH] mypy --- pyproject.toml | 2 -- vision_agent/clients/http.py | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e56d77de..e4da9ca6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,8 +79,6 @@ line_length = 88 profile = "black" [tool.mypy] -plugins = ["pydantic.mypy"] - exclude = "tests" show_error_context = true pretty = true diff --git a/vision_agent/clients/http.py b/vision_agent/clients/http.py index a041952f..678148a9 100644 --- a/vision_agent/clients/http.py +++ b/vision_agent/clients/http.py @@ -23,12 +23,12 @@ def __init__( } self._base_endpoint = base_endpoint self._session = Session() - self._session.headers.update(self._headers) + self._session.headers.update(self._headers) # type: ignore self._session.mount( self._base_endpoint, HTTPAdapter(max_retries=self._MAX_RETRIES) ) - def post(self, url: str, payload: Dict[str, Any]) -> None: + def post(self, url: str, payload: Dict[str, Any]) -> Dict[str, Any]: formatted_url = f"{self._base_endpoint}/{url}" _LOGGER.info(f"Sending data to {formatted_url}") try: @@ -36,9 +36,11 @@ def post(self, url: str, payload: Dict[str, Any]) -> None: url=formatted_url, json=payload, timeout=self._TIMEOUT ) response.raise_for_status() - _LOGGER.info(json.dumps(response.json())) + result: Dict[str, Any] = response.json() + _LOGGER.info(json.dumps(result)) except (ConnectionError, Timeout, RequestException) as err: _LOGGER.warning(f"Error: {err}.") except json.JSONDecodeError: resp_text = response.text _LOGGER.warning(f"Response seems incorrect: '{resp_text}'.") + return result