Skip to content

Commit

Permalink
replace pipes in type annotations with Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
giuppep committed Apr 16, 2024
1 parent bd4623c commit bb4259b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/flask_session/postgresql/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from contextlib import contextmanager
from datetime import timedelta as TimeDelta
from typing import Generator
from typing import Generator, Optional

from flask import Flask
from itsdangerous import want_bytes
Expand Down Expand Up @@ -40,15 +40,15 @@ class PostgreSqlSessionInterface(ServerSideSessionInterface):
def __init__(
self,
app: Flask,
pool: ThreadedConnectionPool | None = Defaults.SESSION_POSTGRESQL,
pool: Optional[ThreadedConnectionPool] = Defaults.SESSION_POSTGRESQL,
key_prefix: str = Defaults.SESSION_KEY_PREFIX,
use_signer: bool = Defaults.SESSION_USE_SIGNER,
permanent: bool = Defaults.SESSION_PERMANENT,
sid_length: int = Defaults.SESSION_ID_LENGTH,
serialization_format: str = Defaults.SESSION_SERIALIZATION_FORMAT,
table: str = Defaults.SESSION_POSTGRESQL_TABLE,
schema: str = Defaults.SESSION_POSTGRESQL_SCHEMA,
cleanup_n_requests: int | None = Defaults.SESSION_CLEANUP_N_REQUESTS,
cleanup_n_requests: Optional[int] = Defaults.SESSION_CLEANUP_N_REQUESTS,
) -> None:
if not isinstance(pool, ThreadedConnectionPool):
raise TypeError("No valid ThreadedConnectionPool instance provided.")
Expand All @@ -74,7 +74,7 @@ def __init__(

@contextmanager
def _get_cursor(
self, conn: PsycoPg2Connection | None = None
self, conn: Optional[PsycoPg2Connection] = None
) -> Generator[PsycoPg2Cursor, None, None]:
_conn: PsycoPg2Connection = conn or self.pool.getconn()

Expand Down Expand Up @@ -107,7 +107,7 @@ def _delete_session(self, store_id: str) -> None:
)

@retry_query(max_attempts=3)
def _retrieve_session_data(self, store_id: str) -> dict | None:
def _retrieve_session_data(self, store_id: str) -> Optional[dict]:
with self._get_cursor() as cur:
cur.execute(
self._queries.retrieve_session_data,
Expand Down

0 comments on commit bb4259b

Please sign in to comment.