From ae795ce1d6d77033368fc656e6993a549c7ae206 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Fri, 24 May 2024 10:55:05 -0500 Subject: [PATCH] `AbstractBaseSession`: Use `ClassVar` (credit: @flaeppe) --- django-stubs/contrib/sessions/base_session.pyi | 4 +++- scripts/stubtest/allowlist_todo.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/django-stubs/contrib/sessions/base_session.pyi b/django-stubs/contrib/sessions/base_session.pyi index c51e57269..4da1bdb26 100644 --- a/django-stubs/contrib/sessions/base_session.pyi +++ b/django-stubs/contrib/sessions/base_session.pyi @@ -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]] @classmethod def get_session_store_class(cls) -> type[SessionBase] | None: ... diff --git a/scripts/stubtest/allowlist_todo.txt b/scripts/stubtest/allowlist_todo.txt index f5bd7c869..4fb92026b 100644 --- a/scripts/stubtest/allowlist_todo.txt +++ b/scripts/stubtest/allowlist_todo.txt @@ -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__