Skip to content

Commit

Permalink
I dislike python 3.9 [test] [docs]
Browse files Browse the repository at this point in the history
  • Loading branch information
bboonstra committed Oct 23, 2024
1 parent aa1fbc8 commit 1e71e1c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions effortless/effortless.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import os
import logging
from typing import Any, Dict, List, Union
from typing import Any, Dict, List, Optional, Union
import zlib
import base64
import threading
Expand Down Expand Up @@ -306,7 +306,9 @@ def _read_db(self) -> Dict[str, Any]:
content = self._decompress_data(content)

if headers.get("enc"):
content = self._decrypt_data(content if isinstance(content, str) else json.dumps(content))
content = self._decrypt_data(
content if isinstance(content, str) else json.dumps(content)
)

return {"headers": headers, "content": content}
except (IOError, json.JSONDecodeError) as e:
Expand Down Expand Up @@ -338,10 +340,10 @@ def _write_db(self, data: Dict[str, Any], write_in_readonly: bool = False) -> No

headers = data["headers"]
content = data["content"]

if headers.get("enc"):
content = self._encrypt_data(content)

if headers.get("cmp"):
content = self._compress_data(json.dumps(content))

Expand Down Expand Up @@ -381,7 +383,7 @@ def _handle_backup(self) -> None:
self._backup_thread = threading.Thread(target=self._backup)
self._backup_thread.start()

def finish_backup(self, timeout: float | None = None) -> bool:
def finish_backup(self, timeout: Optional[float] = None) -> bool:
"""
Wait for any ongoing backup operation to complete.
Expand Down Expand Up @@ -429,7 +431,7 @@ def _backup(self) -> bool:
except IOError as e:
logger.error(f"Backup failed: {str(e)}")
return False # Indicate failure

return False

def _compress_data(self, data: Union[str, Dict[str, Any]]) -> str:
Expand Down

0 comments on commit 1e71e1c

Please sign in to comment.