diff --git a/dimo/dimo.py b/dimo/dimo.py index df77909..0d5d0fe 100644 --- a/dimo/dimo.py +++ b/dimo/dimo.py @@ -1,4 +1,3 @@ -from typing_extensions import Optional from requests import Session from .api.attestation import Attestation @@ -21,7 +20,9 @@ class DIMO: - def __init__(self, env: str = "Production", session: Optional[Session] = None) -> None: + def __init__( + self, env: str = "Production", session: Optional[Session] = None + ) -> None: self.env = env # Assert valid environment specified @@ -32,7 +33,9 @@ def __init__(self, env: str = "Production", session: Optional[Session] = None) - self._client_id: Optional[str] = None self._services: Dict[str, Any] = {} - self.session = session or Session() # Use the provided session or create a new one + self.session = ( + session or Session() + ) # Use the provided session or create a new one # Creates a full path for endpoints combining DIMO service, specific endpoint, and optional params def _get_full_path(self, service: str, path: str, params=None) -> str: diff --git a/dimo/errors.py b/dimo/errors.py index 9e427c7..5976b2b 100644 --- a/dimo/errors.py +++ b/dimo/errors.py @@ -30,3 +30,12 @@ def check_optional_type(param_name: str, value: Any, expected_type: Union[Type, class DimoValueError(DimoError): pass + + +class HTTPError(Exception): + """Http error wrapper with status code and (optional) response body""" + + def __init__(self, status: int, message: str, body: Any = None): + super().__init__(f"HTTP {status}: {message}") + self.status = status + self.body = body diff --git a/dimo/request.py b/dimo/request.py index 1bc6ad0..ff46527 100644 --- a/dimo/request.py +++ b/dimo/request.py @@ -1,15 +1,6 @@ import json -from typing import Any from requests import Session, RequestException - - -class HTTPError(Exception): - """Http error wrapper with status code and (optional) response body""" - - def __init__(self, status: int, message: str, body: Any = None): - super().__init__(f"HTTP {status}: {message}") - self.status = status - self.body = body +from .errors import HTTPError class Request: diff --git a/tests/test_request.py b/tests/test_request.py index b99c20e..d329900 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -3,7 +3,8 @@ from requests import RequestException from unittest.mock import Mock -from dimo.request import Request, HTTPError +from dimo.errors import HTTPError +from dimo.request import Request class DummyResponse: