Skip to content

Commit

Permalink
Add SessionBase methods, change SessionStore.get_model_class() return (
Browse files Browse the repository at this point in the history
…#1517)

Improve typing in `contrib.session.backends`

Co-authored-by: Marti Raudsepp <[email protected]>
  • Loading branch information
realsuayip and intgr authored Jun 2, 2023
1 parent 99c8fcc commit 2d27ba6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion django-stubs/contrib/sessions/backends/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class SessionBase(dict[str, Any]):
modified: bool
serializer: Any
def __init__(self, session_key: str | None = ...) -> None: ...
@property
def key_salt(self) -> str: ...
def set_test_cookie(self) -> None: ...
def test_cookie_worked(self) -> bool: ...
def delete_test_cookie(self) -> None: ...
def encode(self, session_dict: dict[str, Any]) -> str: ...
def decode(self, session_data: bytes | str) -> dict[str, Any]: ...
def has_key(self, key: Any) -> Any: ...
def has_key(self, key: Any) -> bool: ...
def keys(self) -> Any: ...
def values(self) -> Any: ...
def items(self) -> Any: ...
Expand All @@ -32,6 +34,7 @@ class SessionBase(dict[str, Any]):
def _session_key(self) -> str | None: ...
@_session_key.setter
def _session_key(self, value: str | None) -> None: ...
def get_session_cookie_age(self) -> int: ...
def get_expiry_age(self, **kwargs: Any) -> int: ...
def get_expiry_date(self, **kwargs: Any) -> datetime: ...
def set_expiry(self, value: datetime | int | None) -> None: ...
Expand Down
3 changes: 1 addition & 2 deletions django-stubs/contrib/sessions/backends/db.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from django.contrib.sessions.backends.base import SessionBase
from django.contrib.sessions.base_session import AbstractBaseSession
from django.contrib.sessions.models import Session
from django.db.models.base import Model

class SessionStore(SessionBase):
def __init__(self, session_key: str | None = ...) -> None: ...
@classmethod
def get_model_class(cls) -> type[Session]: ...
def get_model_class(cls) -> type[AbstractBaseSession]: ...
@property
def model(self) -> type[AbstractBaseSession]: ...
def create_model_instance(self, data: dict[str, Model]) -> AbstractBaseSession: ...

0 comments on commit 2d27ba6

Please sign in to comment.