Skip to content

Commit

Permalink
style: Loosen restore_snapshot() typing (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielArndt authored Oct 2, 2024
1 parent 9419064 commit ab90f24
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/charms/vault_k8s/v0/vault_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from abc import abstractmethod
from dataclasses import dataclass
from enum import Enum
from io import IOBase
from typing import List, Protocol

import hvac
Expand Down Expand Up @@ -404,7 +405,7 @@ def create_snapshot(self) -> requests.Response:
"""Create a snapshot of the Vault data."""
return self._client.sys.take_raft_snapshot()

def restore_snapshot(self, snapshot: bytes) -> requests.Response:
def restore_snapshot(self, snapshot: IOBase) -> requests.Response:
"""Restore a snapshot of the Vault data.
Uses force_restore_raft_snapshot to restore the snapshot
Expand Down
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ def _restore_vault(self, snapshot: StreamingBody) -> bool:
# hvac vault client expects bytes or a file-like object to restore the snapshot
# StreamingBody implements the read() method
# so it can be used as a file-like object in this context
response = vault.restore_snapshot(snapshot) # type: ignore[arg-type]
response = vault.restore_snapshot(snapshot)
except VaultClientError as e:
logger.error("Failed to restore snapshot: %s", e)
return False
Expand Down

0 comments on commit ab90f24

Please sign in to comment.