From dff2c4f0dde14ba6aac0b2d43c0692321a7c5a91 Mon Sep 17 00:00:00 2001 From: Mateen Kasim <46801200+mateenkasim@users.noreply.github.com> Date: Tue, 21 Feb 2023 12:00:35 -0500 Subject: [PATCH] Update Model subclass DoesNotExist type (#1364) * Update Model subclass DoesNotExist type * Make special Model exceptions Final * Use typing_extensions --- django-stubs/db/models/base.pyi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index 5070352a3..d22ed7774 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -7,6 +7,7 @@ from django.core.exceptions import MultipleObjectsReturned as BaseMultipleObject from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db.models.manager import BaseManager from django.db.models.options import Options +from typing_extensions import Final _Self = TypeVar("_Self", bound=Model) @@ -26,8 +27,9 @@ class ModelBase(type): def _base_manager(cls: type[_Self]) -> BaseManager[_Self]: ... # type: ignore[misc] class Model(metaclass=ModelBase): - class DoesNotExist(ObjectDoesNotExist): ... - class MultipleObjectsReturned(BaseMultipleObjectsReturned): ... + DoesNotExist: Final[type[ObjectDoesNotExist]] + MultipleObjectsReturned: Final[type[BaseMultipleObjectsReturned]] + class Meta: ... _meta: Options[Any] pk: Any