Skip to content

Commit

Permalink
Merge pull request #100 from smkent/manage-cookie
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
smkent authored Nov 1, 2023
2 parents 479d634 + a2db731 commit 8359b85
Show file tree
Hide file tree
Showing 5 changed files with 694 additions and 718 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-merge-conflict
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.10.1
hooks:
- id: black
args: ["--config", "pyproject.toml"]
Expand All @@ -18,14 +18,14 @@ repos:
- id: isort
args: ["--show-config"]
- repo: https://github.com/pycqa/bandit
rev: 1.7.4
rev: 1.7.5
hooks:
- id: bandit
additional_dependencies: ['.[toml]']
args: ["--configfile", "pyproject.toml"]
exclude: '^tests/'
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -34,11 +34,11 @@ repos:
- flake8-simplify
- pep8-naming
- repo: https://github.com/pycqa/autoflake
rev: v2.0.1
rev: v2.2.1
hooks:
- id: autoflake
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--keep-runtime-typing"]
Expand Down
12 changes: 10 additions & 2 deletions jmapc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
RequestsAuth = Union[requests.auth.AuthBase, Tuple[str, str]]
ClientType = TypeVar("ClientType", bound="Client")

REQUEST_TIMEOUT = 30


@dataclass
class EventSourceConfig:
Expand Down Expand Up @@ -122,7 +124,9 @@ def requests_session(self) -> requests.Session:

@functools.cached_property
def jmap_session(self) -> Session:
r = self.requests_session.get(f"https://{self._host}/.well-known/jmap")
r = self.requests_session.get(
f"https://{self._host}/.well-known/jmap", timeout=REQUEST_TIMEOUT
)
r.raise_for_status()
session = Session.from_dict(r.json())
log.debug(f"Retrieved JMAP session with state {session.state}")
Expand Down Expand Up @@ -150,6 +154,7 @@ def upload_blob(self, file_name: Union[str, Path]) -> Blob:
stream=True,
data=f,
headers={"Content-Type": mime_type},
timeout=REQUEST_TIMEOUT,
)
r.raise_for_status()
return Blob.from_dict(r.json())
Expand All @@ -168,7 +173,9 @@ def download_attachment(
name=attachment.name,
type=attachment.type,
)
r = self.requests_session.get(blob_url, stream=True)
r = self.requests_session.get(
blob_url, stream=True, timeout=REQUEST_TIMEOUT
)
r.raise_for_status()
with open(file_name, "wb") as f:
f.write(r.raw.data)
Expand Down Expand Up @@ -287,6 +294,7 @@ def _api_request(
self.jmap_session.api_url,
headers={"Content-Type": "application/json"},
data=raw_request,
timeout=REQUEST_TIMEOUT,
)
r.raise_for_status()
log.debug(f"Received JMAP response {r.text}")
Expand Down
2 changes: 1 addition & 1 deletion jmapc/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Model(dataclasses_json.DataClassJsonMixin):
dataclass_json_config = dataclasses_json.config(
letter_case=dataclasses_json.LetterCase.CAMEL, # type: ignore
undefined=dataclasses_json.Undefined.EXCLUDE,
exclude=lambda f: f is None, # type: ignore
exclude=lambda f: f is None,
)["dataclasses_json"]

def to_dict(
Expand Down
Loading

0 comments on commit 8359b85

Please sign in to comment.