PY-85518 Update django stubs version to v5.2.8

GitOrigin-RevId: cb1486d12dfc1c56cd111ea8a5a98990f606b1b8
This commit is contained in:
Morgan Bartholomew
2025-12-04 08:05:37 +00:00
committed by intellij-monorepo-bot
parent 3d63dd8724
commit e39fb403c3
73 changed files with 736 additions and 641 deletions
@@ -5,8 +5,11 @@ from re import Pattern
# django.utils.translation -- that module depends on the settings.
from typing import Any, Literal, Protocol, TypeAlias, TypedDict, type_check_only
from django.utils.functional import _StrOrPromise
from typing_extensions import NotRequired
from django_stubs_ext.settings import TemplatesSetting
_Admins: TypeAlias = list[tuple[str, str]]
####################
@@ -74,6 +77,10 @@ MANAGERS: _Admins
# Content-Type header.
DEFAULT_CHARSET: str
# `SERIALIZATION_MODULES` is a dictionary (`dict[str, str]`) of modules containing serializer definitions.
# Because Django doesn't define it, we can't provide its type here. Use `getattr` for type-safe access
# e.g. `getattr(settings, "SERIALIZATION_MODULES")`
# Email address that error messages come from.
SERVER_EMAIL: str
@@ -93,6 +100,10 @@ DATABASE_ROUTERS: list[str | Router]
# to a module that defines an EmailBackend class.
EMAIL_BACKEND: str
# `EMAIL_FILE_PATH` is a `str` indicating the directory used by the file email backend to store output files.
# Because Django doesn't define it, we can't provide its type here. Use `getattr` for type-safe access
# e.g. `getattr(settings, "EMAIL_FILE_PATH")`
# Host for sending email.
EMAIL_HOST: str
@@ -114,7 +125,7 @@ EMAIL_TIMEOUT: int | None
# List of strings representing installed apps.
INSTALLED_APPS: list[str]
TEMPLATES: list[dict[str, Any]]
TEMPLATES: list[TemplatesSetting]
# Default form rendering class.
FORM_RENDERER: str
@@ -167,6 +178,10 @@ ABSOLUTE_URL_OVERRIDES: dict[str, Any]
# ]
IGNORABLE_404_URLS: list[Pattern[str]]
# `ROOT_URLCONF` is a string representing the full Python import path to the root `URLconf`.
# Because Django doesn't define it, we can't provide its type here. Use `getattr` for type-safe access
# e.g. `getattr(settings, "ROOT_URLCONF")`
# A secret key for this particular Django installation. Used in secret-key
# hashing algorithms. Set this in your settings, or Django will complain
# loudly.
@@ -186,6 +201,10 @@ MEDIA_ROOT: str
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL: str
# `SITE_ID` is the ID, as an integer, of the current site in the `django_site` database table.
# Because Django doesn't define it, we can't provide its type here. Use `getattr` for type-safe access
# e.g. `getattr(settings, "SITE_ID")`
# Absolute path to the directory static files should be collected to.
# Example: "/var/www/example.com/static/"
STATIC_ROOT: str | None
@@ -389,11 +408,11 @@ AUTH_USER_MODEL: str
AUTHENTICATION_BACKENDS: Sequence[str]
LOGIN_URL: str
LOGIN_URL: _StrOrPromise
LOGIN_REDIRECT_URL: str
LOGIN_REDIRECT_URL: _StrOrPromise
LOGOUT_REDIRECT_URL: str | None
LOGOUT_REDIRECT_URL: _StrOrPromise | None
# The number of seconds a password reset link is valid for
PASSWORD_RESET_TIMEOUT: int
@@ -24,26 +24,26 @@ from .sites import site as site
def autodiscover() -> None: ...
__all__ = [
"action",
"display",
"register",
"ModelAdmin",
"HORIZONTAL",
"VERTICAL",
"StackedInline",
"TabularInline",
"AdminSite",
"site",
"ListFilter",
"SimpleListFilter",
"FieldListFilter",
"AllValuesFieldListFilter",
"BooleanFieldListFilter",
"RelatedFieldListFilter",
"ChoicesFieldListFilter",
"DateFieldListFilter",
"AllValuesFieldListFilter",
"EmptyFieldListFilter",
"FieldListFilter",
"ListFilter",
"ModelAdmin",
"RelatedFieldListFilter",
"RelatedOnlyFieldListFilter",
"ShowFacets",
"SimpleListFilter",
"StackedInline",
"TabularInline",
"action",
"autodiscover",
"display",
"register",
"site",
]
@@ -12,7 +12,7 @@ DELETION: int
ACTION_FLAG_CHOICES: Any
class LogEntryManager(models.Manager[LogEntry]):
@deprecated("log_action() is deprecated and will be removed in Django 6.0. Use log_action_new() instead.")
@deprecated("log_action() is deprecated and will be removed in Django 6.0. Use log_actions() instead.")
def log_action(
self,
user_id: int | str | UUID,
@@ -299,7 +299,7 @@ class ModelAdmin(BaseModelAdmin[_ModelT]):
_ChildModelT = TypeVar("_ChildModelT", bound=Model)
_ParentModelT = TypeVar("_ParentModelT", bound=Model)
class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_ChildModelT]):
class InlineModelAdmin(BaseModelAdmin[_ChildModelT], Generic[_ChildModelT, _ParentModelT]):
model: type[_ChildModelT]
fk_name: str | None
formset: type[BaseInlineFormSet[_ChildModelT, _ParentModelT, forms.ModelForm[_ChildModelT]]]
@@ -5,6 +5,7 @@ from typing import Any
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test.selenium import SeleniumTestCase
from django.utils.deprecation import MiddlewareMixin
from django.utils.functional import _StrOrPromise
class CSPMiddleware(MiddlewareMixin): ...
@@ -18,7 +19,7 @@ class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
def wait_until_invisible(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_page_ready(self, timeout: int = ...) -> None: ...
def wait_page_loaded(self, timeout: int = ...) -> AbstractContextManager[None]: ...
def admin_login(self, username: str, password: str, login_url: str = ...) -> None: ...
def admin_login(self, username: str, password: str, login_url: _StrOrPromise = ...) -> None: ...
def select_option(self, selector: str, value: Any) -> None: ...
def deselect_option(self, selector: str, value: Any) -> None: ...
def assertSelectOptions(self, selector: str, values: Any) -> None: ...
@@ -1,11 +1,15 @@
from collections.abc import Callable
from typing import TypeVar, overload
from django.utils.functional import _StrOrPromise
_C = TypeVar("_C", bound=Callable)
@overload
def staff_member_required(view_func: _C = ..., redirect_field_name: str | None = ..., login_url: str = ...) -> _C: ...
def staff_member_required(
view_func: _C = ..., redirect_field_name: str | None = ..., login_url: _StrOrPromise = ...
) -> _C: ...
@overload
def staff_member_required(
view_func: None = None, redirect_field_name: str | None = ..., login_url: str = ...
view_func: None = None, redirect_field_name: str | None = ..., login_url: _StrOrPromise = ...
) -> Callable: ...
@@ -3,21 +3,26 @@ from typing import TypeVar, overload
from django.contrib.auth.models import _AnyUser
from django.http.response import HttpResponseBase
from django.utils.functional import _StrOrPromise
_VIEW = TypeVar("_VIEW", bound=Callable[..., HttpResponseBase | Awaitable[HttpResponseBase]])
def user_passes_test(
test_func: Callable[[_AnyUser], bool],
login_url: str | None = ...,
login_url: _StrOrPromise | None = ...,
redirect_field_name: str | None = ...,
) -> Callable[[_VIEW], _VIEW]: ...
# There are two ways of calling @login_required: @with(arguments) and @bare
@overload
def login_required(redirect_field_name: str | None = ..., login_url: str | None = ...) -> Callable[[_VIEW], _VIEW]: ...
def login_required(
redirect_field_name: str | None = ..., login_url: _StrOrPromise | None = ...
) -> Callable[[_VIEW], _VIEW]: ...
@overload
def login_required(function: _VIEW, redirect_field_name: str | None = ..., login_url: str | None = ...) -> _VIEW: ...
def login_required(
function: _VIEW, redirect_field_name: str | None = ..., login_url: _StrOrPromise | None = ...
) -> _VIEW: ...
def login_not_required(view_func: _VIEW) -> _VIEW: ...
def permission_required(
perm: Iterable[str] | str, login_url: str | None = ..., raise_exception: bool = ...
perm: Iterable[str] | str, login_url: _StrOrPromise | None = ..., raise_exception: bool = ...
) -> Callable[[_VIEW], _VIEW]: ...
@@ -60,7 +60,7 @@ class SetUnusablePasswordMixin(Generic[_UserType]):
def validate_password_for_user(self, user: _UserType, **kwargs: Any) -> None: ...
def set_password_and_save(self, user: _User, commit: bool = True, **kwargs: Any) -> _User: ...
class BaseUserCreationForm(Generic[_UserType], forms.ModelForm[_UserType]):
class BaseUserCreationForm(forms.ModelForm[_UserType], Generic[_UserType]):
error_messages: _ErrorMessagesDict
password1: forms.Field
password2: forms.Field
@@ -112,7 +112,7 @@ class PasswordResetForm(forms.Form):
extra_email_context: dict[str, str] | None = ...,
) -> None: ...
class SetPasswordForm(Generic[_UserType], SetPasswordMixin, forms.Form):
class SetPasswordForm(SetPasswordMixin, forms.Form, Generic[_UserType]):
new_password1: forms.Field
new_password2: forms.Field
user: _UserType
@@ -123,7 +123,7 @@ class PasswordChangeForm(SetPasswordForm):
old_password: forms.Field
def clean_old_password(self) -> str: ...
class AdminPasswordChangeForm(Generic[_UserType], forms.Form):
class AdminPasswordChangeForm(forms.Form, Generic[_UserType]):
error_messages: _ErrorMessagesDict
required_css_class: str
usable_password_help_text: str
@@ -6,7 +6,7 @@ from django.http.response import HttpResponseBase, HttpResponseRedirect
from django.utils.functional import _StrOrPromise
class AccessMixin:
login_url: Any
login_url: _StrOrPromise | None
permission_denied_message: _StrOrPromise
raise_exception: bool
redirect_field_name: Any
@@ -2,6 +2,7 @@ from typing import Any
from django.contrib.admin.checks import InlineModelAdminChecks
from django.contrib.admin.options import InlineModelAdmin
from django.contrib.contenttypes.forms import BaseGenericInlineFormSet
from django.db.models.base import Model
class GenericInlineModelAdminChecks(InlineModelAdminChecks):
@@ -10,6 +11,7 @@ class GenericInlineModelAdminChecks(InlineModelAdminChecks):
class GenericInlineModelAdmin(InlineModelAdmin):
template: str
formset: type[BaseGenericInlineFormSet] # type: ignore[assignment]
class GenericStackedInline(GenericInlineModelAdmin): ...
class GenericTabularInline(GenericInlineModelAdmin): ...
@@ -1,9 +1,20 @@
from typing import Any
from typing import Any, Generic, TypeVar
from django.db.models import Prefetch
from django.db.models import Model, Prefetch
from django.db.models.query import QuerySet
class GenericPrefetch(Prefetch):
def __init__(self, lookup: str, querysets: list[QuerySet], to_attr: str | None = None) -> None: ...
# The type of the lookup passed to Prefetch(...)
# This will be specialized to a `LiteralString` in the plugin for further processing and validation
_LookupT = TypeVar("_LookupT", bound=str, covariant=True)
# The type of the querysets passed to GenericPrefetch(...)
_PrefetchedQuerySetsT = TypeVar(
"_PrefetchedQuerySetsT", bound=list[QuerySet[Model]], covariant=True, default=list[QuerySet[Model]]
)
# The attribute name to store the prefetched list[_PrefetchedQuerySetT]
# This will be specialized to a `LiteralString` in the plugin for further processing and validation
_ToAttrT = TypeVar("_ToAttrT", bound=str, covariant=True, default=str)
class GenericPrefetch(Prefetch, Generic[_LookupT, _PrefetchedQuerySetsT, _ToAttrT]):
def __init__(self, lookup: _LookupT, querysets: _PrefetchedQuerySetsT, to_attr: _ToAttrT | None = None) -> None: ...
def __getstate__(self) -> dict[str, Any]: ...
def get_current_querysets(self, level: int) -> list[QuerySet] | None: ...
def get_current_querysets(self, level: int) -> _PrefetchedQuerySetsT | None: ...
@@ -15,6 +15,7 @@ __all__ = [
"HORIZONTAL",
"VERTICAL",
"AdminSite",
"GISModelAdmin",
"ModelAdmin",
"StackedInline",
"TabularInline",
@@ -23,5 +24,4 @@ __all__ = [
"display",
"register",
"site",
"GISModelAdmin",
]
@@ -15,119 +15,119 @@ from django.contrib.gis.db.models.fields import RasterField as RasterField
from django.db.models import *
__all__ = [
"Aggregate",
"Avg",
"Count",
"Max",
"Min",
"StdDev",
"Sum",
"Variance",
"BaseConstraint",
"CheckConstraint",
"Deferrable",
"UniqueConstraint",
"Choices",
"IntegerChoices",
"TextChoices",
"AutoField",
"BLANK_CHOICE_DASH",
"BigAutoField",
"BigIntegerField",
"BinaryField",
"BooleanField",
"CharField",
"CommaSeparatedIntegerField",
"DateField",
"DateTimeField",
"DecimalField",
"DurationField",
"EmailField",
"Empty",
"Field",
"FilePathField",
"FloatField",
"GenericIPAddressField",
"IPAddressField",
"IntegerField",
"NOT_PROVIDED",
"NullBooleanField",
"PositiveBigIntegerField",
"PositiveIntegerField",
"PositiveSmallIntegerField",
"SlugField",
"SmallAutoField",
"SmallIntegerField",
"TextField",
"TimeField",
"URLField",
"UUIDField",
"Index",
"ObjectDoesNotExist",
"signals",
"CASCADE",
"DEFERRED",
"DO_NOTHING",
"NOT_PROVIDED",
"PROTECT",
"RESTRICT",
"SET",
"SET_DEFAULT",
"SET_NULL",
"ProtectedError",
"RestrictedError",
"Aggregate",
"AutoField",
"Avg",
"BaseConstraint",
"BigAutoField",
"BigIntegerField",
"BinaryField",
"BooleanField",
"Case",
"CharField",
"CheckConstraint",
"Choices",
"Collect",
"CommaSeparatedIntegerField",
"CompositePrimaryKey",
"Count",
"DateField",
"DateTimeField",
"DecimalField",
"Deferrable",
"DurationField",
"EmailField",
"Empty",
"Exists",
"Expression",
"ExpressionList",
"ExpressionWrapper",
"Extent",
"Extent3D",
"F",
"Field",
"FileField",
"FilePathField",
"FilteredRelation",
"FloatField",
"ForeignKey",
"ForeignObject",
"ForeignObjectRel",
"Func",
"GeneratedField",
"GenericIPAddressField",
"GeometryCollectionField",
"GeometryField",
"IPAddressField",
"ImageField",
"Index",
"IntegerChoices",
"IntegerField",
"JSONField",
"LineStringField",
"Lookup",
"MakeLine",
"Manager",
"ManyToManyField",
"ManyToManyRel",
"ManyToOneRel",
"Max",
"Min",
"Model",
"MultiLineStringField",
"MultiPointField",
"MultiPolygonField",
"NullBooleanField",
"ObjectDoesNotExist",
"OneToOneField",
"OneToOneRel",
"OrderBy",
"OrderWrt",
"OuterRef",
"PointField",
"PolygonField",
"PositiveBigIntegerField",
"PositiveIntegerField",
"PositiveSmallIntegerField",
"Prefetch",
"ProtectedError",
"Q",
"QuerySet",
"RasterField",
"RestrictedError",
"RowRange",
"SlugField",
"SmallAutoField",
"SmallIntegerField",
"StdDev",
"Subquery",
"Sum",
"TextChoices",
"TextField",
"TimeField",
"Transform",
"URLField",
"UUIDField",
"Union",
"UniqueConstraint",
"Value",
"ValueRange",
"Variance",
"When",
"Window",
"WindowFrame",
"WindowFrameExclusion",
"FileField",
"ImageField",
"GeneratedField",
"JSONField",
"OrderWrt",
"Lookup",
"Transform",
"Manager",
"Prefetch",
"Q",
"QuerySet",
"aprefetch_related_objects",
"prefetch_related_objects",
"DEFERRED",
"Model",
"FilteredRelation",
"ForeignKey",
"ForeignObject",
"OneToOneField",
"ManyToManyField",
"ForeignObjectRel",
"ManyToOneRel",
"ManyToManyRel",
"OneToOneRel",
"Collect",
"Extent",
"Extent3D",
"MakeLine",
"Union",
"GeometryCollectionField",
"GeometryField",
"LineStringField",
"MultiLineStringField",
"MultiPointField",
"MultiPolygonField",
"PointField",
"PolygonField",
"RasterField",
"signals",
]
@@ -15,19 +15,19 @@ from django.contrib.gis.gdal.srs import CoordTransform as CoordTransform
from django.contrib.gis.gdal.srs import SpatialReference as SpatialReference
__all__ = (
"GDAL_VERSION",
"AxisOrder",
"Driver",
"DataSource",
"CoordTransform",
"DataSource",
"Driver",
"Envelope",
"GDALException",
"GDALRaster",
"GDAL_VERSION",
"OGRGeometry",
"OGRGeomType",
"SpatialReference",
"OGRGeometry",
"SRSException",
"SpatialReference",
"check_err",
"gdal_version",
"gdal_full_version",
"gdal_version",
)
@@ -9,4 +9,4 @@ class WKBReader(_WKBReader):
class WKTReader(_WKTReader):
def read(self, wkt: bytes | str) -> GEOSGeometry: ...
__all__ = ["WKBWriter", "WKTWriter", "WKBReader", "WKTReader"]
__all__ = ["WKBReader", "WKBWriter", "WKTReader", "WKTWriter"]
@@ -11,4 +11,4 @@ geos_distance: Any
geos_length: Any
geos_isvalidreason: Any
__all__ = ["geos_area", "geos_distance", "geos_length", "geos_isvalidreason"]
__all__ = ["geos_area", "geos_distance", "geos_isvalidreason", "geos_length"]
@@ -5,4 +5,4 @@ from django.contrib.gis.utils.ogrinspect import mapping as mapping
from django.contrib.gis.utils.ogrinspect import ogrinspect as ogrinspect
from django.contrib.gis.utils.srs import add_srs_entry as add_srs_entry
__all__ = ["add_srs_entry", "mapping", "ogrinfo", "ogrinspect", "LayerMapError", "LayerMapping"]
__all__ = ["LayerMapError", "LayerMapping", "add_srs_entry", "mapping", "ogrinfo", "ogrinspect"]
@@ -48,14 +48,14 @@ def error(
) -> None: ...
__all__ = (
"MessageFailure",
"add_message",
"get_messages",
"get_level",
"set_level",
"debug",
"error",
"get_level",
"get_messages",
"info",
"set_level",
"success",
"warning",
"error",
"MessageFailure",
)
@@ -29,16 +29,16 @@ class RegrSXY(StatAggregate): ...
class RegrSYY(StatAggregate): ...
__all__ = [
"CovarPop",
"Corr",
"CovarPop",
"RegrAvgX",
"RegrAvgY",
"RegrCount",
"RegrIntercept",
"RegrR2",
"RegrSlope",
"RegrSXX",
"RegrSXY",
"RegrSYY",
"RegrSlope",
"StatAggregate",
]
@@ -48,8 +48,8 @@ class DecimalRangeField(RangeField[NumericRange]):
form_field: type[forms.DecimalRangeField]
class DateTimeRangeField(RangeField[DateTimeTZRange]):
base_field: type[models.DecimalField]
form_field: type[forms.DecimalRangeField]
base_field: type[models.DateTimeField]
form_field: type[forms.DateTimeRangeField]
class DateRangeField(RangeField[DateRange]):
base_field: type[models.DateField]
@@ -91,12 +91,12 @@ class UpperInfinite(models.Transform):
output_field: ClassVar[models.BooleanField]
__all__ = [
"RangeField",
"IntegerRangeField",
"BigIntegerRangeField",
"DecimalRangeField",
"DateTimeRangeField",
"DateRangeField",
"DateTimeRangeField",
"DecimalRangeField",
"IntegerRangeField",
"RangeBoundary",
"RangeField",
"RangeOperators",
]
@@ -43,10 +43,10 @@ class DateRangeField(BaseRangeField):
__all__ = [
"BaseRangeField",
"IntegerRangeField",
"DecimalRangeField",
"DateTimeRangeField",
"DateRangeField",
"DateTimeRangeField",
"DecimalRangeField",
"HiddenRangeWidget",
"IntegerRangeField",
"RangeWidget",
]
@@ -121,4 +121,4 @@ class OpClass(Func):
name: str,
) -> None: ...
__all__ = ["BloomIndex", "BrinIndex", "BTreeIndex", "GinIndex", "GistIndex", "HashIndex", "SpGistIndex"]
__all__ = ["BTreeIndex", "BloomIndex", "BrinIndex", "GinIndex", "GistIndex", "HashIndex", "SpGistIndex"]
@@ -1,10 +1,10 @@
from typing import Any
from typing import ClassVar
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.http.response import HttpResponse, HttpResponseBase, HttpResponseRedirectBase
from django.utils.deprecation import MiddlewareMixin
class RedirectFallbackMiddleware(MiddlewareMixin):
response_gone_class: Any
response_redirect_class: Any
response_gone_class: ClassVar[type[HttpResponseBase]]
response_redirect_class: ClassVar[type[HttpResponseRedirectBase]]
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...
@@ -22,11 +22,11 @@ caches: CacheHandler
cache: BaseCache
__all__ = [
"DEFAULT_CACHE_ALIAS",
"BaseCache",
"CacheKeyWarning",
"InvalidCacheBackendError",
"InvalidCacheKey",
"cache",
"caches",
"DEFAULT_CACHE_ALIAS",
"InvalidCacheBackendError",
"CacheKeyWarning",
"BaseCache",
"InvalidCacheKey",
]
@@ -16,19 +16,19 @@ from .registry import run_checks as run_checks
from .registry import tag_exists as tag_exists
__all__ = [
"CheckMessage",
"Debug",
"Info",
"Warning",
"Error",
"Critical",
"CRITICAL",
"DEBUG",
"ERROR",
"INFO",
"WARNING",
"ERROR",
"CRITICAL",
"CheckMessage",
"Critical",
"Debug",
"Error",
"Info",
"Tags",
"Warning",
"register",
"run_checks",
"tag_exists",
"Tags",
]
@@ -16,4 +16,4 @@ if sys.platform == "win32":
def lock(f: Any, flags: int) -> bool: ...
def unlock(f: Any) -> bool: ...
__all__ = ("LOCK_EX", "LOCK_SH", "LOCK_NB", "lock", "unlock")
__all__ = ("LOCK_EX", "LOCK_NB", "LOCK_SH", "lock", "unlock")
@@ -6,13 +6,13 @@ from .handler import InvalidStorageError, StorageHandler
from .memory import InMemoryStorage
__all__ = (
"DefaultStorage",
"FileSystemStorage",
"InMemoryStorage",
"Storage",
"DefaultStorage",
"default_storage",
"InvalidStorageError",
"Storage",
"StorageHandler",
"default_storage",
"storages",
)
@@ -6,7 +6,7 @@ from typing_extensions import Self
class UploadedFile(File):
content_type: str | None
charset: str | None
content_type_extra: dict[str, str] | None
content_type_extra: dict[str, bytes] | None
size: int | None # type: ignore[assignment]
name: str | None
def __init__(
@@ -16,7 +16,7 @@ class UploadedFile(File):
content_type: str | None = None,
size: int | None = None,
charset: str | None = None,
content_type_extra: dict[str, str] | None = None,
content_type_extra: dict[str, bytes] | None = None,
) -> None: ...
class TemporaryUploadedFile(UploadedFile):
@@ -26,7 +26,7 @@ class TemporaryUploadedFile(UploadedFile):
content_type: str | None,
size: int | None,
charset: str | None,
content_type_extra: dict[str, str] | None = None,
content_type_extra: dict[str, bytes] | None = None,
) -> None: ...
def temporary_file_path(self) -> str: ...
@@ -40,7 +40,7 @@ class InMemoryUploadedFile(UploadedFile):
content_type: str | None,
size: int | None,
charset: str | None,
content_type_extra: dict[str, str] | None = None,
content_type_extra: dict[str, bytes] | None = None,
) -> None: ...
def open(self, mode: str | None = None) -> Self: ... # type: ignore[override]
@@ -50,8 +50,8 @@ class SimpleUploadedFile(InMemoryUploadedFile):
def from_dict(cls, file_dict: dict[str, str | bytes]) -> Self: ...
__all__ = (
"UploadedFile",
"TemporaryUploadedFile",
"InMemoryUploadedFile",
"SimpleUploadedFile",
"TemporaryUploadedFile",
"UploadedFile",
)
@@ -19,7 +19,7 @@ class FileUploadHandler:
content_type: str | None
content_length: int | None
charset: str | None
content_type_extra: dict[str, str] | None
content_type_extra: dict[str, bytes] | None
request: HttpRequest | None
field_name: str
def __init__(self, request: HttpRequest | None = None) -> None: ...
@@ -38,7 +38,7 @@ class FileUploadHandler:
content_type: str,
content_length: int | None,
charset: str | None = None,
content_type_extra: dict[str, str] | None = None,
content_type_extra: dict[str, bytes] | None = None,
) -> None: ...
def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ...
def file_complete(self, file_size: int) -> UploadedFile | None: ...
@@ -54,7 +54,7 @@ class TemporaryFileUploadHandler(FileUploadHandler):
content_type: str,
content_length: int | None,
charset: str | None = ...,
content_type_extra: dict[str, str] | None = ...,
content_type_extra: dict[str, bytes] | None = ...,
) -> None: ...
def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ...
def file_complete(self, file_size: int) -> UploadedFile | None: ...
@@ -78,7 +78,7 @@ class MemoryFileUploadHandler(FileUploadHandler):
content_type: str,
content_length: int | None,
charset: str | None = ...,
content_type_extra: dict[str, str] | None = ...,
content_type_extra: dict[str, bytes] | None = ...,
) -> None: ...
def receive_data_chunk(self, raw_data: bytes, start: int) -> bytes | None: ...
def file_complete(self, file_size: int) -> UploadedFile | None: ...
@@ -86,12 +86,12 @@ class MemoryFileUploadHandler(FileUploadHandler):
def load_handler(path: str, *args: Any, **kwargs: Any) -> FileUploadHandler: ...
__all__ = [
"UploadFileException",
"StopUpload",
"SkipFile",
"FileUploadHandler",
"TemporaryFileUploadHandler",
"MemoryFileUploadHandler",
"load_handler",
"SkipFile",
"StopFutureHandlers",
"StopUpload",
"TemporaryFileUploadHandler",
"UploadFileException",
"load_handler",
]
@@ -53,21 +53,21 @@ def mail_managers(
outbox: list[EmailMessage]
__all__ = [
"CachedDnsName",
"DNS_NAME",
"EmailMessage",
"EmailMultiAlternatives",
"SafeMIMEText",
"SafeMIMEMultipart",
"DEFAULT_ATTACHMENT_MIME_TYPE",
"make_msgid",
"DNS_NAME",
"BadHeaderError",
"forbid_multi_line_headers",
"get_connection",
"send_mail",
"send_mass_mail",
"mail_admins",
"mail_managers",
"CachedDnsName",
"EmailAlternative",
"EmailAttachment",
"EmailMessage",
"EmailMultiAlternatives",
"SafeMIMEMultipart",
"SafeMIMEText",
"forbid_multi_line_headers",
"get_connection",
"mail_admins",
"mail_managers",
"make_msgid",
"send_mail",
"send_mass_mail",
]
@@ -46,4 +46,4 @@ def run(
server_cls: type[WSGIServer] = ...,
) -> None: ...
__all__ = ("WSGIServer", "WSGIRequestHandler")
__all__ = ("WSGIRequestHandler", "WSGIServer")
@@ -23,20 +23,20 @@ def close_old_connections(**kwargs: Any) -> None: ...
def reset_queries(**kwargs: Any) -> None: ...
__all__ = [
"DEFAULT_DB_ALIAS",
"DJANGO_VERSION_PICKLE_KEY",
"DataError",
"DatabaseError",
"Error",
"IntegrityError",
"InterfaceError",
"InternalError",
"NotSupportedError",
"OperationalError",
"ProgrammingError",
"close_old_connections",
"connection",
"connections",
"reset_queries",
"router",
"DatabaseError",
"IntegrityError",
"InternalError",
"ProgrammingError",
"DataError",
"NotSupportedError",
"Error",
"InterfaceError",
"OperationalError",
"DEFAULT_DB_ALIAS",
"DJANGO_VERSION_PICKLE_KEY",
]
@@ -23,27 +23,27 @@ from .special import RunSQL as RunSQL
from .special import SeparateDatabaseAndState as SeparateDatabaseAndState
__all__ = [
"CreateModel",
"DeleteModel",
"AddConstraint",
"AddField",
"AddIndex",
"AlterConstraint",
"AlterField",
"AlterIndexTogether",
"AlterModelManagers",
"AlterModelOptions",
"AlterModelTable",
"AlterModelTableComment",
"AlterUniqueTogether",
"RenameModel",
"AlterIndexTogether",
"AlterModelOptions",
"AddIndex",
"RemoveIndex",
"RenameIndex",
"AddField",
"RemoveField",
"AlterField",
"RenameField",
"AddConstraint",
"RemoveConstraint",
"AlterConstraint",
"SeparateDatabaseAndState",
"RunSQL",
"RunPython",
"AlterOrderWithRespectTo",
"AlterModelManagers",
"AlterUniqueTogether",
"CreateModel",
"DeleteModel",
"RemoveConstraint",
"RemoveField",
"RemoveIndex",
"RenameField",
"RenameIndex",
"RenameModel",
"RunPython",
"RunSQL",
"SeparateDatabaseAndState",
]
@@ -96,8 +96,8 @@ class AlterIndexTogether(AlterTogetherOptionOperation):
class AlterOrderWithRespectTo(ModelOptionOperation):
option_name: str
order_with_respect_to: str
def __init__(self, name: str, order_with_respect_to: str) -> None: ...
order_with_respect_to: str | None
def __init__(self, name: str, order_with_respect_to: str | None) -> None: ...
class AlterModelOptions(ModelOptionOperation):
ALTER_OPTION_KEYS: list[str]
@@ -103,105 +103,105 @@ from .query_utils import FilteredRelation as FilteredRelation
from .query_utils import Q as Q
__all__ = [
"Aggregate",
"Avg",
"Count",
"Max",
"Min",
"StdDev",
"Sum",
"Variance",
"BaseConstraint",
"CheckConstraint",
"Deferrable",
"UniqueConstraint",
"Choices",
"IntegerChoices",
"TextChoices",
"AutoField",
"BLANK_CHOICE_DASH",
"BigAutoField",
"BigIntegerField",
"BinaryField",
"BooleanField",
"CharField",
"CommaSeparatedIntegerField",
"DateField",
"DateTimeField",
"DecimalField",
"DurationField",
"EmailField",
"Empty",
"Field",
"FilePathField",
"FloatField",
"GenericIPAddressField",
"IPAddressField",
"IntegerField",
"NOT_PROVIDED",
"NullBooleanField",
"PositiveBigIntegerField",
"PositiveIntegerField",
"PositiveSmallIntegerField",
"SlugField",
"SmallAutoField",
"SmallIntegerField",
"TextField",
"TimeField",
"URLField",
"UUIDField",
"Index",
"ObjectDoesNotExist",
"signals",
"CASCADE",
"DEFERRED",
"DO_NOTHING",
"NOT_PROVIDED",
"PROTECT",
"RESTRICT",
"SET",
"SET_DEFAULT",
"SET_NULL",
"ProtectedError",
"RestrictedError",
"Aggregate",
"AutoField",
"Avg",
"BaseConstraint",
"BigAutoField",
"BigIntegerField",
"BinaryField",
"BooleanField",
"Case",
"CharField",
"CheckConstraint",
"Choices",
"CommaSeparatedIntegerField",
"CompositePrimaryKey",
"Count",
"DateField",
"DateTimeField",
"DecimalField",
"Deferrable",
"DurationField",
"EmailField",
"Empty",
"Exists",
"Expression",
"ExpressionList",
"ExpressionWrapper",
"F",
"Field",
"FileField",
"FilePathField",
"FilteredRelation",
"FloatField",
"ForeignKey",
"ForeignObject",
"ForeignObjectRel",
"Func",
"GeneratedField",
"GenericIPAddressField",
"IPAddressField",
"ImageField",
"Index",
"IntegerChoices",
"IntegerField",
"JSONField",
"Lookup",
"Manager",
"ManyToManyField",
"ManyToManyRel",
"ManyToOneRel",
"Max",
"Min",
"Model",
"NullBooleanField",
"ObjectDoesNotExist",
"OneToOneField",
"OneToOneRel",
"OrderBy",
"OrderWrt",
"OuterRef",
"PositiveBigIntegerField",
"PositiveIntegerField",
"PositiveSmallIntegerField",
"Prefetch",
"ProtectedError",
"Q",
"QuerySet",
"RestrictedError",
"RowRange",
"SlugField",
"SmallAutoField",
"SmallIntegerField",
"StdDev",
"Subquery",
"Sum",
"TextChoices",
"TextField",
"TimeField",
"Transform",
"URLField",
"UUIDField",
"UniqueConstraint",
"Value",
"ValueRange",
"Variance",
"When",
"Window",
"WindowFrame",
"WindowFrameExclusion",
"FileField",
"ImageField",
"GeneratedField",
"JSONField",
"OrderWrt",
"Lookup",
"Transform",
"Manager",
"Prefetch",
"Q",
"QuerySet",
"aprefetch_related_objects",
"prefetch_related_objects",
"DEFERRED",
"Model",
"FilteredRelation",
"ForeignKey",
"ForeignObject",
"OneToOneField",
"ManyToManyField",
"ForeignObjectRel",
"ManyToOneRel",
"ManyToManyRel",
"OneToOneRel",
"signals",
]
@@ -263,7 +263,7 @@ class FloatField(Field[_ST, _GT]):
class DecimalField(Field[_ST, _GT]):
_pyi_private_set_type: str | float | decimal.Decimal | Combinable
_pyi_private_get_type: decimal.Decimal
_pyi_lookup_exact_type: str | decimal.Decimal
_pyi_lookup_exact_type: str | int | decimal.Decimal
# attributes
max_digits: int
decimal_places: int
@@ -635,8 +635,9 @@ class BigAutoField(AutoFieldMixin, BigIntegerField[_ST, _GT]): ... # type: igno
class SmallAutoField(AutoFieldMixin, SmallIntegerField[_ST, _GT]): ... # type: ignore[misc]
__all__ = [
"AutoField",
"BLANK_CHOICE_DASH",
"NOT_PROVIDED",
"AutoField",
"BigAutoField",
"BigIntegerField",
"BinaryField",
@@ -655,7 +656,6 @@ __all__ = [
"GenericIPAddressField",
"IPAddressField",
"IntegerField",
"NOT_PROVIDED",
"NullBooleanField",
"PositiveBigIntegerField",
"PositiveIntegerField",
@@ -91,27 +91,91 @@ from .window import Rank as Rank
from .window import RowNumber as RowNumber
__all__ = [
# text
"MD5",
"SHA1",
"SHA224",
"SHA256",
"SHA384",
"SHA512",
"ACos",
"ASin",
"ATan",
"ATan2",
# math
"Abs",
# comparison and conversion
"Cast",
"Ceil",
"Chr",
"Coalesce",
"Collate",
"Greatest",
"Least",
"NullIf",
"Concat",
"ConcatPair",
"Cos",
"Cot",
# window
"CumeDist",
"Degrees",
"DenseRank",
"Exp",
# datetime
"Extract",
"ExtractDay",
"ExtractHour",
"ExtractIsoWeekDay",
"ExtractIsoYear",
"ExtractMinute",
"ExtractMonth",
"ExtractQuarter",
"ExtractSecond",
"ExtractWeek",
"ExtractIsoWeekDay",
"ExtractWeekDay",
"ExtractIsoYear",
"ExtractYear",
"FirstValue",
"Floor",
"Greatest",
# json
"JSONArray",
"JSONObject",
"LPad",
"LTrim",
"Lag",
"LastValue",
"Lead",
"Least",
"Left",
"Length",
"Ln",
"Log",
"Lower",
"Mod",
"Now",
"NthValue",
"Ntile",
"NullIf",
"Ord",
"PercentRank",
"Pi",
"Power",
"RPad",
"RTrim",
"Radians",
"Random",
"Rank",
"Repeat",
"Replace",
"Reverse",
"Right",
"Round",
"RowNumber",
"Sign",
"Sin",
"Sqrt",
"StrIndex",
"Substr",
"Tan",
"Trim",
"Trunc",
"TruncDate",
"TruncDay",
@@ -123,69 +187,5 @@ __all__ = [
"TruncTime",
"TruncWeek",
"TruncYear",
# json
"JSONArray",
"JSONObject",
# math
"Abs",
"ACos",
"ASin",
"ATan",
"ATan2",
"Ceil",
"Cos",
"Cot",
"Degrees",
"Exp",
"Floor",
"Ln",
"Log",
"Mod",
"Pi",
"Power",
"Radians",
"Random",
"Round",
"Sign",
"Sin",
"Sqrt",
"Tan",
# text
"MD5",
"SHA1",
"SHA224",
"SHA256",
"SHA384",
"SHA512",
"Chr",
"Concat",
"ConcatPair",
"Left",
"Length",
"Lower",
"LPad",
"LTrim",
"Ord",
"Repeat",
"Replace",
"Reverse",
"Right",
"RPad",
"RTrim",
"StrIndex",
"Substr",
"Trim",
"Upper",
# window
"CumeDist",
"DenseRank",
"FirstValue",
"Lag",
"LastValue",
"Lead",
"NthValue",
"Ntile",
"PercentRank",
"Rank",
"RowNumber",
]
@@ -1,7 +1,6 @@
from collections.abc import Iterable, Sequence
from typing import Any, Generic, Literal, TypeVar
from django.core.exceptions import EmptyResultSet
from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models.expressions import Combinable, Expression, Func
from django.db.models.fields import BooleanField
@@ -79,8 +78,8 @@ class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
class IntegerFieldOverflow:
underflow_exception: type[EmptyResultSet]
overflow_exception: type[EmptyResultSet]
underflow_exception: type[Exception]
overflow_exception: type[Exception]
def process_rhs(self, compiler: SQLCompiler, connection: BaseDatabaseWrapper) -> _AsSqlType: ...
class IntegerFieldFloatRounding:
@@ -1,10 +1,10 @@
import datetime
from collections.abc import AsyncIterator, Collection, Iterable, Iterator, Mapping, Sequence
from typing import Any, Generic, NoReturn, TypeVar, overload
from typing import Any, Generic, Literal, NoReturn, TypeVar, overload
from django.db.models.base import Model
from django.db.models.expressions import Combinable, OrderBy
from django.db.models.query import QuerySet, RawQuerySet
from django.db.models.query import Prefetch, QuerySet, RawQuerySet, _LookupT, _PrefetchedQuerySetT, _ToAttrT
from typing_extensions import Self
_T = TypeVar("_T", bound=Model, covariant=True)
@@ -93,8 +93,8 @@ class Manager(BaseManager[_T]):
async def aupdate(self, **kwargs: Any) -> int: ...
def exists(self) -> bool: ...
async def aexists(self) -> bool: ...
def explain(self, *, format: Any | None = ..., **options: Any) -> str: ...
async def aexplain(self, *, format: Any | None = ..., **options: Any) -> str: ...
def explain(self, *, format: str | None = ..., **options: Any) -> str: ...
async def aexplain(self, *, format: str | None = ..., **options: Any) -> str: ...
def contains(self, obj: Model) -> bool: ...
async def acontains(self, obj: Model) -> bool: ...
def raw(
@@ -103,14 +103,23 @@ class Manager(BaseManager[_T]):
params: Any = ...,
translations: dict[str, str] | None = ...,
using: str | None = ...,
) -> RawQuerySet: ...
) -> RawQuerySet[_T]: ...
# The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param
def values(self, *fields: str | Combinable, **expressions: Any) -> QuerySet[_T, dict[str, Any]]: ...
# The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param
def values_list(self, *fields: str | Combinable, flat: bool = ..., named: bool = ...) -> QuerySet[_T, Any]: ...
def dates(self, field_name: str, kind: str, order: str = ...) -> QuerySet[_T, datetime.date]: ...
def dates(
self,
field_name: str,
kind: Literal["year", "month", "week", "day"],
order: Literal["ASC", "DESC"] = "ASC",
) -> QuerySet[_T, datetime.date]: ...
def datetimes(
self, field_name: str, kind: str, order: str = ..., tzinfo: datetime.tzinfo | None = ...
self,
field_name: str,
kind: Literal["year", "month", "week", "day", "hour", "minute", "second"],
order: Literal["ASC", "DESC"] = "ASC",
tzinfo: datetime.tzinfo | None = None,
) -> QuerySet[_T, datetime.datetime]: ...
def none(self) -> QuerySet[_T]: ...
def filter(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
@@ -118,18 +127,24 @@ class Manager(BaseManager[_T]):
def complex_filter(self, filter_obj: Any) -> QuerySet[_T]: ...
def count(self) -> int: ...
async def acount(self) -> int: ...
def union(self, *other_qs: Any, all: bool = ...) -> QuerySet[_T]: ...
def intersection(self, *other_qs: Any) -> QuerySet[_T]: ...
def difference(self, *other_qs: Any) -> QuerySet[_T]: ...
def union(self, *other_qs: QuerySet[Model, Any], all: bool = ...) -> QuerySet[_T]: ...
def intersection(self, *other_qs: QuerySet[Model, Any]) -> QuerySet[_T]: ...
def difference(self, *other_qs: QuerySet[Model, Any]) -> QuerySet[_T]: ...
def select_for_update(
self, nowait: bool = ..., skip_locked: bool = ..., of: Sequence[str] = ..., no_key: bool = ...
) -> QuerySet[_T]: ...
def select_related(self, *fields: Any) -> QuerySet[_T]: ...
def prefetch_related(self, *lookups: Any) -> QuerySet[_T]: ...
@overload
def select_related(self, clear: None, /) -> QuerySet[_T]: ...
@overload
def select_related(self, *fields: str) -> QuerySet[_T]: ...
@overload
def prefetch_related(self, clear: None, /) -> QuerySet[_T]: ...
@overload
def prefetch_related(self, *lookups: str | Prefetch[_LookupT, _PrefetchedQuerySetT, _ToAttrT]) -> QuerySet[_T]: ...
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def alias(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ...
def order_by(self, *field_names: Any) -> QuerySet[_T]: ...
def distinct(self, *field_names: Any) -> QuerySet[_T]: ...
def order_by(self, *field_names: str | Combinable) -> QuerySet[_T]: ...
def distinct(self, *field_names: str) -> QuerySet[_T]: ...
# extra() return type won't be supported any time soon
def extra(
self,
@@ -141,8 +156,11 @@ class Manager(BaseManager[_T]):
select_params: Sequence[Any] | None = ...,
) -> QuerySet[Any]: ...
def reverse(self) -> QuerySet[_T]: ...
def defer(self, *fields: Any) -> QuerySet[_T]: ...
def only(self, *fields: Any) -> QuerySet[_T]: ...
@overload
def defer(self, clear: None, /) -> QuerySet[_T]: ...
@overload
def defer(self, *fields: str) -> QuerySet[_T]: ...
def only(self, *fields: str) -> QuerySet[_T]: ...
def using(self, alias: str | None) -> QuerySet[_T]: ...
class ManagerDescriptor:
@@ -1,5 +1,5 @@
from collections.abc import Iterable, Sequence
from typing import Any, Generic, Literal, TypeAlias, TypeVar, overload
from typing import Any, Generic, TypeAlias, TypeVar, overload
from django.apps.config import AppConfig
from django.apps.registry import Apps
@@ -64,7 +64,7 @@ class Options(Generic[_M]):
order_with_respect_to: str | None
db_tablespace: str
required_db_features: _ListOrTuple[str]
required_db_vendor: Literal["sqlite", "postgresql", "mysql", "oracle"] | None
required_db_vendor: str | None
meta: type | None
pk: Field
auto_field: AutoField | None
@@ -1,6 +1,6 @@
import datetime
from collections.abc import AsyncIterator, Collection, Iterable, Iterator, Mapping, Sequence, Sized
from typing import Any, Generic, NamedTuple, TypeAlias, overload
from typing import Any, Generic, Literal, NamedTuple, TypeAlias, overload
from django.db.backends.utils import _ExecuteQuery
from django.db.models import Manager
@@ -15,8 +15,20 @@ _Model = TypeVar("_Model", bound=Model, covariant=True)
_Row = TypeVar("_Row", covariant=True, default=_Model) # ONLY use together with _Model
_TupleT = TypeVar("_TupleT", bound=tuple[Any, ...], covariant=True)
# The type of the lookup passed to Prefetch(...)
# This will be specialized to a `LiteralString` in the plugin for further processing and validation
_LookupT = TypeVar("_LookupT", bound=str, covariant=True)
# The type of the queryset passed to Prefetch(...)
_PrefetchedQuerySetT = TypeVar("_PrefetchedQuerySetT", bound=QuerySet[Model], covariant=True, default=QuerySet[Model])
# The attribute name to store the prefetched list[_PrefetchedQuerySetT]
# This will be specialized to a `LiteralString` in the plugin for further processing and validation
_ToAttrT = TypeVar("_ToAttrT", bound=str, covariant=True, default=str)
_OrderByFieldName: TypeAlias = str | Combinable
MAX_GET_RESULTS: int
REPR_OUTPUT_SIZE: int
PROHIBITED_FILTER_KWARGS: frozenset[str]
class BaseIterable(Generic[_T]):
queryset: QuerySet[Model]
@@ -25,7 +37,7 @@ class BaseIterable(Generic[_T]):
def __init__(self, queryset: QuerySet[Model], chunked_fetch: bool = False, chunk_size: int = 100) -> None: ...
def __aiter__(self) -> AsyncIterator[_T]: ...
class ModelIterable(Generic[_Model], BaseIterable[_Model]):
class ModelIterable(BaseIterable[_Model], Generic[_Model]):
def __iter__(self) -> Iterator[_Model]: ...
class RawModelIterable(BaseIterable[dict[str, Any]]):
@@ -43,7 +55,7 @@ class NamedValuesListIterable(ValuesListIterable[NamedTuple]):
class FlatValuesListIterable(BaseIterable[_T]):
def __iter__(self) -> Iterator[_T]: ...
class QuerySet(Generic[_Model, _Row], Iterable[_Row], Sized):
class QuerySet(Iterable[_Row], Sized, Generic[_Model, _Row]):
model: type[_Model]
query: Query
_iterable_class: type[BaseIterable]
@@ -127,8 +139,8 @@ class QuerySet(Generic[_Model, _Row], Iterable[_Row], Sized):
async def aupdate(self, **kwargs: Any) -> int: ...
def exists(self) -> bool: ...
async def aexists(self) -> bool: ...
def explain(self, *, format: Any | None = None, **options: Any) -> str: ...
async def aexplain(self, *, format: Any | None = None, **options: Any) -> str: ...
def explain(self, *, format: str | None = None, **options: Any) -> str: ...
async def aexplain(self, *, format: str | None = None, **options: Any) -> str: ...
def contains(self, obj: Model) -> bool: ...
async def acontains(self, obj: Model) -> bool: ...
def raw(
@@ -137,16 +149,25 @@ class QuerySet(Generic[_Model, _Row], Iterable[_Row], Sized):
params: Any = (),
translations: dict[str, str] | None = None,
using: str | None = None,
) -> RawQuerySet: ...
) -> RawQuerySet[_Model]: ...
# The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param
def values(self, *fields: str | Combinable, **expressions: Any) -> QuerySet[_Model, dict[str, Any]]: ...
# The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param
def values_list(
self, *fields: str | Combinable, flat: bool = False, named: bool = False
) -> QuerySet[_Model, Any]: ...
def dates(self, field_name: str, kind: str, order: str = "ASC") -> QuerySet[_Model, datetime.date]: ...
def dates(
self,
field_name: str,
kind: Literal["year", "month", "week", "day"],
order: Literal["ASC", "DESC"] = "ASC",
) -> QuerySet[_Model, datetime.date]: ...
def datetimes(
self, field_name: str, kind: str, order: str = "ASC", tzinfo: datetime.tzinfo | None = None
self,
field_name: str,
kind: Literal["year", "month", "week", "day", "hour", "minute", "second"],
order: Literal["ASC", "DESC"] = "ASC",
tzinfo: datetime.tzinfo | None = None,
) -> QuerySet[_Model, datetime.datetime]: ...
def none(self) -> Self: ...
def all(self) -> Self: ...
@@ -155,18 +176,24 @@ class QuerySet(Generic[_Model, _Row], Iterable[_Row], Sized):
def complex_filter(self, filter_obj: Any) -> Self: ...
def count(self) -> int: ...
async def acount(self) -> int: ...
def union(self, *other_qs: Any, all: bool = False) -> Self: ...
def intersection(self, *other_qs: Any) -> Self: ...
def difference(self, *other_qs: Any) -> Self: ...
def union(self, *other_qs: QuerySet[Model, Any], all: bool = False) -> Self: ...
def intersection(self, *other_qs: QuerySet[Model, Any]) -> Self: ...
def difference(self, *other_qs: QuerySet[Model, Any]) -> Self: ...
def select_for_update(
self, nowait: bool = False, skip_locked: bool = False, of: Sequence[str] = (), no_key: bool = False
) -> Self: ...
def select_related(self, *fields: Any) -> Self: ...
def prefetch_related(self, *lookups: Any) -> Self: ...
@overload
def select_related(self, clear: None, /) -> Self: ...
@overload
def select_related(self, *fields: str) -> Self: ...
@overload
def prefetch_related(self, clear: None, /) -> Self: ...
@overload
def prefetch_related(self, *lookups: str | Prefetch[_LookupT, _PrefetchedQuerySetT, _ToAttrT]) -> Self: ...
def annotate(self, *args: Any, **kwargs: Any) -> Self: ...
def alias(self, *args: Any, **kwargs: Any) -> Self: ...
def order_by(self, *field_names: Any) -> Self: ...
def distinct(self, *field_names: Any) -> Self: ...
def order_by(self, *field_names: _OrderByFieldName) -> Self: ...
def distinct(self, *field_names: str) -> Self: ...
# extra() return type won't be supported any time soon
def extra(
self,
@@ -174,12 +201,15 @@ class QuerySet(Generic[_Model, _Row], Iterable[_Row], Sized):
where: Sequence[str] | None = None,
params: Sequence[Any] | None = None,
tables: Sequence[str] | None = None,
order_by: Sequence[str] | None = None,
order_by: Sequence[_OrderByFieldName] | None = None,
select_params: Sequence[Any] | None = None,
) -> QuerySet[Any, Any]: ...
def reverse(self) -> Self: ...
def defer(self, *fields: Any) -> Self: ...
def only(self, *fields: Any) -> Self: ...
@overload
def defer(self, clear: None, /) -> Self: ...
@overload
def defer(self, *fields: str) -> Self: ...
def only(self, *fields: str) -> Self: ...
def using(self, alias: str | None) -> Self: ...
@property
def ordered(self) -> bool: ...
@@ -219,7 +249,7 @@ class RawQuerySet(Iterable[_Model], Sized):
@overload
def __getitem__(self, k: str) -> Any: ...
@overload
def __getitem__(self, k: slice) -> RawQuerySet[_Model]: ...
def __getitem__(self, k: slice) -> Self: ...
@cached_property
def columns(self) -> list[str]: ...
@property
@@ -227,19 +257,24 @@ class RawQuerySet(Iterable[_Model], Sized):
def iterator(self) -> Iterator[_Model]: ...
@cached_property
def model_fields(self) -> dict[str, str]: ...
def prefetch_related(self, *lookups: Any) -> RawQuerySet[_Model]: ...
@overload
def prefetch_related(self, clear: None, /) -> Self: ...
@overload
def prefetch_related(self, *lookups: str | Prefetch[_LookupT, _PrefetchedQuerySetT, _ToAttrT]) -> Self: ...
def resolve_model_init_order(self) -> tuple[list[str], list[int], list[tuple[str, int]]]: ...
def using(self, alias: str | None) -> RawQuerySet[_Model]: ...
def using(self, alias: str | None) -> Self: ...
# Deprecated alias of QuerySet, for compatibility only.
_QuerySet: TypeAlias = QuerySet # noqa: PYI047
class Prefetch:
class Prefetch(Generic[_LookupT, _PrefetchedQuerySetT, _ToAttrT]):
prefetch_through: str
prefetch_to: str
queryset: QuerySet | None
to_attr: str | None
def __init__(self, lookup: str, queryset: QuerySet | None = None, to_attr: str | None = None) -> None: ...
queryset: _PrefetchedQuerySetT | None
to_attr: _ToAttrT | None
def __init__(
self, lookup: _LookupT, queryset: _PrefetchedQuerySetT | None = None, to_attr: _ToAttrT | None = None
) -> None: ...
def __getstate__(self) -> dict[str, Any]: ...
def add_prefix(self, prefix: str) -> None: ...
def get_current_prefetch_to(self, level: int) -> str: ...
@@ -247,8 +282,8 @@ class Prefetch:
@deprecated(
"get_current_queryset() is deprecated and will be removed in Django 6.0. Use get_current_querysets() instead."
)
def get_current_queryset(self, level: int) -> QuerySet | None: ...
def get_current_querysets(self, level: int) -> list[QuerySet] | None: ...
def get_current_queryset(self, level: int) -> _PrefetchedQuerySetT | None: ...
def get_current_querysets(self, level: int) -> list[_PrefetchedQuerySetT] | None: ...
def prefetch_related_objects(model_instances: Iterable[_Model], *related_lookups: str | Prefetch) -> None: ...
async def aprefetch_related_objects(model_instances: Iterable[_Model], *related_lookups: str | Prefetch) -> None: ...
@@ -27,9 +27,11 @@ class PathInfo(NamedTuple):
def subclasses(cls: type[RegisterLookupMixin]) -> Iterator[type[RegisterLookupMixin]]: ...
class Q(tree.Node):
AND: str
OR: str
AND: Literal["AND"]
OR: Literal["OR"]
XOR: Literal["XOR"]
conditional: bool
connectors: tuple[None, Literal["AND"], Literal["OR"], Literal["XOR"]]
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
# Fake signature, the real is
# def __init__(self, *args: Any, _connector: Any | None = ..., _negated: bool = ..., **kwargs: Any) -> None: ...
@@ -50,6 +52,7 @@ class Q(tree.Node):
def deconstruct(self) -> tuple[str, Sequence[Any], dict[str, Any]]: ...
@cached_property
def referenced_base_fields(self) -> set[str]: ...
def replace_expressions(self, replacements: dict[tree.Node, tree.Node]) -> tree.Node: ...
class DeferredAttribute:
field: Field
@@ -8,4 +8,4 @@ from .where import AND as AND
from .where import OR as OR
from .where import XOR as XOR
__all__ = ["Query", "AND", "OR", "XOR"]
__all__ = ["AND", "OR", "XOR", "Query"]
@@ -4,9 +4,10 @@ from typing import Any, Literal, NamedTuple
from django.db.backends.utils import CursorWrapper
from django.db.models import Field, FilteredRelation, Model, Q
from django.db.models.expressions import BaseExpression, Combinable, Expression, OrderBy
from django.db.models.expressions import BaseExpression, Combinable, Expression
from django.db.models.lookups import Lookup, Transform
from django.db.models.options import Options
from django.db.models.query import _OrderByFieldName
from django.db.models.query_utils import PathInfo
from django.db.models.sql.datastructures import BaseTable, Join
from django.db.models.sql.where import WhereNode
@@ -58,7 +59,7 @@ class Query(BaseExpression):
filter_is_sticky: bool
subquery: bool
group_by: None | Sequence[Combinable] | Sequence[str] | Literal[True]
order_by: Sequence[Any]
order_by: Sequence[_OrderByFieldName]
distinct: bool
distinct_fields: tuple[str, ...]
select: Sequence[BaseExpression]
@@ -78,7 +79,7 @@ class Query(BaseExpression):
combined_queries: tuple
extra_select_mask: set[str] | None
extra_tables: tuple
extra_order_by: Sequence[Any]
extra_order_by: Sequence[_OrderByFieldName]
deferred_loading: tuple[set[str] | frozenset[str], bool]
explain_query: bool
explain_format: str | None
@@ -188,9 +189,9 @@ class Query(BaseExpression):
def clear_select_clause(self) -> None: ...
def clear_select_fields(self) -> None: ...
def set_select(self, cols: list[Expression]) -> None: ...
def add_distinct_fields(self, *field_names: Any) -> None: ...
def add_distinct_fields(self, *field_names: str) -> None: ...
def add_fields(self, field_names: Iterable[str], allow_m2m: bool = True) -> None: ...
def add_ordering(self, *ordering: str | OrderBy) -> None: ...
def add_ordering(self, *ordering: _OrderByFieldName) -> None: ...
def clear_where(self) -> None: ...
def clear_ordering(self, force: bool = False, clear_default: bool = True) -> None: ...
def set_group_by(self, allow_aliases: bool = True) -> None: ...
@@ -202,7 +203,7 @@ class Query(BaseExpression):
where: Sequence[str] | None,
params: Sequence[str] | None,
tables: Sequence[str] | None,
order_by: Sequence[str] | None,
order_by: Sequence[_OrderByFieldName] | None,
) -> None: ...
def clear_deferred_loading(self) -> None: ...
def add_deferred_loading(self, field_names: Iterable[str]) -> None: ...
@@ -41,4 +41,4 @@ class AggregateQuery(Query):
where: WhereNode
where_class: type[WhereNode]
__all__ = ["DeleteQuery", "UpdateQuery", "InsertQuery", "AggregateQuery"]
__all__ = ["AggregateQuery", "DeleteQuery", "InsertQuery", "UpdateQuery"]
@@ -45,28 +45,4 @@ from .models import inlineformset_factory as inlineformset_factory
from .models import model_to_dict as model_to_dict
from .models import modelform_factory as modelform_factory
from .models import modelformset_factory as modelformset_factory
from .widgets import CheckboxInput as CheckboxInput
from .widgets import CheckboxSelectMultiple as CheckboxSelectMultiple
from .widgets import ClearableFileInput as ClearableFileInput
from .widgets import DateInput as DateInput
from .widgets import DateTimeInput as DateTimeInput
from .widgets import EmailInput as EmailInput
from .widgets import FileInput as FileInput
from .widgets import HiddenInput as HiddenInput
from .widgets import Media as Media
from .widgets import MultipleHiddenInput as MultipleHiddenInput
from .widgets import MultiWidget as MultiWidget
from .widgets import NullBooleanSelect as NullBooleanSelect
from .widgets import NumberInput as NumberInput
from .widgets import PasswordInput as PasswordInput
from .widgets import RadioSelect as RadioSelect
from .widgets import Select as Select
from .widgets import SelectDateWidget as SelectDateWidget
from .widgets import SelectMultiple as SelectMultiple
from .widgets import SplitDateTimeWidget as SplitDateTimeWidget
from .widgets import SplitHiddenDateTimeWidget as SplitHiddenDateTimeWidget
from .widgets import Textarea as Textarea
from .widgets import TextInput as TextInput
from .widgets import TimeInput as TimeInput
from .widgets import URLInput as URLInput
from .widgets import Widget as Widget
from .widgets import *
@@ -559,32 +559,32 @@ class JSONField(CharField):
def has_changed(self, initial: Any | None, data: Any | None) -> bool: ...
__all__ = (
"Field",
"CharField",
"IntegerField",
"DateField",
"TimeField",
"DateTimeField",
"DurationField",
"RegexField",
"EmailField",
"FileField",
"ImageField",
"URLField",
"BooleanField",
"NullBooleanField",
"CharField",
"ChoiceField",
"MultipleChoiceField",
"ComboField",
"MultiValueField",
"FloatField",
"DateField",
"DateTimeField",
"DecimalField",
"SplitDateTimeField",
"GenericIPAddressField",
"DurationField",
"EmailField",
"Field",
"FileField",
"FilePathField",
"FloatField",
"GenericIPAddressField",
"ImageField",
"IntegerField",
"JSONField",
"MultiValueField",
"MultipleChoiceField",
"NullBooleanField",
"RegexField",
"SlugField",
"SplitDateTimeField",
"TimeField",
"TypedChoiceField",
"TypedMultipleChoiceField",
"URLField",
"UUIDField",
)
@@ -1,5 +1,5 @@
from collections.abc import Iterable, Iterator, MutableMapping
from typing import Any, ClassVar
from collections.abc import Iterable, Iterator, Mapping, MutableMapping, Sequence
from typing import Any, ClassVar, overload
from django.core.exceptions import ValidationError
from django.forms.boundfield import BoundField
@@ -58,7 +58,16 @@ class BaseForm(RenderableFormMixin):
@property
def template_name(self) -> str: ...
def non_field_errors(self) -> ErrorList: ...
def add_error(self, field: str | None, error: ValidationError | _StrOrPromise) -> None: ...
@overload
def add_error(
self,
field: None,
error: Mapping[str, ValidationError | _StrOrPromise | Sequence[ValidationError | _StrOrPromise]],
) -> None: ...
@overload
def add_error(
self, field: str | None, error: ValidationError | _StrOrPromise | Sequence[ValidationError | _StrOrPromise]
) -> None: ...
def has_error(self, field: str | None, code: str | None = None) -> bool: ...
def full_clean(self) -> None: ...
def clean(self) -> dict[str, Any] | None: ...
@@ -25,7 +25,7 @@ class ManagementForm(Form):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean(self) -> dict[str, int | None]: ...
class BaseFormSet(Generic[_F], Sized, RenderableFormMixin):
class BaseFormSet(Sized, RenderableFormMixin, Generic[_F]):
form: type[_F]
extra: int
can_order: bool
@@ -125,4 +125,4 @@ def formset_factory(
) -> type[BaseFormSet[_F]]: ...
def all_valid(formsets: Sequence[BaseFormSet[_F]]) -> bool: ...
__all__ = ("BaseFormSet", "formset_factory", "all_valid")
__all__ = ("BaseFormSet", "all_valid", "formset_factory")
@@ -67,7 +67,7 @@ class ModelFormOptions(Generic[_M]):
class ModelFormMetaclass(DeclarativeFieldsMetaclass): ...
class BaseModelForm(Generic[_M], BaseForm):
class BaseModelForm(BaseForm, Generic[_M]):
instance: _M
_meta: ModelFormOptions[_M]
def __init__(
@@ -108,7 +108,7 @@ def modelform_factory(
_ModelFormT = TypeVar("_ModelFormT", bound=ModelForm)
class BaseModelFormSet(Generic[_M, _ModelFormT], BaseFormSet[_ModelFormT]):
class BaseModelFormSet(BaseFormSet[_ModelFormT], Generic[_M, _ModelFormT]):
model: type[_M]
edit_only: bool
unique_fields: Collection[str]
@@ -171,7 +171,7 @@ def modelformset_factory(
edit_only: bool = False,
) -> type[BaseModelFormSet[_M, _ModelFormT]]: ...
class BaseInlineFormSet(Generic[_M, _ParentM, _ModelFormT], BaseModelFormSet[_M, _ModelFormT]):
class BaseInlineFormSet(BaseModelFormSet[_M, _ModelFormT], Generic[_M, _ParentM, _ModelFormT]):
instance: _ParentM
save_as_new: bool
unique_fields: Collection[str]
@@ -316,16 +316,16 @@ def _get_foreign_key(
) -> ForeignKey: ...
__all__ = (
"ModelForm",
"BaseModelForm",
"model_to_dict",
"fields_for_model",
"ModelChoiceField",
"ModelMultipleChoiceField",
"ALL_FIELDS",
"BaseModelFormSet",
"modelformset_factory",
"BaseInlineFormSet",
"BaseModelForm",
"BaseModelFormSet",
"ModelChoiceField",
"ModelForm",
"ModelMultipleChoiceField",
"fields_for_model",
"inlineformset_factory",
"model_to_dict",
"modelform_factory",
"modelformset_factory",
)
@@ -320,34 +320,34 @@ class SelectDateWidget(Widget):
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
__all__ = (
"Script",
"Media",
"MediaDefiningClass",
"Widget",
"TextInput",
"NumberInput",
"EmailInput",
"URLInput",
"ColorInput",
"SearchInput",
"TelInput",
"PasswordInput",
"HiddenInput",
"MultipleHiddenInput",
"FileInput",
"CheckboxInput",
"CheckboxSelectMultiple",
"ClearableFileInput",
"Textarea",
"ColorInput",
"DateInput",
"DateTimeInput",
"TimeInput",
"CheckboxInput",
"Select",
"NullBooleanSelect",
"SelectMultiple",
"RadioSelect",
"CheckboxSelectMultiple",
"EmailInput",
"FileInput",
"HiddenInput",
"Media",
"MediaDefiningClass",
"MultiWidget",
"MultipleHiddenInput",
"NullBooleanSelect",
"NumberInput",
"PasswordInput",
"RadioSelect",
"Script",
"SearchInput",
"Select",
"SelectDateWidget",
"SelectMultiple",
"SplitDateTimeWidget",
"SplitHiddenDateTimeWidget",
"SelectDateWidget",
"TelInput",
"TextInput",
"Textarea",
"TimeInput",
"URLInput",
"Widget",
)
@@ -23,27 +23,27 @@ from .response import JsonResponse as JsonResponse
from .response import StreamingHttpResponse as StreamingHttpResponse
__all__ = [
"SimpleCookie",
"parse_cookie",
"BadHeaderError",
"FileResponse",
"Http404",
"HttpHeaders",
"HttpRequest",
"HttpResponse",
"HttpResponseBadRequest",
"HttpResponseBase",
"HttpResponseForbidden",
"HttpResponseGone",
"HttpResponseNotAllowed",
"HttpResponseNotFound",
"HttpResponseNotModified",
"HttpResponsePermanentRedirect",
"HttpResponseRedirect",
"HttpResponseServerError",
"JsonResponse",
"QueryDict",
"RawPostDataException",
"UnreadablePostError",
"HttpResponse",
"HttpResponseBase",
"SimpleCookie",
"StreamingHttpResponse",
"HttpResponseRedirect",
"HttpResponsePermanentRedirect",
"HttpResponseNotModified",
"HttpResponseBadRequest",
"HttpResponseForbidden",
"HttpResponseNotFound",
"HttpResponseNotAllowed",
"HttpResponseGone",
"HttpResponseServerError",
"Http404",
"BadHeaderError",
"JsonResponse",
"FileResponse",
"UnreadablePostError",
"parse_cookie",
]
@@ -59,4 +59,4 @@ class Parser:
def __init__(self, stream: LazyStream, boundary: bytes) -> None: ...
def __iter__(self) -> Iterator[tuple[str, dict[str, tuple[str, dict[str, bytes | str]]], LazyStream]]: ...
__all__ = ("MultiPartParser", "MultiPartParserError", "InputStreamExhausted")
__all__ = ("InputStreamExhausted", "MultiPartParser", "MultiPartParserError")
@@ -6,7 +6,7 @@ from json import JSONEncoder
from typing import Any, Literal, NoReturn, TypeVar, overload, type_check_only
from django.utils.datastructures import CaseInsensitiveMapping, _PropertyDescriptor
from django.utils.functional import cached_property
from django.utils.functional import _StrOrPromise, cached_property
class BadHeaderError(ValueError): ...
@@ -132,7 +132,9 @@ class FileResponse(StreamingHttpResponse):
class HttpResponseRedirectBase(HttpResponse):
allowed_schemes: list[str]
def __init__(self, redirect_to: str, preserve_request: bool = False, *args: Any, **kwargs: Any) -> None: ...
def __init__(
self, redirect_to: _StrOrPromise, preserve_request: bool = False, *args: Any, **kwargs: Any
) -> None: ...
@property
def url(self) -> str: ...
@@ -1,11 +1,11 @@
from typing import Any
from typing import ClassVar
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase, HttpResponsePermanentRedirect
from django.http.response import HttpResponseBase, HttpResponsePermanentRedirect, HttpResponseRedirectBase
from django.utils.deprecation import MiddlewareMixin
class CommonMiddleware(MiddlewareMixin):
response_redirect_class: Any
response_redirect_class: ClassVar[type[HttpResponseRedirectBase]]
def process_request(self, request: HttpRequest) -> HttpResponsePermanentRedirect | None: ...
def should_redirect_with_slash(self, request: HttpRequest) -> bool: ...
def get_full_path_with_slash(self, request: HttpRequest) -> str: ...
@@ -1,10 +1,10 @@
from typing import Any
from typing import ClassVar
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
from django.http.response import HttpResponseBase, HttpResponseRedirectBase
from django.utils.deprecation import MiddlewareMixin
class LocaleMiddleware(MiddlewareMixin):
response_redirect_class: Any
response_redirect_class: ClassVar[type[HttpResponseRedirectBase]]
def process_request(self, request: HttpRequest) -> None: ...
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
@@ -5,6 +5,7 @@ from django.db.models import Manager, QuerySet
from django.db.models.base import Model
from django.http import HttpRequest
from django.http.response import HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect
from django.utils.functional import _StrOrPromise
def render(
request: HttpRequest | None,
@@ -45,4 +46,4 @@ def get_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any,
async def aget_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
def get_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
async def aget_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
def resolve_url(to: Callable | Model | str, *args: Any, **kwargs: Any) -> str: ...
def resolve_url(to: Callable | Model | _StrOrPromise, *args: Any, **kwargs: Any) -> str: ...
@@ -18,4 +18,4 @@ from .utils import EngineHandler as EngineHandler
engines: EngineHandler
__all__ = ("Engine", "engines", "Template", "Context", "RequestContext")
__all__ = ("Context", "Engine", "RequestContext", "Template", "engines")
@@ -19,17 +19,17 @@ __all__ = [
"AsyncClient",
"AsyncRequestFactory",
"Client",
"LiveServerTestCase",
"RequestFactory",
"SimpleTestCase",
"TestCase",
"TransactionTestCase",
"SimpleTestCase",
"LiveServerTestCase",
"skipIfDBFeature",
"skipUnlessAnyDBFeature",
"skipUnlessDBFeature",
"ignore_warnings",
"modify_settings",
"override_settings",
"override_system_checks",
"skipIfDBFeature",
"skipUnlessAnyDBFeature",
"skipUnlessDBFeature",
"tag",
]
@@ -18,7 +18,7 @@ from django.http.response import HttpResponseBase
from django.template.base import Template
from django.test.utils import ContextList
from django.urls import ResolverMatch
from django.utils.functional import cached_property
from django.utils.functional import _StrOrPromise, cached_property
BOUNDARY: str
MULTIPART_CONTENT: str
@@ -88,7 +88,7 @@ class _RequestFactory(Generic[_T]):
def request(self, **request: Any) -> _T: ...
def get(
self,
path: str,
path: _StrOrPromise,
data: _GetDataType = ...,
secure: bool = ...,
*,
@@ -98,7 +98,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def post(
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
secure: bool = ...,
@@ -109,7 +109,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def head(
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
secure: bool = ...,
*,
@@ -119,7 +119,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def trace(
self,
path: str,
path: _StrOrPromise,
secure: bool = ...,
*,
headers: Mapping[str, Any] | None = ...,
@@ -128,7 +128,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def options(
self,
path: str,
path: _StrOrPromise,
data: dict[str, str] | str = ...,
content_type: str = ...,
secure: bool = ...,
@@ -139,7 +139,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def put(
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
secure: bool = ...,
@@ -150,7 +150,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def patch(
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
secure: bool = ...,
@@ -161,7 +161,7 @@ class _RequestFactory(Generic[_T]):
) -> _T: ...
def delete(
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
secure: bool = ...,
@@ -173,7 +173,7 @@ class _RequestFactory(Generic[_T]):
def generic(
self,
method: str,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str | None = ...,
secure: bool = ...,
@@ -283,7 +283,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
def request(self, **request: Any) -> _MonkeyPatchedWSGIResponse: ...
def get( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: _GetDataType = ...,
follow: bool = ...,
secure: bool = ...,
@@ -294,7 +294,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def post( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -306,7 +306,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def head( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
follow: bool = ...,
secure: bool = ...,
@@ -317,7 +317,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def options( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: dict[str, str] | str = ...,
content_type: str = ...,
follow: bool = ...,
@@ -329,7 +329,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def put( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -341,7 +341,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def patch( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -353,7 +353,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def delete( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -365,7 +365,7 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
) -> _MonkeyPatchedWSGIResponse: ...
def trace( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
follow: bool = ...,
secure: bool = ...,
@@ -393,7 +393,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
async def request(self, **request: Any) -> _MonkeyPatchedASGIResponse: ...
async def get( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: _GetDataType = ...,
follow: bool = ...,
secure: bool = ...,
@@ -404,7 +404,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def post( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -416,7 +416,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def head( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
follow: bool = ...,
secure: bool = ...,
@@ -427,7 +427,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def options( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: dict[str, str] | str = ...,
content_type: str = ...,
follow: bool = ...,
@@ -439,7 +439,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def put( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -451,7 +451,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def patch( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -463,7 +463,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def delete( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
content_type: str = ...,
follow: bool = ...,
@@ -475,7 +475,7 @@ class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGI
) -> _MonkeyPatchedASGIResponse: ...
async def trace( # type: ignore[override]
self,
path: str,
path: _StrOrPromise,
data: Any = ...,
follow: bool = ...,
secure: bool = ...,
@@ -20,7 +20,7 @@ from django.template.base import Template
from django.test.client import AsyncClient, Client
from django.test.html import Element
from django.test.utils import CaptureQueriesContext, ContextList
from django.utils.functional import classproperty
from django.utils.functional import _StrOrPromise, classproperty
from typing_extensions import Self
def to_list(value: Any) -> list[Any]: ...
@@ -78,14 +78,14 @@ class SimpleTestCase(unittest.TestCase):
) -> None: ...
def assertURLEqual(
self,
url1: str | Any, # Any for reverse_lazy() support
url2: str | Any,
url1: _StrOrPromise,
url2: _StrOrPromise,
msg_prefix: str = ...,
) -> None: ...
def assertContains(
self,
response: HttpResponseBase,
text: bytes | int | str,
text: bytes | int | _StrOrPromise,
count: int | None = ...,
status_code: int = ...,
msg_prefix: str = ...,
@@ -94,7 +94,7 @@ class SimpleTestCase(unittest.TestCase):
def assertNotContains(
self,
response: HttpResponseBase,
text: bytes | str,
text: bytes | int | _StrOrPromise,
status_code: int = ...,
msg_prefix: str = ...,
html: bool = ...,
@@ -249,4 +249,4 @@ class SerializeMixin:
def connections_support_transactions(aliases: Iterable[str] | None = ...) -> bool: ...
__all__ = ("TestCase", "TransactionTestCase", "SimpleTestCase", "skipIfDBFeature", "skipUnlessDBFeature")
__all__ = ("SimpleTestCase", "TestCase", "TransactionTestCase", "skipIfDBFeature", "skipUnlessDBFeature")
@@ -173,19 +173,19 @@ def garbage_collect() -> None: ...
__all__ = (
"Approximate",
"CaptureQueriesContext",
"ContextList",
"isolate_lru_cache",
"garbage_collect",
"get_runner",
"CaptureQueriesContext",
"ignore_warnings",
"isolate_apps",
"isolate_lru_cache",
"modify_settings",
"override_settings",
"override_system_checks",
"tag",
"requires_tz_support",
"setup_databases",
"setup_test_environment",
"tag",
"teardown_test_environment",
)
@@ -42,10 +42,10 @@ _AnyURL: TypeAlias = URLPattern | URLResolver # noqa: PYI047
__all__ = [
"LocalePrefixPattern",
"NoReverseMatch",
"URLPattern",
"URLResolver",
"Resolver404",
"ResolverMatch",
"URLPattern",
"URLResolver",
"clear_script_prefix",
"clear_url_caches",
"get_callable",
@@ -4,26 +4,36 @@ from typing import Any, Literal, TypeAlias
from django.http.request import QueryDict
from django.http.response import HttpResponseBase
from django.urls.resolvers import ResolverMatch
from django.utils.functional import _StrPromise
# https://github.com/python/typeshed/blob/87f599dc8312ac67b941b5f2b47274534a1a2d3a/stdlib/urllib/parse.pyi#L136-L138
_QueryType: TypeAlias = (
Mapping[Any, Any] | Mapping[Any, Sequence[Any]] | Sequence[tuple[Any, Any]] | Sequence[tuple[Any, Sequence[Any]]]
)
def resolve(path: str, urlconf: str | None = ...) -> ResolverMatch: ...
def resolve(path: str | _StrPromise, urlconf: str | None = ...) -> ResolverMatch: ...
# NOTE: make sure `reverse` and `reverse_lazy` objects are in sync:
def reverse(
viewname: Callable[..., HttpResponseBase] | str | None,
urlconf: str | None = ...,
args: Sequence[Any] | None = ...,
kwargs: dict[str, Any] | None = ...,
current_app: str | None = ...,
urlconf: str | None = None,
args: Sequence[Any] | None = None,
kwargs: dict[str, Any] | None = None,
current_app: str | None = None,
*,
query: QueryDict | _QueryType | None = ...,
fragment: str | None = ...,
query: QueryDict | _QueryType | None = None,
fragment: str | None = None,
) -> str: ...
reverse_lazy: Any
def reverse_lazy(
viewname: Callable[..., HttpResponseBase] | str | None,
urlconf: str | None = None,
args: Sequence[Any] | None = None,
kwargs: dict[str, Any] | None = None,
current_app: str | None = None,
*,
query: QueryDict | _QueryType | None = None,
fragment: str | None = None,
) -> _StrPromise: ...
def clear_url_caches() -> None: ...
def set_script_prefix(prefix: str) -> None: ...
def get_script_prefix() -> str: ...
@@ -45,8 +45,6 @@ def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: tuple) -
_Pattern: TypeAlias = RegexPattern | RoutePattern | LocalePrefixPattern
class LocaleRegexDescriptor:
attr: str
def __init__(self, attr: Any) -> None: ...
@overload
def __get__(self, instance: None, cls: type[_Pattern] = ...) -> LocaleRegexDescriptor: ...
@overload
@@ -62,7 +62,7 @@ class MultiValueDict(dict[_K, _V]):
def __init__(self, key_to_list_mapping: Mapping[_K, list[_V] | None]) -> None: ...
@overload
def __init__(self, key_to_list_mapping: Iterable[tuple[_K, list[_V]]] = ()) -> None: ...
@overload # type: ignore[override]
@overload
def get(self, key: _K, default: None = None) -> _V | None: ...
@overload
def get(self, key: _K, default: _V) -> _V: ...
@@ -1,4 +1,4 @@
from collections.abc import Callable
from collections.abc import Callable, Iterable
# Mypy has special handling for functools.cached_property, reuse typeshed's definition instead of defining our own
from functools import cached_property as cached_property
@@ -84,7 +84,7 @@ class SimpleLazyObject(LazyObject):
_PartitionMember = TypeVar("_PartitionMember")
def partition(
predicate: Callable[[_PartitionMember], int | bool], values: list[_PartitionMember]
predicate: Callable[[_PartitionMember], int | bool], values: Iterable[_PartitionMember]
) -> tuple[list[_PartitionMember], list[_PartitionMember]]: ...
_Get = TypeVar("_Get", covariant=True)
@@ -39,19 +39,19 @@ def make_aware(value: datetime, timezone: tzinfo | None = None) -> datetime: ...
def make_naive(value: datetime, timezone: tzinfo | None = None) -> datetime: ...
__all__ = [
"get_fixed_timezone",
"get_default_timezone",
"get_default_timezone_name",
"get_current_timezone",
"get_current_timezone_name",
"activate",
"deactivate",
"override",
"localtime",
"localdate",
"now",
"get_current_timezone",
"get_current_timezone_name",
"get_default_timezone",
"get_default_timezone_name",
"get_fixed_timezone",
"is_aware",
"is_naive",
"localdate",
"localtime",
"make_aware",
"make_naive",
"now",
"override",
]
@@ -50,24 +50,24 @@ def round_away_from_one(value: int) -> int: ...
__all__ = [
"activate",
"check_for_language",
"deactivate",
"override",
"deactivate_all",
"get_language",
"get_language_bidi",
"get_language_from_request",
"get_language_info",
"get_language_bidi",
"check_for_language",
"to_language",
"to_locale",
"templatize",
"gettext",
"gettext_lazy",
"gettext_noop",
"ngettext",
"ngettext_lazy",
"pgettext",
"pgettext_lazy",
"npgettext",
"npgettext_lazy",
"override",
"pgettext",
"pgettext_lazy",
"templatize",
"to_language",
"to_locale",
]
@@ -18,21 +18,21 @@ from .list import ListView as ListView
class GenericViewError(Exception): ...
__all__ = [
"View",
"TemplateView",
"RedirectView",
"ArchiveIndexView",
"YearArchiveView",
"MonthArchiveView",
"WeekArchiveView",
"DayArchiveView",
"TodayArchiveView",
"CreateView",
"DateDetailView",
"DayArchiveView",
"DeleteView",
"DetailView",
"FormView",
"CreateView",
"UpdateView",
"DeleteView",
"ListView",
"GenericViewError",
"ListView",
"MonthArchiveView",
"RedirectView",
"TemplateView",
"TodayArchiveView",
"UpdateView",
"View",
"WeekArchiveView",
"YearArchiveView",
]
@@ -6,7 +6,7 @@ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
_M = TypeVar("_M", bound=models.Model)
class SingleObjectMixin(Generic[_M], ContextMixin):
class SingleObjectMixin(ContextMixin, Generic[_M]):
model: type[_M]
queryset: models.query.QuerySet[_M] | None
slug_field: str
@@ -5,6 +5,7 @@ from django.forms.forms import BaseForm
from django.forms.models import BaseModelForm
from django.http import HttpRequest, HttpResponse
from django.utils.datastructures import _ListOrTuple
from django.utils.functional import _StrOrPromise
from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
from django.views.generic.detail import BaseDetailView, SingleObjectMixin, SingleObjectTemplateResponseMixin
@@ -12,10 +13,10 @@ _FormT = TypeVar("_FormT", bound=BaseForm)
_ModelFormT = TypeVar("_ModelFormT", bound=BaseModelForm)
_M = TypeVar("_M", bound=models.Model)
class FormMixin(Generic[_FormT], ContextMixin):
class FormMixin(ContextMixin, Generic[_FormT]):
initial: dict[str, Any]
form_class: type[_FormT] | None
success_url: str | None
success_url: _StrOrPromise | None = None
prefix: str | None
def get_initial(self) -> dict[str, Any]: ...
def get_prefix(self) -> str | None: ...
@@ -27,7 +28,7 @@ class FormMixin(Generic[_FormT], ContextMixin):
def form_invalid(self, form: _FormT) -> HttpResponse: ...
def get_context_data(self, **kwargs: Any) -> dict[str, Any]: ...
class ModelFormMixin(Generic[_M, _ModelFormT], FormMixin[_ModelFormT], SingleObjectMixin[_M]):
class ModelFormMixin(FormMixin[_ModelFormT], SingleObjectMixin[_M], Generic[_M, _ModelFormT]):
fields: _ListOrTuple[str] | Literal["__all__"] | None
def get_form_class(self) -> type[_ModelFormT]: ...
def get_form_kwargs(self) -> dict[str, Any]: ...
@@ -59,15 +60,15 @@ class UpdateView(SingleObjectTemplateResponseMixin, BaseUpdateView[_M, _ModelFor
template_name_suffix: str
class DeletionMixin(Generic[_M]):
success_url: str | None
success_url: _StrOrPromise | None = None
object: _M
def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def delete(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_success_url(self) -> str: ...
class BaseDeleteView(Generic[_M, _ModelFormT], DeletionMixin[_M], FormMixin[_ModelFormT], BaseDetailView[_M]):
class BaseDeleteView(DeletionMixin[_M], FormMixin[_ModelFormT], BaseDetailView[_M], Generic[_M, _ModelFormT]):
object: _M
class DeleteView(Generic[_M, _ModelFormT], SingleObjectTemplateResponseMixin, BaseDeleteView[_M, _ModelFormT]):
class DeleteView(SingleObjectTemplateResponseMixin, BaseDeleteView[_M, _ModelFormT], Generic[_M, _ModelFormT]):
object: _M
template_name_suffix: str
@@ -13,7 +13,7 @@ class _HasModel(Protocol):
@property
def model(self) -> type[Model]: ...
class MultipleObjectMixin(Generic[_M], ContextMixin):
class MultipleObjectMixin(ContextMixin, Generic[_M]):
allow_empty: bool
queryset: QuerySet[_M] | None
model: type[_M] | None