Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve BaseManager, Manager types #205

Merged
merged 5 commits into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions django-stubs/db/models/manager.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterable, MutableMapping
from typing import Any, Generic, TypeVar
from typing import Any, Callable, Generic, TypeVar
from typing_extensions import Self

from django.db.models.base import Model
Expand All @@ -19,21 +19,24 @@ class BaseManager(QuerySet[_T]):
def __init__(self) -> None: ...
def deconstruct(
self,
) -> tuple[bool, str, None, tuple[Any, ...], dict[str, int]]: ...
) -> tuple[bool, str | None, str | None, tuple[Any, ...] | None, dict[str, Any] | None]: ...
def check(self, **kwargs: Any) -> list[Any]: ...
@classmethod
def from_queryset(
cls, queryset_class: type[QuerySet[Any]], class_name: str | None = ...
) -> Any: ...
cls, queryset_class: type[QuerySet[_T]], class_name: str | None = ...
) -> type[Manager[_T]]: ...
@classmethod
def _get_queryset_methods(cls, queryset_class: type) -> dict[str, Any]: ...
def _get_queryset_methods(
cls, queryset_class: type[QuerySet[_T]]
) -> dict[str, Callable[..., Any]]: ...
def contribute_to_class(self, model: type[Model], name: str) -> None: ...
def db_manager(
self, using: str | None = ..., hints: dict[str, Model] | None = ...
) -> Self: ...
def get_queryset(self) -> QuerySet[_T]: ...

class Manager(BaseManager[_T]): ...
class Manager(BaseManager[_T]):
_queryset_class: type[QuerySet[_T]]

class RelatedManager(Manager[_T]):
related_val: tuple[int, ...]
Expand Down