Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions campus_python/json_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading