From a351a67f3a76f77b5e870b178c5f49e3bc9779b1 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Wed, 6 Nov 2024 19:22:52 +0000 Subject: [PATCH] fix types --- codeforlife/models/abstract_base_session.py | 2 -- codeforlife/models/abstract_base_user.py | 2 -- codeforlife/models/base_session_store.py | 4 +++- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/codeforlife/models/abstract_base_session.py b/codeforlife/models/abstract_base_session.py index e4d8f4b..a752275 100644 --- a/codeforlife/models/abstract_base_session.py +++ b/codeforlife/models/abstract_base_session.py @@ -10,7 +10,6 @@ AbstractBaseSession as _AbstractBaseSession, ) from django.db import models -from django.db.models import Manager from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -31,7 +30,6 @@ class AbstractBaseSession(_AbstractBaseSession): """ pk: str # type: ignore[assignment] - objects: Manager[t.Self] user_id: int user = models.OneToOneField( diff --git a/codeforlife/models/abstract_base_user.py b/codeforlife/models/abstract_base_user.py index 66b654b..3323fe8 100644 --- a/codeforlife/models/abstract_base_user.py +++ b/codeforlife/models/abstract_base_user.py @@ -6,7 +6,6 @@ import typing as t from django.contrib.auth.models import AbstractBaseUser as _AbstractBaseUser -from django.db.models import Manager from django.utils.translation import gettext_lazy as _ if t.TYPE_CHECKING: @@ -26,7 +25,6 @@ class AbstractBaseUser(_AbstractBaseUser): id: int pk: int session: "AbstractBaseSession" - objects: Manager[t.Self] # pylint: disable-next=missing-class-docstring,too-few-public-methods class Meta(TypedModelMeta): diff --git a/codeforlife/models/base_session_store.py b/codeforlife/models/base_session_store.py index ad8af54..af8520e 100644 --- a/codeforlife/models/base_session_store.py +++ b/codeforlife/models/base_session_store.py @@ -72,7 +72,9 @@ def create_model_instance(self, data): session = model_class.objects.get(user_id=user_id) except model_class.DoesNotExist: session = model_class.objects.get(session_key=self.session_key) - self.associate_session_to_user(session, user_id) + self.associate_session_to_user( + t.cast(AnyAbstractBaseSession, session), user_id + ) session.session_data = self.encode(data)