Skip to content

Commit

Permalink
🧩 Implement compatibility w/ GidgetHub v5.3+
Browse files Browse the repository at this point in the history
This patch bypasses the new `extra_headers` argument to the internal
GidgetHub helpers in its modern versions while passing nothing when
it's `None`.

Fixes #53.
  • Loading branch information
webknjaz committed Jun 17, 2023
1 parent e64d123 commit 20838c1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions octomachinery/github/api/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def _make_request(
jwt: Optional[str] = None,
oauth_token: Optional[str] = None,
content_type: str = JSON_CONTENT_TYPE,
extra_headers: Optional[Dict[str, str]] = None,
) -> Tuple[bytes, Optional[str]]:
token = self._token
# pylint: disable=fixme
Expand All @@ -67,6 +68,17 @@ async def _make_request(
if isinstance(token, GitHubJWTToken):
jwt = str(token)
oauth_token = None
optional_kwargs = {
# NOTE: GidgetHub v5.3.0 introduced a new `extra_headers` argument
# NOTE: in this private method and the public ones. Its default
# NOTE: value is `None` in all cases so the only case when it's set
# NOTE: is when the end-users call corresponding methods with it.
# NOTE: And that would only be the case with modern versions of
# NOTE: GidgetHub. Here, we rely on this side effect to only pass
# NOTE: this value down the stack when the chances that GidgetHub
# NOTE: is modern enough are close to 100%.
'extra_headers': extra_headers,
} if extra_headers is not None else {}
return await super()._make_request(
method=method,
url=url,
Expand All @@ -76,6 +88,7 @@ async def _make_request(
oauth_token=oauth_token,
jwt=jwt,
content_type=content_type,
**optional_kwargs,
)

getitem = accept_preview_version(GitHubAPI.getitem)
Expand Down

0 comments on commit 20838c1

Please sign in to comment.