Skip to content

Commit

Permalink
Update contrib.sessions.backends (#2351)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Viicos and pre-commit-ci[bot] authored Aug 29, 2024
1 parent 0d7e4a7 commit 7906c01
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 68 deletions.
47 changes: 43 additions & 4 deletions django-stubs/contrib/sessions/backends/base.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from _collections_abc import dict_items, dict_keys, dict_values
from collections.abc import Iterable
from datetime import datetime, timedelta
from typing import Any
from typing import Any, overload

from _typeshed import SupportsKeysAndGetItem

VALID_KEY_CHARS: Any

Expand All @@ -13,17 +17,39 @@ class SessionBase(dict[str, Any]):
modified: bool
serializer: Any
def __init__(self, session_key: str | None = None) -> None: ...
async def aset(self, key: str, value: Any) -> None: ...
@property
def key_salt(self) -> str: ...
@overload
async def aget(self, key: str) -> Any | None: ...
@overload
async def aget(self, key: str, default: Any) -> Any: ...
@overload
async def apop(self, key: str) -> Any: ...
@overload
async def apop(self, key: str, default: Any) -> Any: ...
async def asetdefault(self, key: str, value: Any) -> Any: ...
def set_test_cookie(self) -> None: ...
async def aset_test_cookie(self) -> None: ...
def test_cookie_worked(self) -> bool: ...
async def atest_cookie_worked(self) -> bool: ...
def delete_test_cookie(self) -> None: ...
async def adelete_test_cookie(self) -> None: ...
def encode(self, session_dict: dict[str, Any]) -> str: ...
def decode(self, session_data: bytes | str) -> dict[str, Any]: ...
@overload # type: ignore[override]
def update(self, dict_: SupportsKeysAndGetItem[str, Any]) -> None: ...
@overload
def update(self, dict_: Iterable[tuple[str, Any]]) -> None: ...
@overload
async def aupdate(self, dict_: SupportsKeysAndGetItem[str, Any]) -> None: ...
@overload
async def aupdate(self, dict_: Iterable[tuple[str, Any]]) -> None: ...
def has_key(self, key: Any) -> bool: ...
def keys(self) -> Any: ...
def values(self) -> Any: ...
def items(self) -> Any: ...
async def ahas_key(self, key: Any) -> bool: ...
async def akeys(self) -> dict_keys[str, Any]: ...
async def avalues(self) -> dict_values[str, Any]: ...
async def aitems(self) -> dict_items[str, Any]: ...
def clear(self) -> None: ...
def is_empty(self) -> bool: ...
def _get_session_key(self) -> str | None: ...
Expand All @@ -36,15 +62,28 @@ class SessionBase(dict[str, Any]):
def _session_key(self, value: str | None) -> None: ...
def get_session_cookie_age(self) -> int: ...
def get_expiry_age(self, **kwargs: Any) -> int: ...
async def aget_expiry_age(self, **kwargs: Any) -> int: ...
def get_expiry_date(self, **kwargs: Any) -> datetime: ...
async def aget_expiry_date(self, **kwargs: Any) -> datetime: ...
def set_expiry(self, value: datetime | timedelta | int | None) -> None: ...
async def aset_expiry(self, value: datetime | timedelta | int | None) -> None: ...
def get_expire_at_browser_close(self) -> bool: ...
async def aget_expire_at_browser_close(self) -> bool: ...
def flush(self) -> None: ...
async def aflush(self) -> None: ...
def cycle_key(self) -> None: ...
async def acycle_key(self) -> None: ...
def exists(self, session_key: str) -> bool: ...
async def aexists(self, session_key: str) -> bool: ...
def create(self) -> None: ...
async def acreate(self) -> None: ...
def save(self, must_create: bool = False) -> None: ...
async def asave(self, must_create: bool = False) -> None: ...
def delete(self, session_key: str | None = None) -> None: ...
async def adelete(self, session_key: str | None = None) -> None: ...
def load(self) -> dict[str, Any]: ...
async def aload(self) -> dict[str, Any]: ...
@classmethod
def clear_expired(cls) -> None: ...
@classmethod
async def aclear_expired(cls) -> None: ...
1 change: 1 addition & 0 deletions django-stubs/contrib/sessions/backends/cache.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ class SessionStore(SessionBase):
def __init__(self, session_key: str | None = None) -> None: ...
@property
def cache_key(self) -> str: ...
async def acache_key(self) -> str: ...
4 changes: 4 additions & 0 deletions django-stubs/contrib/sessions/backends/cached_db.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from logging import Logger
from typing import Any

from django.contrib.sessions.backends.db import SessionStore as DBStore

KEY_PREFIX: str

logger: Logger

class SessionStore(DBStore):
cache_key_prefix: Any
def __init__(self, session_key: str | None = None) -> None: ...
@property
def cache_key(self) -> str: ...
async def acache_key(self) -> str: ...
1 change: 1 addition & 0 deletions django-stubs/contrib/sessions/backends/db.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class SessionStore(SessionBase):
@cached_property
def model(self) -> type[AbstractBaseSession]: ...
def create_model_instance(self, data: dict[str, Any]) -> AbstractBaseSession: ...
async def acreate_model_instance(self, data: dict[str, Any]) -> AbstractBaseSession: ...
1 change: 0 additions & 1 deletion django-stubs/contrib/sessions/backends/file.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ class SessionStore(SessionBase):
storage_path: str
file_prefix: str
def __init__(self, session_key: str | None = None) -> None: ...
def clean(self) -> None: ...
3 changes: 2 additions & 1 deletion django-stubs/contrib/sessions/backends/signed_cookies.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib.sessions.backends.base import SessionBase

class SessionStore(SessionBase): ...
class SessionStore(SessionBase):
async def aexists(self, session_key: str | None = None) -> bool: ...
4 changes: 4 additions & 0 deletions scripts/stubtest/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,7 @@ django.db.migrations.recorder.Migration@AnnotatedWith
django.contrib.auth.backends.UserModel
django.contrib.auth.forms.UserModel
django.contrib.auth.views.UserModel

# Using the definitions from `dict` (from typeshed)
django.contrib.sessions.backends.base.SessionBase.get
django.contrib.sessions.backends.base.SessionBase.setdefault
3 changes: 0 additions & 3 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,6 @@ django.contrib.redirects.models.Redirect.new_path
django.contrib.redirects.models.Redirect.old_path
django.contrib.redirects.models.Redirect.site
django.contrib.redirects.models.Redirect.site_id
django.contrib.sessions.backends.base.SessionBase.get
django.contrib.sessions.backends.base.SessionBase.setdefault
django.contrib.sessions.backends.base.SessionBase.update
django.contrib.sessions.backends.signed_cookies.SessionStore.exists
django.contrib.sessions.base_session.AbstractBaseSession.expire_date
django.contrib.sessions.base_session.AbstractBaseSession.get_next_by_expire_date
Expand Down
59 changes: 0 additions & 59 deletions scripts/stubtest/allowlist_todo_django51.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,65 +98,6 @@ django.contrib.postgres.operations.CreateExtension.category
django.contrib.postgres.operations.RemoveCollation.category
django.contrib.postgres.operations.RemoveIndexConcurrently.category
django.contrib.postgres.operations.ValidateConstraint.category
django.contrib.sessions.backends.base.SessionBase.aclear_expired
django.contrib.sessions.backends.base.SessionBase.acreate
django.contrib.sessions.backends.base.SessionBase.acycle_key
django.contrib.sessions.backends.base.SessionBase.adelete
django.contrib.sessions.backends.base.SessionBase.adelete_test_cookie
django.contrib.sessions.backends.base.SessionBase.aexists
django.contrib.sessions.backends.base.SessionBase.aflush
django.contrib.sessions.backends.base.SessionBase.aget
django.contrib.sessions.backends.base.SessionBase.aget_expire_at_browser_close
django.contrib.sessions.backends.base.SessionBase.aget_expiry_age
django.contrib.sessions.backends.base.SessionBase.aget_expiry_date
django.contrib.sessions.backends.base.SessionBase.ahas_key
django.contrib.sessions.backends.base.SessionBase.aitems
django.contrib.sessions.backends.base.SessionBase.akeys
django.contrib.sessions.backends.base.SessionBase.aload
django.contrib.sessions.backends.base.SessionBase.apop
django.contrib.sessions.backends.base.SessionBase.asave
django.contrib.sessions.backends.base.SessionBase.aset
django.contrib.sessions.backends.base.SessionBase.aset_expiry
django.contrib.sessions.backends.base.SessionBase.aset_test_cookie
django.contrib.sessions.backends.base.SessionBase.asetdefault
django.contrib.sessions.backends.base.SessionBase.atest_cookie_worked
django.contrib.sessions.backends.base.SessionBase.aupdate
django.contrib.sessions.backends.base.SessionBase.avalues
django.contrib.sessions.backends.cache.SessionStore.acache_key
django.contrib.sessions.backends.cache.SessionStore.aclear_expired
django.contrib.sessions.backends.cache.SessionStore.acreate
django.contrib.sessions.backends.cache.SessionStore.adelete
django.contrib.sessions.backends.cache.SessionStore.aexists
django.contrib.sessions.backends.cache.SessionStore.aload
django.contrib.sessions.backends.cache.SessionStore.asave
django.contrib.sessions.backends.cached_db.SessionStore.acache_key
django.contrib.sessions.backends.cached_db.SessionStore.adelete
django.contrib.sessions.backends.cached_db.SessionStore.aexists
django.contrib.sessions.backends.cached_db.SessionStore.aflush
django.contrib.sessions.backends.cached_db.SessionStore.aload
django.contrib.sessions.backends.cached_db.SessionStore.asave
django.contrib.sessions.backends.cached_db.logger
django.contrib.sessions.backends.db.SessionStore.aclear_expired
django.contrib.sessions.backends.db.SessionStore.acreate
django.contrib.sessions.backends.db.SessionStore.acreate_model_instance
django.contrib.sessions.backends.db.SessionStore.adelete
django.contrib.sessions.backends.db.SessionStore.aexists
django.contrib.sessions.backends.db.SessionStore.aload
django.contrib.sessions.backends.db.SessionStore.asave
django.contrib.sessions.backends.file.SessionStore.aclear_expired
django.contrib.sessions.backends.file.SessionStore.acreate
django.contrib.sessions.backends.file.SessionStore.adelete
django.contrib.sessions.backends.file.SessionStore.aexists
django.contrib.sessions.backends.file.SessionStore.aload
django.contrib.sessions.backends.file.SessionStore.asave
django.contrib.sessions.backends.file.SessionStore.clean
django.contrib.sessions.backends.signed_cookies.SessionStore.aclear_expired
django.contrib.sessions.backends.signed_cookies.SessionStore.acreate
django.contrib.sessions.backends.signed_cookies.SessionStore.acycle_key
django.contrib.sessions.backends.signed_cookies.SessionStore.adelete
django.contrib.sessions.backends.signed_cookies.SessionStore.aexists
django.contrib.sessions.backends.signed_cookies.SessionStore.aload
django.contrib.sessions.backends.signed_cookies.SessionStore.asave
django.core.checks.templates.E001
django.core.checks.templates.E002
django.core.checks.templates.W003
Expand Down

0 comments on commit 7906c01

Please sign in to comment.