Skip to content

Commit

Permalink
Merge branch 'main' into drop-38
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelizimm authored Dec 16, 2024
2 parents 7002e10 + b36328e commit 5a77a84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pins/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections.abc import Mapping, Sequence
from dataclasses import InitVar, asdict, dataclass, field, fields
from pathlib import Path
from typing import ClassVar
from typing import Any, ClassVar

import yaml

Expand Down Expand Up @@ -105,7 +105,7 @@ def __getattr__(self, k):
except KeyError:
raise AttributeError(f"No metadata field not found: {k}")

def to_dict(self) -> Mapping:
def to_dict(self) -> dict[str, Any]:
data = asdict(self)

return data
Expand Down
15 changes: 12 additions & 3 deletions pins/rsconnect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from functools import partial
from io import IOBase
from pathlib import Path
from typing import Generic, TypeVar
from typing import Generic, Literal, TypeVar, overload
from urllib.parse import urlencode

import requests
Expand Down Expand Up @@ -215,7 +215,15 @@ def query(self, route, method="GET", return_request=False, **kwargs):

return self._raw_query(endpoint, method, return_request, **kwargs)

def _raw_query(self, url, method="GET", return_request=False, **kwargs):
@overload
def _raw_query(
self, url, method, return_request: Literal[True], **kwargs
) -> requests.Response: ...
@overload
def _raw_query(
self, url, method, return_request: Literal[False], **kwargs
) -> dict | list: ...
def _raw_query(self, url, method="GET", return_request: bool = False, **kwargs):
if "headers" in kwargs:
raise KeyError("cannot specify headers param in kwargs")

Expand All @@ -234,8 +242,9 @@ def _raw_query(self, url, method="GET", return_request=False, **kwargs):
data = r.json()
self._validate_json_response(data)
return data
except requests.JSONDecodeError:
except requests.JSONDecodeError as err:
r.raise_for_status()
raise err # Fallback if somehow there was no HTTPError

def walk_paginated_offsets(self, f_query, endpoint, method, params=None, **kwargs):
if params is None:
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ reportArgumentType = false
reportAttributeAccessIssue = false
reportCallIssue = false
reportIncompatibleMethodOverride = false
reportIndexIssue = false
reportMissingImports = false
reportMissingTypeStubs = false
reportOptionalIterable = false
reportOptionalMemberAccess = false
reportOptionalSubscript = false
reportPossiblyUnboundVariable = false
Expand Down

0 comments on commit 5a77a84

Please sign in to comment.