From 5135cc1c8cd96cb2f77f4fa9f30d7e24f44f0bfe Mon Sep 17 00:00:00 2001 From: Lex Date: Mon, 5 Feb 2024 01:54:29 +1000 Subject: [PATCH] Fix python 3.7 type hint compatibility --- src/flask_session/sessions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/flask_session/sessions.py b/src/flask_session/sessions.py index 3db3eda3..c9c01354 100644 --- a/src/flask_session/sessions.py +++ b/src/flask_session/sessions.py @@ -32,9 +32,9 @@ def __bool__(self) -> bool: def __init__( self, - initial: dict[str, Any] | None = None, - sid: str | None = None, - permanent: bool | None = None, + initial: Optional[dict[str, Any]] = None, + sid: Optional[str] = None, + permanent: Optional[bool] = None, ): def on_update(self) -> None: self.modified = True @@ -177,7 +177,7 @@ def open_session(self, app: Flask, request: Request) -> ServerSideSession: sid = self._generate_sid(self.sid_length) return self.session_class(sid=sid, permanent=self.permanent) - def _retrieve_session_data(self, store_id: str) -> dict | None: + def _retrieve_session_data(self, store_id: str) -> Optional[dict]: raise NotImplementedError() def _delete_session(self, store_id: str) -> None: @@ -224,7 +224,7 @@ def __init__( self.redis = redis super().__init__(app, key_prefix, use_signer, permanent, sid_length) - def _retrieve_session_data(self, store_id: str) -> dict | None: + def _retrieve_session_data(self, store_id: str) -> Optional[dict]: # Get the saved session (value) from the database serialized_session_data = self.redis.get(store_id) if serialized_session_data: @@ -315,7 +315,7 @@ def _get_memcache_timeout(self, timeout: int) -> int: timeout += int(time.time()) return timeout - def _retrieve_session_data(self, store_id: str) -> dict | None: + def _retrieve_session_data(self, store_id: str) -> Optional[dict]: # Get the saved session (item) from the database serialized_session_data = self.client.get(store_id) if serialized_session_data: @@ -382,7 +382,7 @@ def __init__( self.cache = FileSystemCache(cache_dir, threshold=threshold, mode=mode) super().__init__(app, key_prefix, use_signer, permanent, sid_length) - def _retrieve_session_data(self, store_id: str) -> dict | None: + def _retrieve_session_data(self, store_id: str) -> Optional[dict]: # Get the saved session (item) from the database return self.cache.get(store_id) @@ -451,7 +451,7 @@ def __init__( super().__init__(app, key_prefix, use_signer, permanent, sid_length) - def _retrieve_session_data(self, store_id: str) -> dict | None: + def _retrieve_session_data(self, store_id: str) -> Optional[dict]: # Get the saved session (document) from the database document = self.store.find_one({"id": store_id}) if document: