Skip to content

Commit

Permalink
Fix python 3.7 type hint compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Lxstr committed Feb 4, 2024
1 parent 7d7d58c commit 95da35b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/flask_session/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -586,7 +586,7 @@ def __repr__(self):

self.sql_session_model = Session

def _retrieve_session_data(self, store_id: str) -> dict | None:
def _retrieve_session_data(self, store_id: str) -> Optional[dict]:
# Get the saved session (record) from the database
record = self.sql_session_model.query.filter_by(session_id=store_id).first()

Expand Down

0 comments on commit 95da35b

Please sign in to comment.