From 3fdb7cc953eb81ca82565c846cdc5a12e898366f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 12 Jan 2019 16:23:48 +0000 Subject: [PATCH] xep_0384: add types to Storage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- storage.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/storage.py b/storage.py index 3a6b462..60fa48e 100644 --- a/storage.py +++ b/storage.py @@ -16,7 +16,7 @@ import omemo class SyncFileStorage(omemo.Storage): def __init__(self, storage_dir: str) -> None: self.storage_dir = storage_dir - self.__state = None + self.__state = None # type: Any self.__own_data = None # type: Optional[Dict[str, Union[str, int]]] self.__sessions = {} # type: Dict[str, Dict[int, Any]] self.__devices = {} # type: Dict[str, Dict[str, Union[List[int], Dict[int, int]]]] @@ -29,7 +29,7 @@ class SyncFileStorage(omemo.Storage): "devices" : self.__devices }) - def loadOwnData(self, _callback): + def loadOwnData(self, _callback) -> Optional[Dict[str, Union[str, int]]]: if self.__own_data is None: try: filepath = os.path.join(self.storage_dir, 'own_data.json') @@ -50,7 +50,7 @@ class SyncFileStorage(omemo.Storage): with open(filepath, 'w') as f: json.dump(self.__own_data, f) - def loadState(self, _callback): + def loadState(self, _callback) -> Any: if self.__state is None: try: filepath = os.path.join(self.storage_dir, 'omemo.json') @@ -61,13 +61,13 @@ class SyncFileStorage(omemo.Storage): return self.__state - def storeState(self, _callback, state) -> None: + def storeState(self, _callback, state: Any) -> None: self.__state = state filepath = os.path.join(self.storage_dir, 'omemo.json') with open(filepath, 'w') as f: json.dump(self.__state, f) - def loadSession(self, _callback, bare_jid: str, device_id: int): + def loadSession(self, _callback, bare_jid: str, device_id: int) -> Any: if not self.__sessions: try: filepath = os.path.join(self.storage_dir, 'sessions.json')