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.
This commit is contained in:
Dave Halter
2020-06-09 22:48:19 +02:00
committed by Adam Johnson
parent 1d78b8ffac
commit 7c995572c6

View File

@@ -1,4 +1,4 @@
from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union from typing import Any, ClassVar, Collection, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
from django.core.checks.messages import CheckMessage from django.core.checks.messages import CheckMessage
from django.core.exceptions import MultipleObjectsReturned as BaseMultipleObjectsReturned from django.core.exceptions import MultipleObjectsReturned as BaseMultipleObjectsReturned
@@ -29,7 +29,7 @@ class Model(metaclass=ModelBase):
@classproperty @classproperty
@classmethod @classmethod
def _base_manager(cls: Type[_Self]) -> BaseManager[_Self]: ... def _base_manager(cls: Type[_Self]) -> BaseManager[_Self]: ...
objects: BaseManager[Any] objects: ClassVar[BaseManager[Any]]
pk: Any = ... pk: Any = ...
_state: ModelState _state: ModelState
def __init__(self: _Self, *args: Any, **kwargs: Any) -> None: ... def __init__(self: _Self, *args: Any, **kwargs: Any) -> None: ...