Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractBaseSession: Use model fields for subclassed cases #2180

Merged
merged 3 commits into from
May 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
AbstractBaseSession: Use ClassVar (credit: @flaeppe)
tony committed May 24, 2024
commit ae795ce1d6d77033368fc656e6993a549c7ae206
4 changes: 3 additions & 1 deletion django-stubs/contrib/sessions/base_session.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from datetime import datetime
from typing import Any, TypeVar
from typing import Any, ClassVar, TypeVar

from django.contrib.sessions.backends.base import SessionBase
from django.db import models
from typing_extensions import Self

_T = TypeVar("_T", bound=AbstractBaseSession)

@@ -14,6 +15,7 @@ class AbstractBaseSession(models.Model):
session_key = models.CharField(primary_key=True)
session_data = models.TextField()
expire_date = models.DateTimeField()
objects: ClassVar[BaseSessionManager[Self]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this is better because it's more precise, thanks.


@classmethod
def get_session_store_class(cls) -> type[SessionBase] | None: ...
1 change: 1 addition & 0 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
@@ -509,6 +509,7 @@ 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
django.contrib.sessions.base_session.AbstractBaseSession.get_previous_by_expire_date
django.contrib.sessions.base_session.AbstractBaseSession.objects
django.contrib.sessions.base_session.AbstractBaseSession.session_data
django.contrib.sessions.base_session.AbstractBaseSession.session_key
django.contrib.sessions.base_session.BaseSessionManager.__slotnames__