From fd057010f6cbf176f57d1099e82be46d39b99cb9 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 9 Jun 2020 22:48:19 +0200 Subject: [PATCH] Model.objects should be a ClassVar Model.objects is only available on classes and while we cannot force this, without ClassVar it's kind of only available on instances. I have noticed this when I was writing a Jedi plugin that makes django-stubs work properly. --- django-stubs/db/models/base.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django-stubs/db/models/base.pyi b/django-stubs/db/models/base.pyi index ba33a02..5851803 100644 --- a/django-stubs/db/models/base.pyi +++ b/django-stubs/db/models/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, Collection +from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, Collection, ClassVar from django.core.checks.messages import CheckMessage from django.core.exceptions import ValidationError @@ -22,7 +22,7 @@ class Model(metaclass=ModelBase): class Meta: ... _meta: Options[Any] _default_manager: BaseManager[Model] - objects: BaseManager[Any] + objects: ClassVar[BaseManager[Any]] pk: Any = ... _state: ModelState def __init__(self: _Self, *args, **kwargs) -> None: ...