Skip to content

Commit

Permalink
Update Model subclass DoesNotExist type (#1364)
Browse files Browse the repository at this point in the history
* Update Model subclass DoesNotExist type
* Make special Model exceptions Final
* Use typing_extensions
  • Loading branch information
mateenkasim authored Feb 21, 2023
1 parent 3b52179 commit dff2c4f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django-stubs/db/models/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit dff2c4f

Please sign in to comment.