Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dayof committed Aug 6, 2024
1 parent 630eff3 commit 5eb26ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ line_length = 88
profile = "black"

[tool.mypy]
plugins = ["pydantic.mypy"]

exclude = "tests"
show_error_context = true
pretty = true
Expand Down
8 changes: 5 additions & 3 deletions vision_agent/clients/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ 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:
response = self._session.post(
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

0 comments on commit 5eb26ef

Please sign in to comment.