diff --git a/campus_python/json_client/__init__.py b/campus_python/json_client/__init__.py index 3797fae..46d4ce5 100644 --- a/campus_python/json_client/__init__.py +++ b/campus_python/json_client/__init__.py @@ -13,10 +13,17 @@ from collections.abc import Callable from typing import Any, Mapping, Self, cast -import campus.model import requests from campus.common import env +try: + from campus.webauth.models import HttpHeader +except ImportError: + # campus-suite predating campus#857 keeps header models in + # campus.model; this fallback lets this client work against both + # the old and the new campus-suite until locks are re-resolved. + from campus.model import HttpHeader + from .. import errors from .interface import JsonClient, JsonDict, JsonResponse @@ -47,7 +54,7 @@ def text(self) -> str: def json(self) -> Any: try: return self._response.json() - except ValueError as exc: # JSON decoding error + except ValueError: # JSON decoding error raise errors.MalformedResponseError( error_description="Response is not valid JSON" ) from None @@ -108,10 +115,10 @@ def __init__( self.reset_authorization() @property - def headers(self) -> campus.model.HttpHeader: + def headers(self) -> HttpHeader: """Get the currently configured headers.""" headers = cast(Mapping[str, str], self._session.headers) - return campus.model.HttpHeader.from_header(headers) + return HttpHeader.from_header(headers) def _build_url(self, path: str) -> str: if not self.base_url: # relative URL