Skip to content

Commit 44e60f5

Browse files
Minor changes to typing. (#672)
1 parent bf9a5f0 commit 44e60f5

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

aiohttp_session/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
Callable,
1313
Dict,
1414
Iterator,
15-
Mapping,
1615
MutableMapping,
1716
Optional,
1817
Union,
@@ -40,7 +39,7 @@ class _CookieParams(TypedDict, total=False):
4039
expires: str
4140

4241

43-
class _SessionData(TypedDict, total=False):
42+
class SessionData(TypedDict, total=False):
4443
created: int
4544
session: Dict[str, Any]
4645

@@ -53,7 +52,7 @@ def __init__(
5352
self,
5453
identity: Optional[Any],
5554
*,
56-
data: Optional[Mapping[str, Any]],
55+
data: Optional[SessionData],
5756
new: bool,
5857
max_age: Optional[int] = None,
5958
) -> None:
@@ -264,7 +263,7 @@ def max_age(self) -> Optional[int]:
264263
def cookie_params(self) -> _CookieParams:
265264
return self._cookie_params
266265

267-
def _get_session_data(self, session: Session) -> _SessionData:
266+
def _get_session_data(self, session: Session) -> SessionData:
268267
if session.empty:
269268
return {}
270269

examples/postgres_storage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def __init__( # type: ignore[no-any-unimported]
4141

4242
async def load_session(self, request: web.Request) -> Session:
4343
cookie = self.load_cookie(request)
44-
data = {}
4544
if cookie is None:
4645
return Session(None, data={}, new=True, max_age=self.max_age)
4746
else:

tests/test_session_dict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pytest
55

6-
from aiohttp_session import Session
6+
from aiohttp_session import Session, SessionData
77

88

99
def test_create() -> None:
@@ -64,7 +64,7 @@ def test__repr__() -> None:
6464

6565
def test__repr__2() -> None:
6666
created = int(time.time()) - 1000
67-
session_data = {"session": {"key": 123}, "created": created}
67+
session_data: SessionData = {"session": {"key": 123}, "created": created}
6868
s = Session("test_identity", data=session_data, new=False)
6969
assert str(
7070
s

0 commit comments

Comments
 (0)