From 5731b70db3420356472d3e711be8aaa7c618f3d9 Mon Sep 17 00:00:00 2001 From: fderuiter <127706008+fderuiter@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:48:43 +0000 Subject: [PATCH 1/3] Fix outdated references to imednet.core.exceptions module Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- Makefile | 2 +- docs/api_overview.rst | 12 ++++++------ docs/imednet.core.rst | 9 +-------- docs/quick_start.rst | 2 +- docs/retry_policy.rst | 4 ++-- docs/schema_validation.rst | 2 +- examples/custom_retry.py | 9 +++++---- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 44199243..a6f3f70b 100644 --- a/Makefile +++ b/Makefile @@ -3,5 +3,5 @@ docs: poetry install --with dev poetry run sphinx-apidoc -o docs src/imednet \ - src/imednet/core/__init__.py src/imednet/models/base.py + src/imednet/errors/__init__.py src/imednet/models/base.py poetry run sphinx-build -b html --keep-going docs docs/_build/html diff --git a/docs/api_overview.rst b/docs/api_overview.rst index 538d1ba6..8020b81f 100644 --- a/docs/api_overview.rst +++ b/docs/api_overview.rst @@ -29,12 +29,12 @@ HTTP methods and errors The API primarily supports ``GET`` and ``POST`` requests. Non‐successful status codes raise typed exceptions: -* ``400`` – :class:`~imednet.core.exceptions.ValidationError` -* ``401`` – :class:`~imednet.core.exceptions.AuthenticationError` -* ``403`` – :class:`~imednet.core.exceptions.AuthorizationError` -* ``404`` – :class:`~imednet.core.exceptions.NotFoundError` -* ``429`` – :class:`~imednet.core.exceptions.RateLimitError` -* ``5xx`` – :class:`~imednet.core.exceptions.ServerError` +* ``400`` – :class:`~imednet.errors.ValidationError` +* ``401`` – :class:`~imednet.errors.AuthenticationError` +* ``403`` – :class:`~imednet.errors.AuthorizationError` +* ``404`` – :class:`~imednet.errors.NotFoundError` +* ``429`` – :class:`~imednet.errors.RateLimitError` +* ``5xx`` – :class:`~imednet.errors.ServerError` See :doc:`retry_policy` for examples of handling these errors and configuring custom retry logic. diff --git a/docs/imednet.core.rst b/docs/imednet.core.rst index 40790e7e..4443ad75 100644 --- a/docs/imednet.core.rst +++ b/docs/imednet.core.rst @@ -59,13 +59,6 @@ HTTPX requests used by the SDK: :show-inheritance: :noindex: -imednet.core.exceptions module ------------------------------- - -.. automodule:: imednet.core.exceptions - :members: - :undoc-members: - :show-inheritance: imednet.core.paginator module ----------------------------- @@ -87,7 +80,7 @@ requests should be retried. The SDK uses from imednet.core.client import Client from imednet.core.retry import RetryPolicy, RetryState - from imednet.core.exceptions import ServerError + from imednet.errors import ServerError class ServerRetry(RetryPolicy): def should_retry(self, state: RetryState) -> bool: diff --git a/docs/quick_start.rst b/docs/quick_start.rst index 820b58d7..e2863449 100644 --- a/docs/quick_start.rst +++ b/docs/quick_start.rst @@ -47,7 +47,7 @@ Custom retry logic can be provided via a ``RetryPolicy``: .. code-block:: python from imednet.core.retry import RetryPolicy, RetryState - from imednet.core.exceptions import ServerError + from imednet.errors import ServerError class ServerRetry(RetryPolicy): def should_retry(self, state: RetryState) -> bool: diff --git a/docs/retry_policy.rst b/docs/retry_policy.rst index 2a060b32..97ea02b4 100644 --- a/docs/retry_policy.rst +++ b/docs/retry_policy.rst @@ -13,7 +13,7 @@ Use typed exceptions to respond to different failure modes: .. code-block:: python from imednet import ImednetSDK - from imednet.core.exceptions import RateLimitError, ServerError, NotFoundError + from imednet.errors import RateLimitError, ServerError, NotFoundError sdk = ImednetSDK() try: @@ -35,7 +35,7 @@ Retry policies decide if a request should be retried. To retry on from imednet.core.client import Client from imednet.core.retry import RetryPolicy, RetryState - from imednet.core.exceptions import RateLimitError, ServerError + from imednet.errors import RateLimitError, ServerError class RateLimitServerRetry(RetryPolicy): def should_retry(self, state: RetryState) -> bool: diff --git a/docs/schema_validation.rst b/docs/schema_validation.rst index 3c4a3358..118fbfb3 100644 --- a/docs/schema_validation.rst +++ b/docs/schema_validation.rst @@ -7,7 +7,7 @@ submitting it to the API. The validator checks that all variables exist, required fields are present, and that values match the expected types. If the variable metadata for a form is missing, ``SchemaValidator`` automatically loads it from the API using :class:`~imednet.endpoints.variables.VariablesEndpoint`. -Any problems raise :class:`~imednet.core.exceptions.ValidationError` before the +Any problems raise :class:`~imednet.errors.ValidationError` before the record is sent to the server. ``SchemaValidator`` works with both synchronous and asynchronous SDK clients. diff --git a/examples/custom_retry.py b/examples/custom_retry.py index 64f15288..14ef65fa 100644 --- a/examples/custom_retry.py +++ b/examples/custom_retry.py @@ -7,7 +7,7 @@ import httpx from imednet.core.client import Client -from imednet.core.exceptions import RateLimitError, ServerError +from imednet.errors import RateLimitError, ServerError from imednet.core.retry import RetryPolicy, RetryState from imednet.utils import configure_json_logging @@ -48,15 +48,16 @@ def responder(_: httpx.Request) -> httpx.Response: return next(responses) +from imednet.auth.strategy import AuthStrategy + class MockClient(Client): - def _create_client(self, api_key: str, security_key: str) -> httpx.Client: # type: ignore[override] + def _create_client(self, auth: AuthStrategy) -> httpx.Client: # type: ignore[override] return httpx.Client( base_url=self.base_url, headers={ "Accept": "application/json", "Content-Type": "application/json", - "x-api-key": api_key, - "x-imn-security-key": security_key, + **auth.get_headers(), }, timeout=self.timeout, transport=httpx.MockTransport(responder), From 12a997bf8afe6d9921999ea899205090e2a186cc Mon Sep 17 00:00:00 2001 From: fderuiter <127706008+fderuiter@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:51:57 +0000 Subject: [PATCH 2/3] Fix formatting in examples/custom_retry.py Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- examples/custom_retry.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/custom_retry.py b/examples/custom_retry.py index 14ef65fa..418c7635 100644 --- a/examples/custom_retry.py +++ b/examples/custom_retry.py @@ -7,8 +7,8 @@ import httpx from imednet.core.client import Client -from imednet.errors import RateLimitError, ServerError from imednet.core.retry import RetryPolicy, RetryState +from imednet.errors import RateLimitError, ServerError from imednet.utils import configure_json_logging """Demonstrate custom retry logic with simulated rate limit and server errors. @@ -50,6 +50,7 @@ def responder(_: httpx.Request) -> httpx.Response: from imednet.auth.strategy import AuthStrategy + class MockClient(Client): def _create_client(self, auth: AuthStrategy) -> httpx.Client: # type: ignore[override] return httpx.Client( From fcc2c3f48f4c806b6e08cd8de1a42dc752fb8a29 Mon Sep 17 00:00:00 2001 From: fderuiter <127706008+fderuiter@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:54:40 +0000 Subject: [PATCH 3/3] Fix ruff E402 module level import error in examples/custom_retry.py Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- examples/custom_retry.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/custom_retry.py b/examples/custom_retry.py index 418c7635..ff7ba241 100644 --- a/examples/custom_retry.py +++ b/examples/custom_retry.py @@ -6,6 +6,7 @@ import httpx +from imednet.auth.strategy import AuthStrategy from imednet.core.client import Client from imednet.core.retry import RetryPolicy, RetryState from imednet.errors import RateLimitError, ServerError @@ -48,9 +49,6 @@ def responder(_: httpx.Request) -> httpx.Response: return next(responses) -from imednet.auth.strategy import AuthStrategy - - class MockClient(Client): def _create_client(self, auth: AuthStrategy) -> httpx.Client: # type: ignore[override] return httpx.Client(