Large update (#909)

* Make module declaration precise.

* Make settings match real file.

* Replace `include` with import.

* Make types more specific.

* Replace `WSGIRequest` with `HttpRequest` where possible.

* Replace all `OrderedDict` occurrences with plain `Dict` (it is not used in Django 3.2 and later)

* Add fake datastructures for convenience: _PropertyDescriptor and _ListOrTuple now can live here. Added _IndexableCollection (often useful as alias for 'sequence or queryset')

* Actualize other datastructures.

* Rework MultiValueDict to reflect the fact that some methods can return empty list instead of value.

* Deprecate SafeText in favor of SafeString.

* Minor improvements to utils

* Disallow using str in TimeFormat and DateFormat, drop removed fmt `B`

* Do not let classproperty expect classmethod, make return value covariant.

* Sync with real file.

* Improve types for timezone.

* Sync deprecated, new and removed features in translation utils.

* Drop removed files, sync huge deprecations.

* Fix incompatible decorators (properties, contextmanagers)

* Rework pagination.

* Sync validators with real code. Add _ValidatorCallable for any external use (field validation etc.)

* Add shared type definitions (for fields of both forms and models). Actualize model fields. Mark keyword-only args explicitly in stubs (where code uses **kwargs). Disallow bytes for verbose_name.

* Make all checks return Sequence[CheckMessage] or subclass to be covariant.

* Add bidirectional references between backend.base and other files. Replace some Any's with specific types.

* Actualize db.migrations: remove removed methods, replace "None" annotations in wrong places, improve some wrong annotations.

* Actualize db.utils to match real file.

* Replace FileResponse and TemplateResponse with HttpResponse(Base) where needed: at least HttpResponseNotModified/HttpResponseRedirect can be returned instead of it, so annotation was wrong.

* Replace Any in forms where possible. Actualize class bases and method arguments.

* Improve typing of serializers.

* Actualize views, rename variable bound to Model to _M for consistency.

* Make types of file-related code consistent. Disallow using bytes as path, because many methods expect str-only paths. Make File inherit from IO[AnyStr] instead of IO[Any]: it makes impossible to instantiate file of union type, but allows precise types for some methods.

* Minor improvements: stop using None as annotation in wrong places, replace obvious Any's with precise types, actualize methods (missing/renamed/signature changed).

* Allow less specific containers, replace Any's with specific types.

* Improve types for requests and responses.

* Use AbstractBaseUser instead of User in auth.

* Use broader type for permission_required

* Use wider container types. Add 'type: ignore' to avoid issues with mypy.stubtest.

* Disallow using backend class as argument (it is passed to import_string).

* Add required methods to PasseordValidator.

* Allow using Path instance as argument.

* Actualize methods.

* Add 'type: ignore' to avoid issues with mypy.stubtest.

* Replace Any's with specific types and BaseForm with ModelForm.

* Actualize contrib.postgres

* Remove render_to_response, add 'get_absolute_url' to corresponding protocol.

* Actualize signers.

* Use precise types for handlers. Disallow str as stream type for LimitedStream.

* Exact types for ValidationError

* Replace wrong used Union with Sequence.

* Actualize static handlers.

* More specific types for admin. Fixes #874.

* Improve types and replace 'Tags' with str (it isn't Enum, so annotation was wrong).

* Replace Any with specific types, actualize signatures.

* Add async variants of handlers and clients. Use fake class to distinguish between request types in RequestFactory and AsyncRequestFactory.

* Fix signature, minor improvements.

* Actualize signatures and class names, replace Any with more specific types.

* Fix signature.

* Add some missing methods to Collector

* Combinable rarely returns Self type: almost always it's CombinedExpression.

* No Random in source anymore.

* Drop removed SimpleCol.

* Replace _OutputField with Field: nothing in docs about strings.

* Introduce reusable types, add missing methods. Remove strange types (probably created by stubgen). Remove RawQuery from Compiler: it obviously doesn't work with RawQuery.

* Use literal constants.

* Actualize base classes.

* Callable is not accepted by get_field.

* Add precise types.

* Use property and broader containers where possible. Add missing methods.

* Actualize indexes.

* More specific types for signals.

* Fix signatures, drop missing methods.

* Actualize window functions to match source.

* Actualize text functions, add missing methods, use type aliases for consistency.

* Add missing property decorators, methods and attributes. Use type aliases. Remove absent YearComparisonLookup and any SafeText references (they aren't related to lookups at all).

* Use bound TypeVar, mark all BuiltinLookup descendants as generic explicitly. Remove strange Union from Lookup.__init__

* Apply type alias, fix base class and argument name.

* Actualize BaseExpression methods.

* Fix imports.

* Add missing class and fix incompatible bases.

* Use same types in __init__ and attribute.

* OrderBy accepts F or Expression.

* Non-expressions are converted to Values.

* Add missing attributes.

* Add missing methods, fix 'None' argument type.

* Define properties where possible, remove 'None' argument annotations, remove inadequate type in make_immutable_fields_list.

* Remove absent QueryWrapper. Replace some Any with precise types.

* Fix wrong types and actualize signatures. Deny ManagerDescriptor.__get__ on model instances.

* Use more specific types.

* Arity can be None in subclasses.

* Reformat with black

* Make DeletionMixin generic.

* Fix wrong type variable in _RequestFactory.

* Fix variable name in signature.

* Disallow returning None from Form.clean()

* Allow again returning None from Form.clean

* Drop some unused imports.

* Add tests for MultiValueDict.

* Add tests for utils.timezone.

* Fix #834.

* Add more files to import_all test

* Allow None for `context_object_name`

* Fix CI

* Fix test to work on python 3.8
This commit is contained in:
sterliakov
2022-04-04 00:41:41 +03:00
committed by GitHub
parent dc4c0d9ee4
commit f69e0639c7
322 changed files with 5740 additions and 3465 deletions

View File

@@ -1,4 +1,5 @@
from typing import Any, Dict, Iterator, Optional, Type
import types
from typing import Dict, Iterator, Optional, Type
from django.apps.registry import Apps
from django.db.models.base import Model
@@ -7,14 +8,14 @@ MODELS_MODULE_NAME: str
class AppConfig:
name: str = ...
module: Optional[Any] = ...
module: Optional[types.ModuleType] = ...
apps: Optional[Apps] = ...
label: str = ...
verbose_name: str = ...
path: str = ...
models_module: Optional[str] = ...
models: Dict[str, Type[Model]] = ...
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
def __init__(self, app_name: str, app_module: Optional[types.ModuleType]) -> None: ...
@classmethod
def create(cls, entry: str) -> AppConfig: ...
def get_model(self, model_name: str, require_ready: bool = ...) -> Type[Model]: ...

View File

@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Optional
from django.utils.functional import LazyObject
@@ -6,24 +6,32 @@ from django.utils.functional import LazyObject
from . import global_settings
ENVIRONMENT_VARIABLE: str = ...
DEFAULT_CONTENT_TYPE_DEPRECATED_MSG: str = ...
FILE_CHARSET_DEPRECATED_MSG: str = ...
PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG: str = ...
DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG: str = ...
# required for plugin to be able to distinguish this specific instance of LazySettings from others
class _DjangoConfLazyObject(LazyObject):
def __getattr__(self, item: Any) -> Any: ...
class LazySettings(_DjangoConfLazyObject):
configured: bool
def configure(self, default_settings: Any = ..., **options: Any) -> Any: ...
@property
def configured(self) -> bool: ...
def configure(self, default_settings: Any = ..., **options: Any) -> None: ...
settings: LazySettings = ...
class Settings:
def __init__(self, settings_module: str): ...
def __init__(self, settings_module: str) -> None: ...
def is_overridden(self, setting: str) -> bool: ...
class UserSettingsHolder: ...
class UserSettingsHolder:
SETTINGS_MODULE: Optional[Any] = ...
def __init__(self, default_settings: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
def is_overridden(self, setting: str) -> bool: ...
class SettingsReference(str):
def __new__(self, value: Any, setting_name: str) -> SettingsReference: ...
def __init__(self, value: str, setting_name: str) -> None: ...

View File

@@ -68,15 +68,11 @@ USE_L10N: bool = ...
# notifications and other various emails.
MANAGERS = ADMINS
# Default content type and charset to use for all HttpResponse objects, if a
# Default charset to use for all HttpResponse objects, if a
# MIME type isn't manually specified. These are used to construct the
# Content-Type header.
DEFAULT_CONTENT_TYPE: str = ...
DEFAULT_CHARSET: str = ...
# Encoding of files read from disk (template and initial SQL files).
FILE_CHARSET: str = ...
# Email address that error messages come from.
SERVER_EMAIL: str = ...
@@ -136,7 +132,7 @@ APPEND_SLASH: bool = ...
PREPEND_WWW: bool = ...
# Override the server-derived value of SCRIPT_NAME
FORCE_SCRIPT_NAME = None
FORCE_SCRIPT_NAME: Optional[str] = ...
# List of compiled regular expression objects representing User-Agent strings
# that are not allowed to visit any page, systemwide. Use this for bad
@@ -148,7 +144,7 @@ FORCE_SCRIPT_NAME = None
# re.compile(r'^SiteSucker.*'),
# re.compile(r'^sohu-search'),
# ]
DISALLOWED_USER_AGENTS: List[Pattern] = ...
DISALLOWED_USER_AGENTS: List[Pattern[str]] = ...
ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ...
@@ -162,7 +158,7 @@ ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ...
# re.compile(r'^/phpmyadmin/'),
# re.compile(r'\.(cgi|php|pl)$'),
# ]
IGNORABLE_404_URLS: List[Pattern] = ...
IGNORABLE_404_URLS: List[Pattern[str]] = ...
# A secret key for this particular Django installation. Used in secret-key
# hashing algorithms. Set this in your settings, or Django will complain
@@ -210,12 +206,12 @@ FILE_UPLOAD_TEMP_DIR: Optional[str] = ...
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https://docs.python.org/library/os.html#files-and-directories.
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_PERMISSIONS: int = ...
# The numeric mode to assign to newly-created directories, when uploading files.
# The value should be a mode as you'd pass to os.chmod;
# see https://docs.python.org/library/os.html#files-and-directories.
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_DIRECTORY_PERMISSIONS: Optional[int] = ...
# Python module path where user will place custom format definition.
# The directory where this setting is pointing should contain subdirectories
@@ -330,33 +326,33 @@ MIDDLEWARE: List[str] = ...
############
# Cache to store session data if using the cache session backend.
SESSION_CACHE_ALIAS = "default"
SESSION_CACHE_ALIAS: str = ...
# Cookie name. This can be whatever you want.
SESSION_COOKIE_NAME = "sessionid"
SESSION_COOKIE_NAME: str = ...
# Age of cookie, in seconds (default: 2 weeks).
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
SESSION_COOKIE_AGE: int = ...
# A string like "example.com", or None for standard domain cookie.
SESSION_COOKIE_DOMAIN: Optional[str] = ...
# Whether the session cookie should be secure (https:// only).
SESSION_COOKIE_SECURE = False
SESSION_COOKIE_SECURE: bool = ...
# The path of the session cookie.
SESSION_COOKIE_PATH = "/"
SESSION_COOKIE_PATH: str = ...
# Whether to use the non-RFC standard httpOnly flag (IE, FF3+, others)
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_HTTPONLY: bool = ...
# Whether to set the flag restricting cookie leaks on cross-site requests.
# This can be 'Lax', 'Strict', or None to disable the flag.
SESSION_COOKIE_SAMESITE: Optional[str] = ...
# Whether to save the session data on every request.
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SAVE_EVERY_REQUEST: bool = ...
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_EXPIRE_AT_BROWSER_CLOSE: bool = ...
# The module to store session data
SESSION_ENGINE = "django.contrib.sessions.backends.db"
SESSION_ENGINE: str = ...
# Directory to store session files if using the file session module. If None,
# the backend will use a sensible default.
SESSION_FILE_PATH: Optional[str] = ...
# class to serialize session data
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
SESSION_SERIALIZER: str = ...
#########
# CACHE #
@@ -364,9 +360,9 @@ SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
# The cache backends to use.
CACHES: Dict[str, Dict[str, Any]] = ...
CACHE_MIDDLEWARE_KEY_PREFIX = ""
CACHE_MIDDLEWARE_SECONDS = 600
CACHE_MIDDLEWARE_ALIAS = "default"
CACHE_MIDDLEWARE_KEY_PREFIX: str = ...
CACHE_MIDDLEWARE_SECONDS: int = ...
CACHE_MIDDLEWARE_ALIAS: str = ...
##################
# AUTHENTICATION #
@@ -376,14 +372,14 @@ AUTH_USER_MODEL: str = ...
AUTHENTICATION_BACKENDS: Sequence[str] = ...
LOGIN_URL = "/accounts/login/"
LOGIN_URL: str = ...
LOGIN_REDIRECT_URL: str = ...
LOGOUT_REDIRECT_URL: Optional[str] = ...
# The number of days a password reset link is valid for
PASSWORD_RESET_TIMEOUT_DAYS = 3
PASSWORD_RESET_TIMEOUT_DAYS: int = ...
# the first hasher in this list is the preferred algorithm. any
# password using different algorithms will be converted automatically
@@ -396,7 +392,7 @@ AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] = ...
# SIGNING #
###########
SIGNING_BACKEND = "django.core.signing.TimestampSigner"
SIGNING_BACKEND: str = ...
########
# CSRF #
@@ -404,26 +400,26 @@ SIGNING_BACKEND = "django.core.signing.TimestampSigner"
# Dotted path to callable to be used as view when a request is
# rejected by the CSRF middleware.
CSRF_FAILURE_VIEW = "django.views.csrf.csrf_failure"
CSRF_FAILURE_VIEW: str = ...
# Settings for CSRF cookie.
CSRF_COOKIE_NAME = "csrftoken"
CSRF_COOKIE_AGE = 60 * 60 * 24 * 7 * 52
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_PATH = "/"
CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_NAME: str = ...
CSRF_COOKIE_AGE: int = ...
CSRF_COOKIE_DOMAIN: Optional[str] = ...
CSRF_COOKIE_PATH: str = ...
CSRF_COOKIE_SECURE: bool = ...
CSRF_COOKIE_HTTPONLY: bool = ...
CSRF_COOKIE_SAMESITE: Optional[str] = ...
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
CSRF_HEADER_NAME: str = ...
CSRF_TRUSTED_ORIGINS: List[str] = ...
CSRF_USE_SESSIONS = False
CSRF_USE_SESSIONS: bool = ...
############
# MESSAGES #
############
# Class to use as messages backend
MESSAGE_STORAGE = "django.contrib.messages.storage.fallback.FallbackStorage"
MESSAGE_STORAGE: str = ...
# Default values of MESSAGE_LEVEL and MESSAGE_TAGS are defined within
# django.contrib.messages to avoid imports in this settings file.
@@ -433,21 +429,21 @@ MESSAGE_STORAGE = "django.contrib.messages.storage.fallback.FallbackStorage"
###########
# The callable to use to configure logging
LOGGING_CONFIG = "logging.config.dictConfig"
LOGGING_CONFIG: str = ...
# Custom logging configuration.
LOGGING: Dict[str, Any] = ...
# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
DEFAULT_EXCEPTION_REPORTER_FILTER = "django.views.debug.SafeExceptionReporterFilter"
DEFAULT_EXCEPTION_REPORTER_FILTER: str = ...
###########
# TESTING #
###########
# The name of the class to use to run the test suite
TEST_RUNNER = "django.test.runner.DiscoverRunner"
TEST_RUNNER: str = ...
# Apps that don't need to be serialized at test database creation time
# (only apps with migrations are to start with)
@@ -494,11 +490,11 @@ SILENCED_SYSTEM_CHECKS: List[str] = ...
#######################
# SECURITY MIDDLEWARE #
#######################
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_BROWSER_XSS_FILTER: bool = ...
SECURE_CONTENT_TYPE_NOSNIFF: bool = ...
SECURE_HSTS_INCLUDE_SUBDOMAINS: bool = ...
SECURE_HSTS_PRELOAD: bool = ...
SECURE_HSTS_SECONDS: int = ...
SECURE_REDIRECT_EXEMPT: List[str] = ...
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False
SECURE_SSL_HOST: Optional[str] = ...
SECURE_SSL_REDIRECT: bool = ...

View File

@@ -3,6 +3,7 @@ from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union, overlo
from django.http.response import HttpResponse, HttpResponseBase
from django.urls import URLPattern, URLResolver
from django.urls import include as include
handler400: Union[str, Callable[..., HttpResponse]] = ...
handler403: Union[str, Callable[..., HttpResponse]] = ...
@@ -11,14 +12,19 @@ handler500: Union[str, Callable[..., HttpResponse]] = ...
IncludedURLConf = Tuple[Sequence[Union[URLResolver, URLPattern]], Optional[str], Optional[str]]
def include(arg: Any, namespace: str = ..., app_name: str = ...) -> IncludedURLConf: ...
# Deprecated
@overload
def url(
regex: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] = ..., name: str = ...
regex: str, view: Callable[..., HttpResponseBase], kwargs: Optional[Dict[str, Any]] = ..., name: Optional[str] = ...
) -> URLPattern: ...
@overload
def url(regex: str, view: IncludedURLConf, kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ...
def url(
regex: str, view: IncludedURLConf, kwargs: Optional[Dict[str, Any]] = ..., name: Optional[str] = ...
) -> URLResolver: ...
@overload
def url(
regex: str, view: Sequence[Union[URLResolver, str]], kwargs: Dict[str, Any] = ..., name: str = ...
regex: str,
view: Sequence[Union[URLResolver, str]],
kwargs: Optional[Dict[str, Any]] = ...,
name: Optional[str] = ...,
) -> URLResolver: ...

View File

@@ -1,8 +1,10 @@
from typing import Any, Callable, List, Tuple
from typing import Callable, List, Tuple, Union
from django.urls.resolvers import URLPattern
from django.urls.resolvers import URLPattern, URLResolver
def i18n_patterns(*urls: Any, prefix_default_language: bool = ...) -> List[List[URLPattern]]: ...
def i18n_patterns(
*urls: Union[URLPattern, URLResolver], prefix_default_language: bool = ...
) -> List[Union[URLPattern, URLResolver]]: ...
def is_language_prefix_patterns_used(urlconf: str) -> Tuple[bool, bool]: ...
urlpatterns: List[Callable]

View File

@@ -12,7 +12,6 @@ from .filters import ListFilter as ListFilter
from .filters import RelatedFieldListFilter as RelatedFieldListFilter
from .filters import RelatedOnlyFieldListFilter as RelatedOnlyFieldListFilter
from .filters import SimpleListFilter as SimpleListFilter
from .helpers import ACTION_CHECKBOX_NAME as ACTION_CHECKBOX_NAME
from .options import HORIZONTAL as HORIZONTAL
from .options import VERTICAL as VERTICAL
from .options import ModelAdmin as ModelAdmin

View File

@@ -1,8 +1,8 @@
from typing import Optional
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.query import QuerySet
from django.http.request import HttpRequest
from django.template.response import TemplateResponse
def delete_selected(modeladmin: ModelAdmin, request: WSGIRequest, queryset: QuerySet) -> Optional[TemplateResponse]: ...
def delete_selected(modeladmin: ModelAdmin, request: HttpRequest, queryset: QuerySet) -> Optional[TemplateResponse]: ...

View File

@@ -1,18 +1,21 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.contrib.admin.options import BaseModelAdmin
from django.core.checks.messages import CheckMessage, Error
def check_admin_app(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
def check_dependencies(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
def check_admin_app(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[CheckMessage]: ...
def check_dependencies(**kwargs: Any) -> Sequence[CheckMessage]: ...
class BaseModelAdminChecks:
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ...
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> Sequence[CheckMessage]: ...
class ModelAdminChecks(BaseModelAdminChecks): ...
class InlineModelAdminChecks(BaseModelAdminChecks): ...
class ModelAdminChecks(BaseModelAdminChecks):
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> Sequence[CheckMessage]: ...
class InlineModelAdminChecks(BaseModelAdminChecks):
def check(self, inline_obj: BaseModelAdmin, **kwargs: Any) -> Sequence[CheckMessage]: ... # type: ignore
def must_be(type: Any, option: Any, obj: Any, id: Any): ...
def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any): ...
def refer_to_missing_field(field: Any, option: Any, model: Any, obj: Any, id: Any): ...
def refer_to_missing_field(field: Any, option: Any, obj: Any, id: Any): ...

View File

@@ -1,38 +1,39 @@
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.fields.related import RelatedField
from django.db.models.query import QuerySet
from django.http.request import HttpRequest
class ListFilter:
title: Any = ...
title: str = ...
template: str = ...
used_parameters: Any = ...
def __init__(
self, request: WSGIRequest, params: Dict[str, str], model: Type[Model], model_admin: ModelAdmin
self, request: HttpRequest, params: Dict[str, str], model: Type[Model], model_admin: ModelAdmin
) -> None: ...
def has_output(self) -> bool: ...
def choices(self, changelist: Any) -> Optional[Iterator[Dict[str, Any]]]: ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
def queryset(self, request: Any, queryset: QuerySet) -> Optional[QuerySet]: ...
def expected_parameters(self) -> Optional[List[str]]: ...
class SimpleListFilter(ListFilter):
parameter_name: Any = ...
parameter_name: str = ...
lookup_choices: Any = ...
def value(self) -> Optional[str]: ...
def lookups(self, request: Any, model_admin: Any) -> List[Tuple[Any, str]]: ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
class FieldListFilter(ListFilter):
field: Field = ...
field_path: Any = ...
title: Any = ...
field_path: str = ...
title: str = ...
def __init__(
self,
field: Field,
request: WSGIRequest,
request: HttpRequest,
params: Dict[str, str],
model: Type[Model],
model_admin: ModelAdmin,
@@ -44,7 +45,7 @@ class FieldListFilter(ListFilter):
def create(
cls,
field: Field,
request: WSGIRequest,
request: HttpRequest,
params: Dict[str, str],
model: Type[Model],
model_admin: ModelAdmin,
@@ -55,32 +56,34 @@ class RelatedFieldListFilter(FieldListFilter):
used_parameters: Dict[Any, Any]
lookup_kwarg: str = ...
lookup_kwarg_isnull: str = ...
lookup_val: None = ...
lookup_val_isnull: None = ...
lookup_val: Any = ...
lookup_val_isnull: Any = ...
lookup_choices: Any = ...
lookup_title: Any = ...
lookup_title: str = ...
title: str = ...
empty_value_display: Any = ...
@property
def include_empty_choice(self) -> bool: ...
def field_choices(
self, field: RelatedField, request: WSGIRequest, model_admin: ModelAdmin
self, field: RelatedField, request: HttpRequest, model_admin: ModelAdmin
) -> List[Tuple[str, str]]: ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
class BooleanFieldListFilter(FieldListFilter):
lookup_kwarg: Any = ...
lookup_kwarg2: Any = ...
lookup_kwarg: str = ...
lookup_kwarg2: str = ...
lookup_val: Any = ...
lookup_val2: Any = ...
def choices(self, changelist: Any) -> None: ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
class ChoicesFieldListFilter(FieldListFilter):
title: str
used_parameters: Dict[Any, Any]
lookup_kwarg: str = ...
lookup_kwarg_isnull: str = ...
lookup_val: None = ...
lookup_val_isnull: None = ...
lookup_val: Any = ...
lookup_val_isnull: Any = ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
class DateFieldListFilter(FieldListFilter):
field_generic: Any = ...
@@ -89,25 +92,28 @@ class DateFieldListFilter(FieldListFilter):
lookup_kwarg_until: Any = ...
links: Any = ...
lookup_kwarg_isnull: Any = ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
class AllValuesFieldListFilter(FieldListFilter):
title: str
used_parameters: Dict[Any, Any]
lookup_kwarg: str = ...
lookup_kwarg_isnull: str = ...
lookup_val: None = ...
lookup_val_isnull: None = ...
lookup_val: Any = ...
lookup_val_isnull: Any = ...
empty_value_display: str = ...
lookup_choices: QuerySet = ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...
class RelatedOnlyFieldListFilter(RelatedFieldListFilter):
lookup_kwarg: str
lookup_kwarg_isnull: str
lookup_val: None
lookup_val_isnull: None
lookup_val: Any
lookup_val_isnull: Any
title: str
used_parameters: Dict[Any, Any]
class EmptyFieldListFilter(FieldListFilter):
lookup_kwarg: str = ...
lookup_val: None = ...
lookup_val: Any = ...
def choices(self, changelist: Any) -> Iterator[Dict[str, Any]]: ...

View File

@@ -1,12 +1,20 @@
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
import sys
from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Tuple, Union
from django import forms
from django.contrib.admin.options import ModelAdmin
from django.db.models import Model
from django.db.models.fields import AutoField
from django.forms.boundfield import BoundField
from django.forms.forms import BaseForm
from django.forms.utils import ErrorDict
from django.forms.models import ModelForm
from django.forms.utils import ErrorDict, ErrorList
from django.forms.widgets import Media, Widget
from django.utils.safestring import SafeText
from django.utils.safestring import SafeString
if sys.version_info < (3, 8):
from typing_extensions import TypedDict
else:
from typing import TypedDict
ACTION_CHECKBOX_NAME: str
@@ -16,99 +24,121 @@ class ActionForm(forms.Form):
checkbox: Any
class _PrepopulatedDict(TypedDict):
field: BoundField
dependencies: List[BoundField]
class AdminForm:
prepopulated_fields: Any = ...
model_admin: Any = ...
readonly_fields: Any = ...
prepopulated_fields: List[_PrepopulatedDict]
model_admin: Optional[ModelAdmin] = ...
readonly_fields: Sequence[str] = ...
form: ModelForm
fieldsets: List[Tuple[Any, Dict[str, List[str]]]]
def __init__(
self,
form: BaseForm,
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
prepopulated_fields: Dict[Any, Any],
readonly_fields: Optional[Iterable[Any]] = ...,
model_admin: Any = ...,
form: ModelForm,
fieldsets: List[Tuple[Any, Dict[str, List[str]]]],
prepopulated_fields: Mapping[str, Iterable[str]],
readonly_fields: Optional[Sequence[str]] = ...,
model_admin: Optional[ModelAdmin] = ...,
) -> None: ...
def __iter__(self) -> Iterator[Fieldset]: ...
@property
def errors(self) -> ErrorDict: ...
@property
def non_field_errors(self) -> Callable: ...
def non_field_errors(self) -> Callable[[], ErrorList]: ...
@property
def media(self) -> Media: ...
class Fieldset:
form: Any = ...
classes: Any = ...
description: Any = ...
model_admin: Any = ...
readonly_fields: Any = ...
form: ModelForm = ...
classes: str = ...
description: Optional[str] = ...
model_admin: Optional[ModelAdmin] = ...
readonly_fields: Sequence[str] = ...
def __init__(
self,
form: Any,
form: ModelForm,
name: Optional[Any] = ...,
readonly_fields: Optional[Iterable[Any]] = ...,
fields: Any = ...,
classes: Any = ...,
description: Optional[Any] = ...,
model_admin: Optional[Any] = ...,
readonly_fields: Sequence[str] = ...,
fields: Sequence[str] = ...,
classes: Iterable[str] = ...,
description: Optional[str] = ...,
model_admin: Optional[ModelAdmin] = ...,
) -> None: ...
@property
def media(self) -> Media: ...
def __iter__(self) -> Iterator[Fieldline]: ...
class Fieldline:
form: Any = ...
fields: Any = ...
has_visible_field: Any = ...
model_admin: Any = ...
readonly_fields: Any = ...
form: ModelForm = ...
fields: Sequence[str] = ...
has_visible_field: bool = ...
model_admin: Optional[ModelAdmin] = ...
readonly_fields: Sequence[str] = ...
def __init__(
self, form: Any, field: Any, readonly_fields: Optional[Iterable[Any]] = ..., model_admin: Optional[Any] = ...
self,
form: ModelForm,
field: Union[str, Sequence[str]],
readonly_fields: Optional[Sequence[str]] = ...,
model_admin: Optional[ModelAdmin] = ...,
) -> None: ...
def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ...
def errors(self) -> SafeText: ...
def errors(self) -> SafeString: ...
class AdminField:
field: BoundField = ...
is_first: bool = ...
is_checkbox: bool = ...
is_readonly: bool = ...
def __init__(self, form: Any, field: Any, is_first: Any) -> None: ...
def label_tag(self) -> SafeText: ...
def errors(self) -> SafeText: ...
def __init__(self, form: ModelForm, field: str, is_first: bool) -> None: ...
def label_tag(self) -> SafeString: ...
def errors(self) -> SafeString: ...
class _FieldDictT(TypedDict):
name: str
label: str
help_text: str
field: Union[Callable[[Model], Any], str]
class AdminReadonlyField:
field: Any = ...
form: Any = ...
model_admin: Any = ...
is_first: Any = ...
field: _FieldDictT = ...
form: ModelForm = ...
model_admin: Optional[ModelAdmin] = ...
is_first: bool = ...
is_checkbox: bool = ...
is_readonly: bool = ...
empty_value_display: Any = ...
def __init__(self, form: Any, field: Any, is_first: Any, model_admin: Optional[Any] = ...) -> None: ...
def label_tag(self) -> SafeText: ...
def contents(self) -> SafeText: ...
def __init__(
self,
form: ModelForm,
field: Union[Callable[[Model], Any], str],
is_first: bool,
model_admin: Optional[ModelAdmin] = ...,
) -> None: ...
def label_tag(self) -> SafeString: ...
def contents(self) -> SafeString: ...
class InlineAdminFormSet:
opts: Any = ...
formset: Any = ...
fieldsets: Any = ...
model_admin: Any = ...
readonly_fields: Any = ...
prepopulated_fields: Any = ...
classes: Any = ...
has_add_permission: Any = ...
has_change_permission: Any = ...
has_delete_permission: Any = ...
has_view_permission: Any = ...
model_admin: Optional[ModelAdmin] = ...
readonly_fields: Sequence[str] = ...
prepopulated_fields: Dict[str, Any] = ...
classes: str = ...
has_add_permission: bool = ...
has_change_permission: bool = ...
has_delete_permission: bool = ...
has_view_permission: bool = ...
def __init__(
self,
inline: Any,
formset: Any,
fieldsets: Any,
prepopulated_fields: Optional[Any] = ...,
readonly_fields: Optional[Any] = ...,
model_admin: Optional[Any] = ...,
prepopulated_fields: Optional[Dict[str, Any]] = ...,
readonly_fields: Optional[Sequence[str]] = ...,
model_admin: Optional[ModelAdmin] = ...,
has_add_permission: bool = ...,
has_change_permission: bool = ...,
has_delete_permission: bool = ...,
@@ -120,26 +150,27 @@ class InlineAdminFormSet:
@property
def forms(self): ...
@property
def non_form_errors(self) -> Callable: ...
def non_form_errors(self) -> Callable[[], ErrorList]: ...
@property
def media(self) -> Media: ...
class InlineAdminForm(AdminForm):
formset: Any = ...
original: Any = ...
show_url: Any = ...
absolute_url: Any = ...
original: Optional[bool] = ...
show_url: bool = ...
absolute_url: Optional[str] = ...
def __init__(
self,
formset: Any,
form: Any,
form: ModelForm,
fieldsets: Any,
prepopulated_fields: Any,
original: Any,
readonly_fields: Optional[Any] = ...,
model_admin: Optional[Any] = ...,
view_on_site_url: Optional[Any] = ...,
original: Optional[bool],
readonly_fields: Optional[Sequence[str]] = ...,
model_admin: Optional[ModelAdmin] = ...,
view_on_site_url: Optional[str] = ...,
) -> None: ...
def __iter__(self) -> Iterator[InlineFieldset]: ...
def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ...
def pk_field(self) -> AdminField: ...
def fk_field(self) -> AdminField: ...
@@ -149,6 +180,7 @@ class InlineAdminForm(AdminForm):
class InlineFieldset(Fieldset):
formset: Any = ...
def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ...
def __iter__(self) -> Iterator[Fieldline]: ...
class AdminErrorList(forms.utils.ErrorList):
def __init__(self, form: Any, inline_formsets: Any) -> None: ...
def __init__(self, form: ModelForm, inline_formsets: Any) -> None: ...

View File

@@ -1,9 +1,10 @@
from collections import OrderedDict
import sys
from typing import (
Any,
Callable,
Dict,
Generic,
Iterable,
Iterator,
List,
Mapping,
@@ -17,7 +18,7 @@ from typing import (
)
from django import forms
from django.contrib.admin.filters import ListFilter
from django.contrib.admin.filters import FieldListFilter, ListFilter
from django.contrib.admin.models import LogEntry
from django.contrib.admin.sites import AdminSite
from django.contrib.admin.views.main import ChangeList
@@ -25,22 +26,28 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import CheckMessage
from django.core.paginator import Paginator
from django.db import models
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.fields import Field as FormField
from django.forms.fields import TypedChoiceField
from django.forms.forms import BaseForm
from django.forms.formsets import BaseFormSet
from django.forms.models import BaseInlineFormSet, ModelChoiceField, ModelMultipleChoiceField
from django.forms.widgets import Media
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase, HttpResponseRedirect, JsonResponse
from django.template.response import TemplateResponse
from django.http.response import HttpResponse, HttpResponseRedirect, JsonResponse
from django.template.response import _TemplateForResponseT
from django.urls.resolvers import URLPattern
from django.utils.safestring import SafeText
from typing_extensions import Literal, TypedDict
from django.utils.datastructures import _ListOrTuple
from django.utils.safestring import SafeString
if sys.version_info < (3, 8):
from typing_extensions import Literal, TypedDict
else:
from typing import Literal, TypedDict
IS_POPUP_VAR: str
TO_FIELD_VAR: str
@@ -57,19 +64,26 @@ class IncorrectLookupParameters(Exception): ...
FORMFIELD_FOR_DBFIELD_DEFAULTS: Any
csrf_protect_m: Any
_FieldGroups = Sequence[Union[str, Sequence[str]]]
class _OptionalFieldOpts(TypedDict, total=False):
classes: Sequence[str]
description: str
class _FieldOpts(_OptionalFieldOpts, total=True):
fields: Sequence[Union[str, Sequence[str]]]
fields: _FieldGroups
# Workaround for mypy issue, a Sequence type should be preferred here.
# https://github.com/python/mypy/issues/8921
# _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]]
_T = TypeVar("_T")
_ListOrTuple = Union[Tuple[_T, ...], List[_T]]
_FieldsetSpec = _ListOrTuple[Tuple[Optional[str], _FieldOpts]]
_ListFilterT = Union[
Type[ListFilter],
Field,
str,
Tuple[Union[Field, str], Type[FieldListFilter]],
List[Union[Field, str, Type[FieldListFilter]]],
]
# Generic type specifically for models, for use in BaseModelAdmin and subclasses
# https://github.com/typeddjango/django-stubs/issues/482
@@ -78,62 +92,66 @@ _ModelT = TypeVar("_ModelT", bound=Model)
class BaseModelAdmin(Generic[_ModelT]):
autocomplete_fields: Sequence[str] = ...
raw_id_fields: Sequence[str] = ...
fields: Sequence[Union[str, Sequence[str]]] = ...
exclude: Sequence[str] = ...
fieldsets: _FieldsetSpec = ...
form: Type[BaseForm] = ...
fields: Optional[_FieldGroups] = ...
exclude: Optional[Sequence[str]] = ...
fieldsets: Optional[_FieldsetSpec] = ...
form: Type[forms.ModelForm[_ModelT]] = ...
filter_vertical: Sequence[str] = ...
filter_horizontal: Sequence[str] = ...
radio_fields: Mapping[str, _Direction] = ...
prepopulated_fields: Mapping[str, Sequence[str]] = ...
prepopulated_fields: Dict[str, Sequence[str]] = ...
formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] = ...
readonly_fields: Sequence[Union[str, Callable[[_ModelT], Any]]] = ...
ordering: Sequence[str] = ...
sortable_by: Sequence[str] = ...
view_on_site: bool = ...
readonly_fields: Sequence[str] = ...
ordering: Optional[Sequence[str]] = ...
sortable_by: Optional[_ListOrTuple[str]] = ...
view_on_site: Union[bool, Callable[[_ModelT], str]] = ...
show_full_result_count: bool = ...
checks_class: Any = ...
model: Type[_ModelT]
opts: Options[_ModelT]
admin_site: AdminSite
def __init__(self) -> None: ...
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
def formfield_for_dbfield(
self, db_field: models.Field, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[forms.Field]: ...
def formfield_for_choice_field(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> TypedChoiceField: ...
def formfield_for_dbfield(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> Optional[FormField]: ...
def formfield_for_choice_field(self, db_field: Field, request: HttpRequest, **kwargs: Any) -> TypedChoiceField: ...
def get_field_queryset(
self, db: None, db_field: RelatedField, request: Optional[HttpRequest]
self, db: Optional[str], db_field: RelatedField, request: HttpRequest
) -> Optional[QuerySet]: ...
def formfield_for_foreignkey(
self, db_field: ForeignKey, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[ModelChoiceField]: ...
self, db_field: ForeignKey, request: HttpRequest, **kwargs: Any
) -> ModelChoiceField: ...
def formfield_for_manytomany(
self, db_field: ManyToManyField, request: Optional[HttpRequest], **kwargs: Any
) -> ModelMultipleChoiceField: ...
def get_autocomplete_fields(self, request: HttpRequest) -> Tuple: ...
self, db_field: ManyToManyField, request: HttpRequest, **kwargs: Any
) -> Optional[ModelMultipleChoiceField]: ...
def get_autocomplete_fields(self, request: HttpRequest) -> Sequence[str]: ...
def get_view_on_site_url(self, obj: Optional[_ModelT] = ...) -> Optional[str]: ...
def get_empty_value_display(self) -> SafeText: ...
def get_exclude(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Any: ...
def get_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Sequence[Union[Callable, str]]: ...
def get_fieldsets(
def get_empty_value_display(self) -> SafeString: ...
def get_exclude(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Optional[Sequence[str]]: ...
def get_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> _FieldGroups: ...
def get_fieldsets(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> _FieldsetSpec: ...
def get_inlines(self, request: HttpRequest, obj: Optional[_ModelT]) -> List[Type[InlineModelAdmin]]: ...
def get_ordering(self, request: HttpRequest) -> Sequence[str]: ...
def get_readonly_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Sequence[str]: ...
def get_prepopulated_fields(
self, request: HttpRequest, obj: Optional[_ModelT] = ...
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
def get_ordering(self, request: HttpRequest) -> Union[List[str], Tuple]: ...
def get_readonly_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Union[List[str], Tuple]: ...
def get_prepopulated_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Dict[str, Tuple[str]]: ...
def get_queryset(self, request: HttpRequest) -> QuerySet: ...
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
) -> Dict[str, Sequence[str]]: ...
def get_queryset(self, request: HttpRequest) -> QuerySet[_ModelT]: ...
def get_sortable_by(self, request: HttpRequest) -> Sequence[str]: ...
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ...
def has_add_permission(self, request: HttpRequest) -> bool: ...
def has_change_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
def has_delete_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
def has_view_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
def has_view_or_change_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
def has_module_permission(self, request: HttpRequest) -> bool: ...
_DisplayT = _ListOrTuple[Union[str, Callable[[_ModelT], str]]]
class ModelAdmin(BaseModelAdmin[_ModelT]):
list_display: Sequence[Union[str, Callable[[_ModelT], Any]]] = ...
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
list_display: _DisplayT = ...
list_display_links: _DisplayT = ...
list_filter: _ListOrTuple[_ListFilterT] = ...
list_select_related: Union[bool, Sequence[str]] = ...
list_per_page: int = ...
list_max_show_all: int = ...
@@ -146,23 +164,22 @@ class ModelAdmin(BaseModelAdmin[_ModelT]):
paginator: Type = ...
preserve_filters: bool = ...
inlines: Sequence[Type[InlineModelAdmin]] = ...
add_form_template: str = ...
change_form_template: str = ...
change_list_template: str = ...
delete_confirmation_template: str = ...
delete_selected_confirmation_template: str = ...
object_history_template: str = ...
popup_response_template: str = ...
add_form_template: Optional[_TemplateForResponseT] = ...
change_form_template: Optional[_TemplateForResponseT] = ...
change_list_template: Optional[_TemplateForResponseT] = ...
delete_confirmation_template: Optional[_TemplateForResponseT] = ...
delete_selected_confirmation_template: Optional[_TemplateForResponseT] = ...
object_history_template: Optional[_TemplateForResponseT] = ...
popup_response_template: Optional[_TemplateForResponseT] = ...
actions: Optional[Sequence[Union[Callable[[ModelAdmin, HttpRequest, QuerySet], None], str]]] = ...
action_form: Any = ...
actions_on_top: bool = ...
actions_on_bottom: bool = ...
actions_selection_counter: bool = ...
model: Type[_ModelT] = ...
opts: Options = ...
opts: Options[_ModelT] = ...
admin_site: AdminSite = ...
def __init__(self, model: Type[_ModelT], admin_site: Optional[AdminSite]) -> None: ...
def get_inlines(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> List[Type[InlineModelAdmin]]: ...
def __init__(self, model: Type[_ModelT], admin_site: AdminSite) -> None: ...
def get_inline_instances(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> List[InlineModelAdmin]: ...
def get_urls(self) -> List[URLPattern]: ...
@property
@@ -170,11 +187,13 @@ class ModelAdmin(BaseModelAdmin[_ModelT]):
@property
def media(self) -> Media: ...
def get_model_perms(self, request: HttpRequest) -> Dict[str, bool]: ...
def get_form(self, request: Any, obj: Optional[_ModelT] = ..., change: bool = ..., **kwargs: Any): ...
def get_form(
self, request: Any, obj: Optional[_ModelT] = ..., change: bool = ..., **kwargs: Any
) -> Type[forms.ModelForm[_ModelT]]: ...
def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ...
def get_changelist_instance(self, request: HttpRequest) -> ChangeList: ...
def get_object(
self, request: HttpRequest, object_id: str, from_field: Optional[Union[Callable[..., Any], str]] = ...
self, request: HttpRequest, object_id: str, from_field: Optional[str] = ...
) -> Optional[_ModelT]: ...
def get_changelist_form(self, request: Any, **kwargs: Any): ...
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
@@ -190,25 +209,25 @@ class ModelAdmin(BaseModelAdmin[_ModelT]):
def log_addition(self, request: HttpRequest, object: _ModelT, message: Any) -> LogEntry: ...
def log_change(self, request: HttpRequest, object: _ModelT, message: Any) -> LogEntry: ...
def log_deletion(self, request: HttpRequest, object: _ModelT, object_repr: str) -> LogEntry: ...
def action_checkbox(self, obj: _ModelT) -> SafeText: ...
def get_actions(self, request: HttpRequest) -> OrderedDict: ...
def action_checkbox(self, obj: _ModelT) -> SafeString: ...
def get_actions(self, request: HttpRequest) -> Dict[str, Optional[Tuple[Callable[..., str], str, str]]]: ...
def get_action_choices(
self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ...
) -> List[Tuple[str, str]]: ...
def get_action(self, action: Union[Callable, str]) -> Tuple[Callable, str, str]: ...
def get_list_display(self, request: HttpRequest) -> Sequence[str]: ...
def get_list_display_links(self, request: HttpRequest, list_display: Sequence[str]) -> Optional[Sequence[str]]: ...
def get_list_filter(self, request: HttpRequest) -> Sequence[str]: ...
def get_list_select_related(self, request: HttpRequest) -> Sequence[str]: ...
def get_search_fields(self, request: HttpRequest) -> List[str]: ...
def get_action(self, action: Union[Callable, str]) -> Optional[Tuple[Callable[..., str], str, str]]: ...
def get_list_display(self, request: HttpRequest) -> _DisplayT: ...
def get_list_display_links(self, request: HttpRequest, list_display: _DisplayT) -> _DisplayT: ...
def get_list_filter(self, request: HttpRequest) -> Sequence[_ListFilterT]: ...
def get_list_select_related(self, request: HttpRequest) -> Union[bool, Sequence[str]]: ...
def get_search_fields(self, request: HttpRequest) -> Sequence[str]: ...
def get_search_results(
self, request: HttpRequest, queryset: QuerySet, search_term: str
) -> Tuple[QuerySet, bool]: ...
) -> Tuple[QuerySet[_ModelT], bool]: ...
def get_preserved_filters(self, request: HttpRequest) -> str: ...
def _get_edited_object_pks(self, request: HttpRequest, prefix: str) -> List[str]: ...
def _get_list_editable_queryset(self, request: HttpRequest, prefix: str) -> QuerySet: ...
def _get_list_editable_queryset(self, request: HttpRequest, prefix: str) -> QuerySet[_ModelT]: ...
def construct_change_message(
self, request: HttpRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
self, request: HttpRequest, form: AdminPasswordChangeForm, formsets: Iterable[BaseFormSet], add: bool = ...
) -> List[Dict[str, Dict[str, List[str]]]]: ...
def message_user(
self,
@@ -239,44 +258,45 @@ class ModelAdmin(BaseModelAdmin[_ModelT]):
def response_change(self, request: HttpRequest, obj: _ModelT) -> HttpResponse: ...
def response_post_save_add(self, request: HttpRequest, obj: _ModelT) -> HttpResponseRedirect: ...
def response_post_save_change(self, request: HttpRequest, obj: _ModelT) -> HttpResponseRedirect: ...
def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
# Probably FileResponse cannot come from ModelAdmin views
def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponse]: ...
def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
def render_delete_form(self, request: Any, context: Any): ...
def get_inline_formsets(
self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[_ModelT] = ...
) -> List[Any]: ...
def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str]: ...
def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, Union[str, List[str]]]: ...
def changeform_view(
self,
request: HttpRequest,
object_id: Optional[str] = ...,
form_url: str = ...,
extra_context: Optional[Dict[str, Any]] = ...,
) -> Any: ...
def autocomplete_view(self, request: HttpRequest) -> JsonResponse: ...
) -> HttpResponse: ...
def add_view(
self, request: HttpRequest, form_url: str = ..., extra_context: Optional[Dict[str, Any]] = ...
) -> HttpResponse: ...
def change_view(
self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: Optional[Dict[str, Any]] = ...
) -> HttpResponse: ...
def changelist_view(
self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def changelist_view(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def get_deleted_objects(
self, objs: QuerySet, request: HttpRequest
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
self, objs: Union[Sequence[_ModelT], QuerySet[_ModelT]], request: HttpRequest
) -> Tuple[List[Model], Dict[str, int], Set[str], List[str]]: ...
def delete_view(
self, request: HttpRequest, object_id: str, extra_context: Optional[Dict[str, Any]] = ...
) -> Any: ...
) -> HttpResponse: ...
def history_view(
self, request: HttpRequest, object_id: str, extra_context: Optional[Dict[str, Any]] = ...
) -> HttpResponse: ...
class InlineModelAdmin(BaseModelAdmin[_ModelT]):
model: Type[_ModelT] = ...
fk_name: str = ...
formset: Type[BaseInlineFormSet] = ...
_ChildModelT = TypeVar("_ChildModelT", bound=Model)
_ParentModelT = TypeVar("_ParentModelT", bound=Model)
class InlineModelAdmin(Generic[_ChildModelT, _ParentModelT], BaseModelAdmin[_ChildModelT]):
model: Type[_ChildModelT] = ...
fk_name: Optional[str] = ...
formset: Type[BaseInlineFormSet[_ChildModelT, forms.ModelForm[_ChildModelT]]] = ...
extra: int = ...
min_num: Optional[int] = ...
max_num: Optional[int] = ...
@@ -287,16 +307,26 @@ class InlineModelAdmin(BaseModelAdmin[_ModelT]):
show_change_link: bool = ...
classes: Optional[Sequence[str]] = ...
admin_site: AdminSite = ...
parent_model: Any = ...
opts: Any = ...
has_registered_model: Any = ...
def __init__(self, parent_model: Union[Type[_ModelT], _ModelT], admin_site: AdminSite) -> None: ...
parent_model: Type[_ParentModelT] = ...
opts: Options[_ChildModelT] = ...
has_registered_model: bool = ...
def __init__(self, parent_model: Type[_ParentModelT], admin_site: AdminSite) -> None: ...
@property
def media(self) -> Media: ...
def get_extra(self, request: HttpRequest, obj: Optional[_ModelT] = ..., **kwargs: Any) -> int: ...
def get_min_num(self, request: HttpRequest, obj: Optional[_ModelT] = ..., **kwargs: Any) -> Optional[int]: ...
def get_max_num(self, request: HttpRequest, obj: Optional[_ModelT] = ..., **kwargs: Any) -> Optional[int]: ...
def get_formset(self, request: Any, obj: Optional[_ModelT] = ..., **kwargs: Any): ...
def get_extra(self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any) -> int: ...
def get_min_num(self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any) -> Optional[int]: ...
def get_max_num(self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any) -> Optional[int]: ...
def get_formset(
self, request: HttpRequest, obj: Optional[_ParentModelT] = ..., **kwargs: Any
) -> Type[BaseInlineFormSet[_ChildModelT, forms.ModelForm[_ChildModelT]]]: ...
def get_queryset(self, request: HttpRequest) -> QuerySet[_ChildModelT]: ...
def has_add_permission(self, request: HttpRequest, obj: Optional[_ParentModelT]) -> bool: ... # type: ignore
def has_change_permission(self, request: HttpRequest, obj: Optional[_ParentModelT] = ...) -> bool: ... # type: ignore
def has_delete_permission(self, request: HttpRequest, obj: Optional[_ParentModelT] = ...) -> bool: ... # type: ignore
def has_view_permission(self, request: HttpRequest, obj: Optional[_ParentModelT] = ...) -> bool: ... # type: ignore
class StackedInline(InlineModelAdmin[_ModelT]): ...
class TabularInline(InlineModelAdmin[_ModelT]): ...
class StackedInline(InlineModelAdmin[_ChildModelT, _ParentModelT]):
template: str = ...
class TabularInline(InlineModelAdmin[_ChildModelT, _ParentModelT]):
template: str = ...

View File

@@ -5,9 +5,9 @@ from django.apps.config import AppConfig
from django.contrib.admin.options import ModelAdmin
from django.contrib.auth.forms import AuthenticationForm
from django.core.checks import CheckMessage
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.query import QuerySet
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.template.response import TemplateResponse
from django.urls import URLPattern, URLResolver
@@ -22,7 +22,7 @@ else:
all_sites: MutableSet[AdminSite]
_ActionCallback = Callable[[ModelAdmin, WSGIRequest, QuerySet], Optional[TemplateResponse]]
_ActionCallback = Callable[[ModelAdmin, HttpRequest, QuerySet], Optional[TemplateResponse]]
class AlreadyRegistered(Exception): ...
class NotRegistered(Exception): ...
@@ -41,6 +41,7 @@ class AdminSite:
password_change_done_template: Optional[str] = ...
name: str = ...
enable_nav_sidebar: bool = ...
empty_value_display: str = ...
final_catch_all_view: bool = ...
_empty_value_display: str = ...
_registry: Dict[Type[Model], ModelAdmin]
@@ -61,31 +62,29 @@ class AdminSite:
def get_action(self, name: str) -> Callable: ...
@property
def actions(self) -> Iterable[Tuple[str, _ActionCallback]]: ...
@property
def empty_value_display(self) -> str: ...
@empty_value_display.setter
def empty_value_display(self, empty_value_display: str) -> None: ...
def has_permission(self, request: WSGIRequest) -> bool: ...
def has_permission(self, request: HttpRequest) -> bool: ...
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
def get_urls(self) -> List[URLResolver]: ...
def get_urls(self) -> List[Union[URLResolver, URLPattern]]: ...
@property
def urls(self) -> Tuple[List[Union[URLResolver, URLPattern]], str, str]: ...
def each_context(self, request: WSGIRequest) -> Dict[str, Any]: ...
def each_context(self, request: HttpRequest) -> Dict[str, Any]: ...
def password_change(
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def password_change_done(
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def logout(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def login(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def _build_app_dict(self, request: WSGIRequest, label: Optional[str] = ...) -> Dict[str, Any]: ...
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def i18n_javascript(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def logout(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def login(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def _build_app_dict(self, request: HttpRequest, label: Optional[str] = ...) -> Dict[str, Any]: ...
def get_app_list(self, request: HttpRequest) -> List[Any]: ...
def index(self, request: HttpRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def app_index(
self, request: WSGIRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ...
self, request: HttpRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def autocomplete_view(self, request: HttpRequest) -> HttpResponse: ...
def catch_all_view(self, request: HttpRequest, url: str) -> HttpResponse: ...
class DefaultAdminSite(LazyObject): ...

View File

@@ -5,24 +5,25 @@ from django.contrib.admin.templatetags.base import InclusionAdminNode
from django.contrib.admin.views.main import ChangeList
from django.db.models.base import Model
from django.forms.boundfield import BoundField
from django.forms.models import ModelForm
from django.template.base import Parser, Token
from django.template.context import RequestContext
from django.utils.safestring import SafeText
from django.utils.safestring import SafeString
from .base import InclusionAdminNode
register: Any
DOT: str
def paginator_number(cl: ChangeList, i: int) -> SafeText: ...
def pagination(cl: ChangeList) -> Dict[str, Iterable[Any]]: ...
def paginator_number(cl: ChangeList, i: int) -> SafeString: ...
def pagination(cl: ChangeList) -> Dict[str, Any]: ...
def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ...
def items_for_result(cl: ChangeList, result: Model, form: None) -> Iterator[SafeText]: ...
def items_for_result(cl: ChangeList, result: Model, form: Optional[ModelForm]) -> Iterator[SafeString]: ...
class ResultList(list):
form: None = ...
def __init__(self, form: None, *items: Any) -> None: ...
form: Optional[ModelForm] = ...
def __init__(self, form: Optional[ModelForm], *items: Any) -> None: ...
def results(cl: ChangeList) -> Iterator[ResultList]: ...
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
@@ -36,7 +37,7 @@ def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Any]]: ...
def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ...
def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def admin_list_filter(cl: ChangeList, spec: FieldListFilter) -> SafeText: ...
def admin_list_filter(cl: ChangeList, spec: FieldListFilter) -> SafeString: ...
def admin_actions(context: RequestContext) -> RequestContext: ...
def admin_actions_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def change_list_object_tools_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...

View File

@@ -1,5 +0,0 @@
from typing import Any
register: Any
def static(path: str) -> str: ...

View File

@@ -3,11 +3,11 @@ from uuid import UUID
from django.db.models.options import Options
from django.template.context import RequestContext
from django.utils.safestring import SafeText
from django.utils.safestring import SafeString
register: Any
def admin_urlname(value: Options, arg: SafeText) -> str: ...
def admin_urlname(value: Options, arg: SafeString) -> str: ...
def admin_urlquote(value: Union[int, str, UUID]) -> Union[int, str, UUID]: ...
def add_preserved_filters(
context: Union[Dict[str, Union[Options, str]], RequestContext],

View File

@@ -3,15 +3,15 @@ from typing import Any, Callable, Dict, List
from django.template.base import Parser, Token
from django.template.context import Context
from django.template.library import InclusionNode
from django.utils.safestring import SafeText
from django.utils.safestring import SafeString
class InclusionAdminNode(InclusionNode):
args: List[Any]
func: Callable
kwargs: Dict[Any, Any]
kwargs: Dict[str, Any]
takes_context: bool
template_name: str = ...
def __init__(
self, parser: Parser, token: Token, func: Callable, template_name: str, takes_context: bool = ...
) -> None: ...
def render(self, context: Context) -> SafeText: ...
def render(self, context: Context) -> SafeString: ...

View File

@@ -1,4 +1,5 @@
from typing import Any, Callable
from contextlib import contextmanager
from typing import Any, Callable, Generator
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test.selenium import SeleniumTestCase
@@ -8,16 +9,18 @@ class CSPMiddleware(MiddlewareMixin): ...
class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
def wait_until(self, callback: Callable, timeout: int = ...) -> None: ...
def wait_for_popup(self, num_windows: int = ..., timeout: int = ...) -> None: ...
def wait_for_and_switch_to_popup(self, num_windows: int = ..., timeout: int = ...) -> None: ...
def wait_for(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_for_text(self, css_selector: str, text: str, timeout: int = ...) -> None: ...
def wait_for_value(self, css_selector: str, text: str, timeout: int = ...) -> None: ...
def wait_until_visible(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_until_invisible(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_page_loaded(self) -> None: ...
def wait_page_ready(self, timeout: int = ...) -> None: ...
@contextmanager
def wait_page_loaded(self, timeout: int = ...) -> Generator[None, None, None]: ...
def admin_login(self, username: str, password: str, login_url: str = ...) -> None: ...
def get_css_value(self, selector: str, attribute: str) -> Any: ...
def get_select_option(self, selector: str, value: Any) -> Any: ...
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: ...
def assertSelectedOptions(self, selector: str, values: Any) -> None: ...
def has_css_class(self, selector: str, klass: str) -> bool: ...

View File

@@ -1,34 +1,40 @@
import collections
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
import datetime
import sys
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type, Union, overload
from uuid import UUID
from django.contrib.admin.options import BaseModelAdmin
from django.contrib.admin.sites import AdminSite
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.deletion import Collector
from django.db.models.fields import Field, reverse_related
from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.forms import BaseForm
from django.forms.formsets import BaseFormSet
from django.http.request import HttpRequest
from django.utils.datastructures import _IndexableCollection
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
class FieldIsAForeignKeyColumnName(Exception): ...
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
def prepare_lookup_value(key: str, value: Union[datetime, str]) -> Union[bool, datetime, str]: ...
def prepare_lookup_value(key: str, value: Union[datetime.datetime, str]) -> Union[bool, datetime.datetime, str]: ...
def quote(s: Union[int, str, UUID]) -> str: ...
def unquote(s: str) -> str: ...
def flatten(fields: Any) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
def get_deleted_objects(
objs: Sequence[Optional[Model]], request: WSGIRequest, admin_site: AdminSite
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
objs: Union[Sequence[Optional[Model]], QuerySet[Model]], request: HttpRequest, admin_site: AdminSite
) -> Tuple[List[Model], Dict[str, int], Set[str], List[str]]: ...
class NestedObjects(Collector):
data: collections.OrderedDict
data: Dict[str, Any]
dependencies: Dict[Any, Any]
fast_deletes: List[Any]
field_updates: Dict[Any, Any]
@@ -38,21 +44,33 @@ class NestedObjects(Collector):
model_objs: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
def related_objects(self, related: ManyToOneRel, objs: Sequence[Optional[Model]]) -> QuerySet: ...
def related_objects(
self, related_model: Type[Model], related_fields: Iterable[Field], objs: _IndexableCollection[Model]
) -> QuerySet[Model]: ...
def nested(self, format_callback: Callable = ...) -> List[Any]: ...
def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ...
def model_format_dict(obj: Any): ...
def model_format_dict(obj: Union[Model, Type[Model], QuerySet, Options[Model]]): ...
def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ...
def lookup_field(
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
) -> Tuple[Optional[Field], Any, Any]: ...
name: Union[Callable, str], obj: Model, model_admin: Optional[BaseModelAdmin] = ...
) -> Tuple[Optional[Field], Optional[str], Any]: ...
@overload
def label_for_field( # type: ignore
name: Union[Callable, str],
model: Type[Model],
model_admin: Optional[BaseModelAdmin] = ...,
return_attr: Literal[True] = ...,
form: Optional[BaseForm] = ...,
) -> Tuple[str, Union[Callable, str, None]]: ...
@overload
def label_for_field(
name: Union[Callable, str],
model: Type[Model],
model_admin: Optional[BaseModelAdmin] = ...,
return_attr: bool = ...,
return_attr: Literal[False] = ...,
form: Optional[BaseForm] = ...,
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
) -> str: ...
def help_text_for_field(name: str, model: Type[Model]) -> str: ...
def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ...
def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ...
@@ -63,5 +81,5 @@ def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel
def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ...
def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ...
def construct_change_message(
form: AdminPasswordChangeForm, formsets: None, add: bool
form: AdminPasswordChangeForm, formsets: Iterable[BaseFormSet], add: bool
) -> List[Dict[str, Dict[str, List[str]]]]: ...

View File

@@ -1,10 +1,11 @@
from typing import Any
from typing import Any, Optional
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.db.models import Model
from django.http.request import HttpRequest
from django.views.generic.list import BaseListView
class AutocompleteJsonView(BaseListView):
model_admin: ModelAdmin = ...
term: Any = ...
def has_perm(self, request: WSGIRequest, obj: None = ...) -> bool: ...
def has_perm(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...

View File

@@ -1,16 +1,21 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
import sys
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Type, Union
from django.contrib.admin.filters import ListFilter, SimpleListFilter
from django.contrib.admin.filters import ListFilter
from django.contrib.admin.options import IS_POPUP_VAR as IS_POPUP_VAR # noqa: F401
from django.contrib.admin.options import TO_FIELD_VAR as TO_FIELD_VAR
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.contrib.admin.options import ModelAdmin, _DisplayT, _ListFilterT
from django.db.models.base import Model
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
from django.db.models.expressions import Expression
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.formsets import BaseFormSet
from django.http.request import HttpRequest
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
ALL_VAR: str
ORDER_VAR: str
@@ -18,69 +23,75 @@ ORDER_TYPE_VAR: str
PAGE_VAR: str
SEARCH_VAR: str
ERROR_FLAG: str
IGNORED_PARAMS: Any
IGNORED_PARAMS: Tuple[str, ...]
class ChangeList:
model: Type[Model] = ...
opts: Options = ...
lookup_opts: Options = ...
root_queryset: QuerySet = ...
list_display: List[str] = ...
list_display_links: List[str] = ...
list_filter: Tuple = ...
date_hierarchy: None = ...
search_fields: Tuple = ...
list_select_related: bool = ...
list_display: _DisplayT = ...
list_display_links: _DisplayT = ...
list_filter: Sequence[_ListFilterT] = ...
date_hierarchy: Any = ...
search_fields: Sequence[str] = ...
list_select_related: Union[bool, Sequence[str]] = ...
list_per_page: int = ...
list_max_show_all: int = ...
model_admin: ModelAdmin = ...
preserved_filters: str = ...
sortable_by: Tuple[str] = ...
sortable_by: Optional[Sequence[str]] = ...
page_num: int = ...
show_all: bool = ...
is_popup: bool = ...
to_field: None = ...
params: Dict[Any, Any] = ...
list_editable: Tuple = ...
to_field: Any = ...
params: Dict[str, Any] = ...
list_editable: Sequence[str] = ...
query: str = ...
queryset: Any = ...
title: Any = ...
pk_attname: Any = ...
title: str = ...
pk_attname: str = ...
formset: Optional[BaseFormSet]
def __init__(
self,
request: WSGIRequest,
request: HttpRequest,
model: Type[Model],
list_display: Union[List[Union[Callable, str]], Tuple[str]],
list_display_links: Optional[Union[List[Callable], List[str], Tuple[str]]],
list_filter: Union[List[Type[SimpleListFilter]], List[str], Tuple],
list_display: _DisplayT,
list_display_links: _DisplayT,
list_filter: Sequence[_ListFilterT],
date_hierarchy: Optional[str],
search_fields: Union[List[str], Tuple],
list_select_related: Union[Tuple, bool],
search_fields: Sequence[str],
list_select_related: Union[bool, Sequence[str]],
list_per_page: int,
list_max_show_all: int,
list_editable: Union[List[str], Tuple],
list_editable: Sequence[str],
model_admin: ModelAdmin,
sortable_by: Union[List[Callable], List[str], Tuple],
sortable_by: Optional[Sequence[str]],
) -> None: ...
def get_filters_params(self, params: None = ...) -> Dict[str, str]: ...
def get_filters(self, request: WSGIRequest) -> Tuple[List[ListFilter], bool, Dict[str, Union[bool, str]], bool]: ...
def get_filters_params(self, params: Optional[Dict[str, Any]] = ...) -> Dict[str, Any]: ...
def get_filters(
self, request: HttpRequest
) -> Tuple[List[ListFilter], bool, Dict[str, Union[bool, str]], bool, bool]: ...
def get_query_string(
self, new_params: Optional[Dict[str, None]] = ..., remove: Optional[List[str]] = ...
self, new_params: Optional[Dict[str, Any]] = ..., remove: Optional[Iterable[str]] = ...
) -> str: ...
result_count: Any = ...
show_full_result_count: Any = ...
show_admin_actions: Any = ...
full_result_count: Any = ...
result_count: int = ...
show_full_result_count: bool = ...
show_admin_actions: bool = ...
full_result_count: Optional[int] = ...
result_list: Any = ...
can_show_all: Any = ...
multi_page: Any = ...
can_show_all: bool = ...
multi_page: bool = ...
paginator: Any = ...
def get_results(self, request: WSGIRequest) -> None: ...
def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[CombinedExpression, str]]: ...
def get_ordering(self, request: WSGIRequest, queryset: QuerySet) -> List[Union[OrderBy, Combinable, str]]: ...
def get_ordering_field_columns(self) -> OrderedDict: ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def get_results(self, request: HttpRequest) -> None: ...
def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[Expression, str]]: ...
def get_ordering(self, request: HttpRequest, queryset: QuerySet) -> List[Union[Expression, str]]: ...
def get_ordering_field_columns(self) -> Dict[int, Literal["desc", "asc"]]: ...
def get_queryset(self, request: HttpRequest) -> QuerySet: ...
filter_specs: List[ListFilter]
has_filters: bool
has_active_filters: bool
clear_all_filters_qs: str
def apply_select_related(self, qs: QuerySet) -> QuerySet: ...
def has_related_field_in_list_display(self) -> bool: ...
def url_for_result(self, result: Model) -> str: ...

View File

@@ -1,28 +1,31 @@
from typing import Any, Dict, Optional, Tuple, Union
from uuid import UUID
from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
from django import forms
from django.contrib.admin.sites import AdminSite
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel
from django.core.files.base import File
from django.db.models.fields import _FieldChoices
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToManyRel, ManyToOneRel
from django.forms.models import ModelChoiceIterator
from django.forms.widgets import Media
from django.forms.widgets import Media, _OptAttrs
class FilteredSelectMultiple(forms.SelectMultiple):
@property
def media(self) -> Media: ...
verbose_name: Any = ...
is_stacked: Any = ...
def __init__(self, verbose_name: str, is_stacked: bool, attrs: None = ..., choices: Tuple = ...) -> None: ...
verbose_name: str = ...
is_stacked: bool = ...
def __init__(
self, verbose_name: str, is_stacked: bool, attrs: Optional[_OptAttrs] = ..., choices: _FieldChoices = ...
) -> None: ...
class AdminDateWidget(forms.DateInput):
@property
def media(self) -> Media: ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...) -> None: ...
class AdminTimeWidget(forms.TimeInput):
@property
def media(self) -> Media: ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...) -> None: ...
class AdminSplitDateTime(forms.SplitDateTimeWidget):
template_name: str
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ...
class AdminSplitDateTime(forms.SplitDateTimeWidget): ...
class AdminRadioSelect(forms.RadioSelect): ...
class AdminFileWidget(forms.ClearableFileInput): ...
@@ -31,18 +34,27 @@ def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ...
class ForeignKeyRawIdWidget(forms.TextInput):
rel: ManyToOneRel = ...
admin_site: AdminSite = ...
db: None = ...
def __init__(self, rel: ForeignObjectRel, admin_site: AdminSite, attrs: None = ..., using: None = ...) -> None: ...
db: Optional[str] = ...
def __init__(
self, rel: ManyToOneRel, admin_site: AdminSite, attrs: Optional[_OptAttrs] = ..., using: Optional[str] = ...
) -> None: ...
def base_url_parameters(self) -> Dict[str, str]: ...
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ...
def url_parameters(self) -> Dict[str, str]: ...
def label_and_url_for_value(self, value: Union[int, str, UUID]) -> Tuple[str, str]: ...
def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ...
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ...
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
rel: ManyToManyRel = ... # type: ignore
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ...
def url_parameters(self) -> Dict[str, str]: ...
def label_and_url_for_value(self, value: Any) -> Tuple[str, str]: ...
def format_value(self, value: Any) -> Optional[str]: ...
def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ...
class RelatedFieldWidgetWrapper(forms.Widget):
template_name: str = ...
choices: ModelChoiceIterator = ...
widget: forms.Widget = ...
widget: forms.ChoiceWidget = ...
rel: ManyToOneRel = ...
can_add_related: bool = ...
can_change_related: bool = ...
@@ -51,8 +63,8 @@ class RelatedFieldWidgetWrapper(forms.Widget):
admin_site: AdminSite = ...
def __init__(
self,
widget: forms.Widget,
rel: ForeignObjectRel,
widget: forms.ChoiceWidget,
rel: ManyToOneRel,
admin_site: AdminSite,
can_add_related: Optional[bool] = ...,
can_change_related: bool = ...,
@@ -60,42 +72,66 @@ class RelatedFieldWidgetWrapper(forms.Widget):
can_view_related: bool = ...,
) -> None: ...
@property
def media(self) -> Media: ...
def media(self) -> Media: ... # type: ignore
@property
def is_hidden(self) -> bool: ...
def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ...
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ...
def value_from_datadict(self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str) -> Any: ...
def value_omitted_from_data(
self, data: Mapping[str, Any], files: Mapping[str, Iterable[File]], name: str
) -> bool: ...
def id_for_label(self, id_: str) -> str: ...
class AdminTextareaWidget(forms.Textarea): ...
class AdminTextInputWidget(forms.TextInput): ...
class AdminEmailInputWidget(forms.EmailInput): ...
class AdminURLFieldWidget(forms.URLInput): ...
class AdminTextareaWidget(forms.Textarea):
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
class AdminTextInputWidget(forms.TextInput):
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
class AdminEmailInputWidget(forms.EmailInput):
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
class AdminURLFieldWidget(forms.URLInput):
template_name: str
def __init__(self, attrs: Optional[_OptAttrs] = ..., validator_class: Any = ...) -> None: ...
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ...
class AdminIntegerFieldWidget(forms.NumberInput):
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
class_name: str = ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
class_name: str = ...
class AdminUUIDInputWidget(forms.TextInput):
def __init__(self, attrs: Optional[Dict[str, str]] = ...) -> None: ...
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
SELECT2_TRANSLATIONS: Any
SELECT2_TRANSLATIONS: Dict[str, str] = ...
class AutocompleteMixin:
url_name: str = ...
rel: Any = ...
admin_site: Any = ...
db: Any = ...
field: Any = ...
admin_site: AdminSite = ...
db: Optional[str] = ...
choices: Any = ...
attrs: Any = ...
attrs: _OptAttrs = ...
def __init__(
self,
rel: ForeignObjectRel,
field: Any,
admin_site: AdminSite,
attrs: Optional[Dict[str, str]] = ...,
choices: Tuple = ...,
using: None = ...,
attrs: Optional[_OptAttrs] = ...,
choices: Any = ...,
using: Optional[str] = ...,
) -> None: ...
def get_url(self) -> str: ...
@property
def media(self) -> Media: ...
def build_attrs(self, base_attrs: _OptAttrs, extra_attrs: Optional[_OptAttrs] = ...) -> Dict[str, Any]: ...
# typo in source: `attr` instead of `attrs`
def optgroups(
self, name: str, value: Sequence[str], attr: Optional[_OptAttrs] = ...
) -> List[Tuple[Optional[str], List[Dict[str, Any]], Optional[int]]]: ...
class AutocompleteSelect(AutocompleteMixin, forms.Select): ...
class AutocompleteSelectMultiple(AutocompleteMixin, forms.SelectMultiple): ...
class AutocompleteSelect(AutocompleteMixin, forms.Select): ... # type: ignore
class AutocompleteSelectMultiple(AutocompleteMixin, forms.SelectMultiple): ... # type: ignore

View File

@@ -1,10 +1,14 @@
from typing import Any, Callable, Dict, Optional, Tuple
from django.core.handlers.wsgi import WSGIRequest
from django.http.response import HttpResponse
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase
from django.utils.deprecation import MiddlewareMixin
class XViewMiddleware(MiddlewareMixin):
def process_view(
self, request: WSGIRequest, view_func: Callable, view_args: Tuple, view_kwargs: Dict[Any, Any]
self,
request: HttpRequest,
view_func: Callable[..., HttpResponseBase],
view_args: Tuple,
view_kwargs: Dict[Any, Any],
) -> Optional[HttpResponse]: ...

View File

@@ -1,19 +1,18 @@
from typing import Any, Callable, Optional
from typing import Any, Callable, Dict, Optional, Tuple
docutils_is_available: bool
def get_view_name(view_func: Callable) -> str: ...
def trim_docstring(docstring: Any): ...
def parse_docstring(docstring: Any): ...
def parse_rst(text: Any, default_reference_context: Any, thing_being_parsed: Optional[Any] = ...): ...
def parse_docstring(docstring: str) -> Tuple[str, str, Dict[str, str]]: ...
def parse_rst(text: str, default_reference_context: Any, thing_being_parsed: Optional[Any] = ...): ...
ROLES: Any
ROLES: Dict[str, str]
def create_reference_role(rolename: Any, urlbase: Any): ...
def create_reference_role(rolename: str, urlbase: str) -> None: ...
def default_reference_role(
name: Any,
rawtext: Any,
text: Any,
name: str,
rawtext: str,
text: str,
lineno: Any,
inliner: Any,
options: Optional[Any] = ...,

View File

@@ -3,8 +3,6 @@ from typing import Any, List, Optional, Type, Union
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.options import Options
from django.http.request import HttpRequest
from django.test.client import Client
@@ -20,12 +18,12 @@ REDIRECT_FIELD_NAME: str
def load_backend(path: str) -> ModelBackend: ...
def get_backends() -> List[ModelBackend]: ...
def authenticate(request: Any = ..., **credentials: Any) -> Optional[AbstractBaseUser]: ...
def authenticate(request: Optional[HttpRequest] = ..., **credentials: Any) -> Optional[AbstractBaseUser]: ...
def login(
request: HttpRequest, user: Optional[AbstractBaseUser], backend: Optional[Union[Type[ModelBackend], str]] = ...
) -> None: ...
def logout(request: HttpRequest) -> None: ...
def get_user_model() -> Type[Model]: ...
def get_user_model() -> Type[AbstractBaseUser]: ...
def get_user(request: Union[HttpRequest, Client]) -> Union[AbstractBaseUser, AnonymousUser]: ...
def get_permission_codename(action: str, opts: Options) -> str: ...
def update_session_auth_hash(request: HttpRequest, user: AbstractBaseUser) -> None: ...

View File

@@ -1,7 +1,7 @@
from typing import Any
from django.contrib import admin
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
csrf_protect_m: Any
@@ -14,4 +14,4 @@ class UserAdmin(admin.ModelAdmin):
add_fieldsets: Any = ...
add_form: Any = ...
change_password_form: Any = ...
def user_change_password(self, request: WSGIRequest, id: str, form_url: str = ...) -> HttpResponse: ...
def user_change_password(self, request: HttpRequest, id: str, form_url: str = ...) -> HttpResponse: ...

View File

@@ -1,11 +1,11 @@
from typing import Any, Optional, Set, Union
from typing import Any, Optional, Set, TypeVar, Union
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser, Permission, User
from django.contrib.auth.models import AnonymousUser, Permission
from django.db.models.base import Model
from django.http.request import HttpRequest
_AnyUser = Union[Model, AnonymousUser]
_AnyUser = Union[AbstractBaseUser, AnonymousUser]
UserModel: Any
@@ -18,6 +18,13 @@ class BaseBackend:
def has_perm(self, user_obj: _AnyUser, perm: str, obj: Optional[Model] = ...) -> bool: ...
class ModelBackend(BaseBackend):
def authenticate(
self,
request: Optional[HttpRequest],
username: Optional[str] = ...,
password: Optional[str] = ...,
**kwargs: Any
) -> Optional[AbstractBaseUser]: ...
def has_module_perms(self, user_obj: _AnyUser, app_label: str) -> bool: ...
def user_can_authenticate(self, user: Optional[_AnyUser]) -> bool: ...
def with_perm(
@@ -30,9 +37,11 @@ class ModelBackend(BaseBackend):
class AllowAllUsersModelBackend(ModelBackend): ...
_U = TypeVar("_U", bound=AbstractBaseUser)
class RemoteUserBackend(ModelBackend):
create_unknown_user: bool = ...
def clean_username(self, username: str) -> str: ...
def configure_user(self, request: HttpRequest, user: User) -> User: ...
def configure_user(self, request: HttpRequest, user: _U) -> _U: ...
class AllowAllUsersRemoteUserBackend(RemoteUserBackend): ...

View File

@@ -1,7 +1,9 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage
def check_user_model(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_models_permissions(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_user_model(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> Sequence[CheckMessage]: ...
def check_models_permissions(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> Sequence[CheckMessage]: ...

View File

@@ -1,4 +1,4 @@
from typing import Callable, List, Optional, Set, TypeVar, Union, overload
from typing import Callable, Iterable, Optional, TypeVar, Union, overload
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
from django.contrib.auth.models import AbstractUser
@@ -16,5 +16,5 @@ def login_required(redirect_field_name: str = ..., login_url: Optional[str] = ..
@overload
def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: Optional[str] = ...) -> _VIEW: ...
def permission_required(
perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ...
perm: Union[Iterable[str], str], login_url: Optional[str] = ..., raise_exception: bool = ...
) -> Callable[[_VIEW], _VIEW]: ...

View File

@@ -1,49 +1,58 @@
from typing import Any, Dict, Iterable, Optional
from typing import Any, Dict, Iterable, List, Optional, Type, TypeVar, Union
from django import forms
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import User
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.core.exceptions import ValidationError
from django.core.handlers.wsgi import WSGIRequest
from django.db import models
from django.db.models.fields import _ErrorMessagesT
from django.forms.fields import _ClassLevelWidgetT
from django.forms.widgets import Widget
from django.http.request import HttpRequest
UserModel: Any
UserModel: Type[AbstractBaseUser]
_User = TypeVar("_User", bound=AbstractBaseUser)
class ReadOnlyPasswordHashWidget(forms.Widget):
template_name: str = ...
read_only: bool = ...
def get_context(self, name: str, value: Any, attrs: Optional[Dict[str, Any]]) -> Dict[str, Any]: ...
class ReadOnlyPasswordHashField(forms.Field):
widget: _ClassLevelWidgetT = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class UsernameField(forms.CharField): ...
class UsernameField(forms.CharField):
def to_python(self, value: Optional[Any]) -> Optional[Any]: ...
def widget_attrs(self, widget: Widget) -> Dict[str, Any]: ...
class UserCreationForm(forms.ModelForm):
error_messages: Any = ...
password1: Any = ...
password2: Any = ...
class UserCreationForm(forms.ModelForm[_User]):
error_messages: _ErrorMessagesT = ...
password1: forms.Field = ...
password2: forms.Field = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> _User: ...
class UserChangeForm(forms.ModelForm):
password: Any = ...
class UserChangeForm(forms.ModelForm[_User]):
password: forms.Field = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password(self) -> str: ...
class AuthenticationForm(forms.Form):
username: Any = ...
password: Any = ...
error_messages: Any = ...
request: WSGIRequest = ...
user_cache: None = ...
username_field: Any = ...
def __init__(self, request: Any = ..., *args: Any, **kwargs: Any) -> None: ...
username: forms.Field = ...
password: forms.Field = ...
error_messages: _ErrorMessagesT = ...
request: Optional[HttpRequest] = ...
user_cache: Any = ...
username_field: models.Field = ...
def __init__(self, request: Optional[HttpRequest] = ..., *args: Any, **kwargs: Any) -> None: ...
def confirm_login_allowed(self, user: AbstractBaseUser) -> None: ...
def get_user(self) -> User: ...
def get_user(self) -> AbstractBaseUser: ...
def get_invalid_login_error(self) -> ValidationError: ...
def clean(self) -> Dict[str, Any]: ...
class PasswordResetForm(forms.Form):
email: Any = ...
email: forms.Field = ...
def send_mail(
self,
subject_template_name: str,
@@ -53,7 +62,7 @@ class PasswordResetForm(forms.Form):
to_email: str,
html_email_template_name: Optional[str] = ...,
) -> None: ...
def get_users(self, email: str) -> Iterable[Any]: ...
def get_users(self, email: str) -> Iterable[AbstractBaseUser]: ...
def save(
self,
domain_override: Optional[str] = ...,
@@ -68,24 +77,27 @@ class PasswordResetForm(forms.Form):
) -> None: ...
class SetPasswordForm(forms.Form):
error_messages: Any = ...
new_password1: Any = ...
new_password2: Any = ...
user: User = ...
def __init__(self, user: Optional[AbstractBaseUser], *args: Any, **kwargs: Any) -> None: ...
error_messages: _ErrorMessagesT = ...
new_password1: forms.Field = ...
new_password2: forms.Field = ...
user: AbstractBaseUser = ...
def __init__(self, user: AbstractBaseUser, *args: Any, **kwargs: Any) -> None: ...
def clean_new_password2(self) -> str: ...
def save(self, commit: bool = ...) -> AbstractBaseUser: ...
class PasswordChangeForm(SetPasswordForm):
old_password: Any = ...
error_messages: _ErrorMessagesT = ...
old_password: forms.Field = ...
def clean_old_password(self) -> str: ...
class AdminPasswordChangeForm(forms.Form):
error_messages: Any = ...
error_messages: _ErrorMessagesT = ...
required_css_class: str = ...
password1: Any = ...
password2: Any = ...
user: User = ...
password1: forms.Field = ...
password2: forms.Field = ...
user: AbstractBaseUser = ...
def __init__(self, user: AbstractBaseUser, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> AbstractBaseUser: ...
@property
def changed_data(self) -> List[str]: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
UNUSABLE_PASSWORD_PREFIX: str
UNUSABLE_PASSWORD_SUFFIX_LENGTH: int
@@ -19,7 +19,7 @@ def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ...
class BasePasswordHasher:
algorithm: str = ...
library: str = ...
library: Union[str, Tuple[str, str]] = ...
rounds: int = ...
time_cost: int = ...
memory_cost: int = ...

View File

@@ -12,4 +12,4 @@ def create_permissions(
**kwargs: Any
) -> None: ...
def get_system_username() -> str: ...
def get_default_username(check_db: bool = ...) -> str: ...
def get_default_username(check_db: bool = ..., database: str = ...) -> str: ...

View File

@@ -1,11 +1,11 @@
from typing import Union
from django.contrib.auth.models import AnonymousUser, User
from django.core.handlers.wsgi import WSGIRequest
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser
from django.http.request import HttpRequest
from django.utils.deprecation import MiddlewareMixin
def get_user(request: WSGIRequest) -> Union[AnonymousUser, User]: ...
def get_user(request: HttpRequest) -> Union[AnonymousUser, AbstractBaseUser]: ...
class AuthenticationMiddleware(MiddlewareMixin):
def process_request(self, request: HttpRequest) -> None: ...

View File

@@ -1,7 +1,7 @@
from typing import Any, Callable, List, Optional
from typing import Any, Callable, Optional, Sequence
from django import http
from django.http.response import HttpResponse, HttpResponseRedirect
from django.http.response import HttpResponseBase, HttpResponseRedirect
class AccessMixin:
login_url: Any = ...
@@ -14,15 +14,15 @@ class AccessMixin:
def handle_no_permission(self) -> HttpResponseRedirect: ...
class LoginRequiredMixin(AccessMixin):
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ...
class PermissionRequiredMixin(AccessMixin):
permission_required: Any = ...
def get_permission_required(self) -> List[str]: ...
def get_permission_required(self) -> Sequence[str]: ...
def has_permission(self) -> bool: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ...
class UserPassesTestMixin(AccessMixin):
def test_func(self) -> Optional[bool]: ...
def get_test_func(self) -> Callable: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponseBase: ...

View File

@@ -1,7 +1,6 @@
import sys
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
from typing import Any, Iterable, Optional, Set, Tuple, Type, TypeVar, Union
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser
from django.contrib.auth.base_user import BaseUserManager as BaseUserManager
from django.contrib.auth.validators import UnicodeUsernameValidator
@@ -48,14 +47,14 @@ class UserManager(BaseUserManager[_T]):
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> _T: ...
def create_superuser(
self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> _T: ...
def with_perm(
self,
perm: Union[str, Permission],
is_active: bool = ...,
include_superusers: bool = ...,
backend: Optional[Union[Type[ModelBackend], str]] = ...,
backend: Optional[str] = ...,
obj: Optional[Model] = ...,
): ...
@@ -67,7 +66,7 @@ class PermissionsMixin(models.Model):
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Iterable[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def has_module_perms(self, app_label: str) -> bool: ...
class AbstractUser(AbstractBaseUser, PermissionsMixin):
@@ -92,13 +91,13 @@ class User(AbstractUser): ...
class AnonymousUser:
id: Any = ...
pk: Any = ...
username: str = ...
is_staff: bool = ...
is_active: bool = ...
is_superuser: bool = ...
def save(self) -> Any: ...
def delete(self) -> Any: ...
def set_password(self, raw_password: str) -> Any: ...
username: Literal[""] = ...
is_staff: Literal[False] = ...
is_active: Literal[False] = ...
is_superuser: Literal[False] = ...
def save(self) -> None: ...
def delete(self) -> None: ...
def set_password(self, raw_password: str) -> None: ...
def check_password(self, raw_password: str) -> Any: ...
@property
def groups(self) -> EmptyManager: ...
@@ -108,7 +107,7 @@ class AnonymousUser:
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[Any]: ...
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Iterable[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def has_module_perms(self, module: str) -> bool: ...
@property
def is_anonymous(self) -> Literal[True]: ...

View File

@@ -6,7 +6,8 @@ from django.db.models.base import Model
_UserModel = Model
class PasswordValidator(Protocol):
def password_changed(self, password: str, user: Optional[_UserModel] = ...): ...
def validate(self, __password: str, __user: Optional[_UserModel] = ...) -> None: ...
def get_help_text(self) -> str: ...
def get_default_password_validators() -> List[PasswordValidator]: ...
def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ...
@@ -37,7 +38,7 @@ class UserAttributeSimilarityValidator:
class CommonPasswordValidator:
DEFAULT_PASSWORD_LIST_PATH: Path = ...
passwords: Set[str] = ...
def __init__(self, password_list_path: Union[PosixPath, str] = ...) -> None: ...
def __init__(self, password_list_path: Union[Path, PosixPath, str] = ...) -> None: ...
def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
def get_help_text(self) -> str: ...

View File

@@ -1,5 +1,5 @@
from datetime import date
from typing import Any, Optional
from datetime import date, datetime
from typing import Any, Optional, Union
from django.contrib.auth.base_user import AbstractBaseUser
@@ -9,9 +9,9 @@ class PasswordResetTokenGenerator:
algorithm: str = ...
def make_token(self, user: AbstractBaseUser) -> str: ...
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...
def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int) -> str: ...
def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int, legacy: bool = ...) -> str: ...
def _make_hash_value(self, user: AbstractBaseUser, timestamp: int) -> str: ...
def _num_days(self, dt: date) -> float: ...
def _today(self) -> date: ...
def _num_seconds(self, dt: Union[datetime, date]) -> int: ...
def _now(self) -> datetime: ...
default_token_generator: Any

View File

@@ -2,10 +2,8 @@ from typing import Any, Optional, Set
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.forms import AuthenticationForm
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponseRedirect
from django.template.response import TemplateResponse
from django.http.response import HttpResponse, HttpResponseRedirect
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView
@@ -23,10 +21,11 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView[AuthenticationForm]):
def get_redirect_url(self) -> str: ...
class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
next_page: Any = ...
redirect_field_name: Any = ...
next_page: Optional[str] = ...
redirect_field_name: str = ...
extra_context: Any = ...
def post(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> TemplateResponse: ...
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_next_page(self) -> Optional[str]: ...
def logout_then_login(request: HttpRequest, login_url: Optional[str] = ...) -> HttpResponseRedirect: ...

View File

@@ -1,9 +1,10 @@
from typing import Any, List, Type
from django.contrib.admin.checks import InlineModelAdminChecks
from django.contrib.admin.options import InlineModelAdmin
from django.db.models.base import Model
class GenericInlineModelAdminChecks:
class GenericInlineModelAdminChecks(InlineModelAdminChecks):
def _check_exclude_of_parent_model(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ...
def _check_relation(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ...

View File

@@ -1,9 +1,11 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage
def check_generic_foreign_keys(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> List[CheckMessage]: ...
def check_model_name_lengths(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
) -> Sequence[CheckMessage]: ...
def check_model_name_lengths(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> Sequence[CheckMessage]: ...

View File

@@ -4,7 +4,7 @@ from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import CheckMessage
from django.db.models.base import Model
from django.db.models.expressions import Combinable
from django.db.models.fields import Field, PositiveIntegerField
from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignObject
from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor
@@ -48,7 +48,7 @@ class GenericForeignKey(FieldCacheMixin):
def get_prefetch_queryset(
self, instances: Union[List[Model], QuerySet], queryset: Optional[QuerySet] = ...
) -> Tuple[List[Model], Callable, Callable, bool, str, bool]: ...
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Optional[Any]: ...
def __get__(self, instance: Optional[Model], cls: Optional[Type[Model]] = ...) -> Optional[Any]: ...
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
class GenericRel(ForeignObjectRel):
@@ -65,9 +65,9 @@ class GenericRel(ForeignObjectRel):
class GenericRelation(ForeignObject):
rel_class: Any = ...
mti_inherited: bool = ...
object_id_field_name: Any = ...
content_type_field_name: Any = ...
for_concrete_model: Any = ...
object_id_field_name: str = ...
content_type_field_name: str = ...
for_concrete_model: bool = ...
to_fields: Any = ...
def __init__(
self,
@@ -79,9 +79,9 @@ class GenericRelation(ForeignObject):
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
**kwargs: Any
) -> None: ...
def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ...
def resolve_related_fields(self) -> List[Tuple[Field, Field]]: ...
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
def get_reverse_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
def get_content_type(self) -> ContentType: ...
def get_extra_restriction(
self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str

View File

@@ -38,4 +38,6 @@ def generic_inlineformset_factory(
for_concrete_model: bool = ...,
min_num: Optional[Any] = ...,
validate_min: bool = ...,
absolute_max: Optional[int] = ...,
can_delete_extra: bool = ...,
): ...

View File

@@ -1,6 +1,6 @@
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class FlatpageFallbackMiddleware(MiddlewareMixin):
def process_response(self, request: WSGIRequest, response: HttpResponse) -> HttpResponse: ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...

View File

@@ -1,8 +1,8 @@
from django.contrib.flatpages.models import FlatPage
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
DEFAULT_TEMPLATE: str
def flatpage(request: WSGIRequest, url: str) -> HttpResponse: ...
def render_flatpage(request: WSGIRequest, f: FlatPage) -> HttpResponse: ...
def flatpage(request: HttpRequest, url: str) -> HttpResponse: ...
def render_flatpage(request: HttpRequest, f: FlatPage) -> HttpResponse: ...

View File

@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Union
from django.contrib.admin import ModelAdmin as ModelAdmin
@@ -14,9 +14,9 @@ class GeoModelAdmin(ModelAdmin):
num_zoom: int = ...
max_zoom: bool = ...
min_zoom: bool = ...
units: bool = ...
max_resolution: bool = ...
max_extent: bool = ...
units: Union[str, bool] = ...
max_resolution: Union[str, bool] = ...
max_extent: Union[str, bool] = ...
modifiable: bool = ...
mouse_position: bool = ...
scale_text: bool = ...
@@ -43,4 +43,7 @@ class OSMGeoAdmin(GeoModelAdmin):
map_template: str = ...
num_zoom: int = ...
map_srid: Any = ...
point_zoom: Any = ...
max_extent: str = ...
max_resolution: str = ...
point_zoom: int = ...
units: str = ...

View File

@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Set
class BaseSpatialOperations:
postgis: bool = ...
@@ -7,27 +7,28 @@ class BaseSpatialOperations:
oracle: bool = ...
spatial_version: Any = ...
select: str = ...
def select_extent(self): ...
@property
def select_extent(self) -> str: ...
geography: bool = ...
geometry: bool = ...
disallowed_aggregates: Any = ...
geom_func_prefix: str = ...
function_names: Any = ...
unsupported_functions: Any = ...
unsupported_functions: Set[str] = ...
from_text: bool = ...
def convert_extent(self, box: Any, srid: Any) -> None: ...
def convert_extent3d(self, box: Any, srid: Any) -> None: ...
def convert_extent(self, box: Any, srid: Any) -> Any: ...
def convert_extent3d(self, box: Any, srid: Any) -> Any: ...
def geo_quote_name(self, name: Any): ...
def geo_db_type(self, f: Any) -> None: ...
def get_distance(self, f: Any, value: Any, lookup_type: Any) -> None: ...
def geo_db_type(self, f: Any) -> Any: ...
def get_distance(self, f: Any, value: Any, lookup_type: Any) -> Any: ...
def get_geom_placeholder(self, f: Any, value: Any, compiler: Any): ...
def check_expression_support(self, expression: Any) -> None: ...
def spatial_aggregate_name(self, agg_name: Any) -> None: ...
def spatial_aggregate_name(self, agg_name: Any) -> Any: ...
def spatial_function_name(self, func_name: Any): ...
def geometry_columns(self) -> None: ...
def spatial_ref_sys(self) -> None: ...
def geometry_columns(self) -> Any: ...
def spatial_ref_sys(self) -> Any: ...
distance_expr_for_lookup: Any = ...
def get_db_converters(self, expression: Any): ...
def get_geometry_converter(self, expression: Any) -> None: ...
def get_geometry_converter(self, expression: Any) -> Any: ...
def get_area_att_for_field(self, field: Any): ...
def get_distance_att_for_field(self, field: Any): ...

View File

@@ -1,3 +1,5 @@
from typing import Any, Dict
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures
@@ -10,5 +12,9 @@ class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
supports_transform: bool = ...
supports_null_geometries: bool = ...
supports_num_points_poly: bool = ...
def supports_empty_geometry_collection(self): ...
def supports_geometry_field_unique_index(self): ...
@property
def empty_intersection_returns_none(self) -> bool: ...
@property
def supports_geometry_field_unique_index(self) -> bool: ... # type: ignore
@property
def django_test_skips(self) -> Dict[str, Any]: ... # type: ignore

View File

@@ -1,18 +1,27 @@
from typing import Any
from typing import Any, Callable, Dict, List, Optional, Set, Type
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations as BaseSpatialOperations
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.geos.geometry import GEOSGeometryBase
from django.db.backends.mysql.operations import DatabaseOperations as DatabaseOperations
class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
mysql: bool = ...
name: str = ...
geom_func_prefix: str = ...
Adapter: Any = ...
def select(self): ...
def from_text(self): ...
def gis_operators(self): ...
@property
def mariadb(self) -> bool: ...
@property
def mysql(self) -> bool: ... # type: ignore
@property
def select(self) -> str: ... # type: ignore
@property
def from_text(self) -> str: ... # type: ignore
@property
def gis_operators(self) -> Dict[str, SpatialOperator]: ...
disallowed_aggregates: Any = ...
def unsupported_functions(self): ...
def geo_db_type(self, f: Any): ...
def get_distance(self, f: Any, value: Any, lookup_type: Any): ...
def get_geometry_converter(self, expression: Any): ...
@property
def unsupported_functions(self) -> Set[str]: ... # type: ignore
def geo_db_type(self, f: Any) -> Any: ...
def get_distance(self, f: Any, value: Any, lookup_type: Any) -> List[Any]: ...
def get_geometry_converter(self, expression: Any) -> Callable[[Any, Any, Any], Optional[GEOSGeometryBase]]: ...

View File

@@ -3,5 +3,6 @@ from typing import Any
from django.db.backends.oracle.introspection import DatabaseIntrospection as DatabaseIntrospection
class OracleIntrospection(DatabaseIntrospection):
@property
def data_types_reverse(self): ...
def get_geometry_type(self, table_name: Any, description: Any): ...

View File

@@ -1,22 +1,31 @@
from typing import Any
import sys
from typing import Any, Union
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.db.backends.postgresql.operations import DatabaseOperations
from django.db.models import Func
BILATERAL: str
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
BILATERAL: Literal["bilateral"]
class PostGISOperator(SpatialOperator):
geography: Any = ...
raster: Any = ...
def __init__(self, geography: bool = ..., raster: bool = ..., **kwargs: Any) -> None: ...
raster: Union[bool, Literal["bilateral"]] = ...
def __init__(
self, geography: bool = ..., raster: Union[bool, Literal["bilateral"]] = ..., **kwargs: Any
) -> None: ...
def as_sql(self, connection: Any, lookup: Any, template_params: Any, *args: Any): ...
def check_raster(self, lookup: Any, template_params: Any): ...
class ST_Polygon(Func):
function: str = ...
def __init__(self, expr: Any) -> None: ...
@property
def output_field(self): ...
class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
@@ -36,7 +45,9 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
unsupported_functions: Any = ...
select: str = ...
select_extent: Any = ...
@property
def function_names(self): ...
@property
def spatial_version(self): ...
def geo_db_type(self, f: Any): ...
def get_distance(self, f: Any, dist_val: Any, lookup_type: Any): ...

View File

@@ -3,4 +3,5 @@ from django.db.backends.sqlite3.features import DatabaseFeatures as SQLiteDataba
class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures):
supports_3d_storage: bool = ...
@property
def supports_area_geodetic(self): ...

View File

@@ -19,12 +19,14 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
disallowed_aggregates: Any = ...
select: str = ...
function_names: Any = ...
@property
def unsupported_functions(self): ...
@property
def spatial_version(self): ...
def geo_db_type(self, f: Any) -> None: ...
def get_distance(self, f: Any, value: Any, lookup_type: Any): ...
def geos_version(self): ...
def proj4_version(self): ...
def proj_version(self): ...
def lwgeom_version(self): ...
def spatialite_version(self): ...
def spatialite_version_tuple(self): ...

View File

@@ -5,6 +5,7 @@ from django.db.models import Aggregate
class GeoAggregate(Aggregate):
function: Any = ...
is_extent: bool = ...
@property
def output_field(self): ...
def as_sql(self, compiler: Any, connection: Any, function: Optional[Any] = ..., **extra_context: Any): ...
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...

View File

@@ -1,6 +1,7 @@
from typing import Any, Iterable, NamedTuple, Optional, Tuple, TypeVar, Union
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
from django.core.validators import _ValidatorCallable
from django.db.models.fields import Field, _ErrorMessagesT, _FieldChoices
# __set__ value type
_ST = TypeVar("_ST")
@@ -21,6 +22,7 @@ class BaseSpatialField(Field[_ST, _GT]):
verbose_name: Optional[Union[str, bytes]] = ...,
srid: int = ...,
spatial_index: bool = ...,
*,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
@@ -40,7 +42,7 @@ class BaseSpatialField(Field[_ST, _GT]):
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
): ...
def deconstruct(self): ...
def db_type(self, connection: Any): ...
@@ -66,6 +68,7 @@ class GeometryField(BaseSpatialField):
verbose_name: Optional[Union[str, bytes]] = ...,
dim: int = ...,
geography: bool = ...,
*,
extent: Tuple[float, float, float, float] = ...,
tolerance: float = ...,
srid: int = ...,
@@ -89,10 +92,10 @@ class GeometryField(BaseSpatialField):
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
): ...
def deconstruct(self): ...
def formfield(self, **kwargs: Any): ...
def formfield(self, **kwargs: Any): ... # type: ignore[override]
def select_format(self, compiler: Any, sql: Any, params: Any): ...
class PointField(GeometryField):

View File

@@ -9,6 +9,7 @@ class GeoFuncMixin:
function: Any = ...
geom_param_pos: Any = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
@property
def geo_field(self): ...
def as_sql(self, compiler: Any, connection: Any, function: Optional[Any] = ..., **extra_context: Any): ...
def resolve_expression(self, *args: Any, **kwargs: Any): ...
@@ -16,6 +17,7 @@ class GeoFuncMixin:
class GeoFunc(GeoFuncMixin, Func): ...
class GeomOutputGeoFunc(GeoFunc):
@property
def output_field(self): ...
class SQLiteDecimalToFloatMixin:
@@ -27,6 +29,7 @@ class OracleToleranceMixin:
class Area(OracleToleranceMixin, GeoFunc):
arity: int = ...
@property
def output_field(self): ...
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
@@ -64,7 +67,7 @@ class AsWKT(GeoFunc):
output_field: Any = ...
arity: int = ...
class BoundingCircle(OracleToleranceMixin, GeoFunc):
class BoundingCircle(OracleToleranceMixin, GeomOutputGeoFunc):
def __init__(self, expression: Any, num_seg: int = ..., **extra: Any) -> None: ...
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
@@ -76,6 +79,7 @@ class Difference(OracleToleranceMixin, GeomOutputGeoFunc):
geom_param_pos: Any = ...
class DistanceResultMixin:
@property
def output_field(self): ...
def source_is_geography(self): ...

View File

@@ -20,9 +20,11 @@ class GDALRaster(GDALRasterBase):
def __del__(self) -> None: ...
@property
def vsi_buffer(self): ...
@property
def is_vsi_based(self): ...
@property
def name(self): ...
@property
def driver(self): ...
@property
def width(self): ...
@@ -53,7 +55,7 @@ class GDALRaster(GDALRasterBase):
def warp(self, ds_input: Any, resampling: str = ..., max_error: float = ...): ...
def transform(
self,
srid: Any,
srs: Any,
driver: Optional[Any] = ...,
name: Optional[Any] = ...,
resampling: str = ...,

View File

@@ -38,6 +38,7 @@ class GEOSFuncFactory:
argtypes: Optional[Any] = ...
) -> None: ...
def __call__(self, *args: Any): ...
@property
def func(self): ...
def geos_version(): ...

View File

@@ -36,7 +36,7 @@ class LayerMapping:
using: Optional[Any] = ...,
) -> None: ...
def check_fid_range(self, fid_range: Any): ...
geom_field: bool = ...
geom_field: str = ...
fields: Any = ...
coord_dim: Any = ...
def check_layer(self): ...

View File

@@ -7,5 +7,5 @@ class BitAnd(Aggregate): ...
class BitOr(Aggregate): ...
class BoolAnd(Aggregate): ...
class BoolOr(Aggregate): ...
class JSONBAgg(Aggregate): ...
class JSONBAgg(OrderableAggMixin, Aggregate): ...
class StringAgg(OrderableAggMixin, Aggregate): ...

View File

@@ -1,5 +1,6 @@
from typing import Optional, Sequence, Tuple, Union
from typing import List, Optional, Sequence, Tuple, Union
from django.db.models import Deferrable
from django.db.models.constraints import BaseConstraint
from django.db.models.expressions import Combinable
from django.db.models.query_utils import Q
@@ -13,6 +14,9 @@ class ExclusionConstraint(BaseConstraint):
*,
name: str,
expressions: Sequence[Tuple[Union[str, Combinable], str]],
condition: Optional[Q] = ...,
index_type: Optional[str] = ...,
condition: Optional[Q] = ...,
deferrable: Optional[Deferrable] = ...,
include: Union[List[str], Tuple[str], None] = ...,
opclasses: Union[List[str], Tuple[str]] = ...,
): ...

View File

@@ -4,13 +4,11 @@ from .citext import CIEmailField as CIEmailField
from .citext import CIText as CIText
from .citext import CITextField as CITextField
from .hstore import HStoreField as HStoreField
from .jsonb import JsonAdapter as JsonAdapter
from .jsonb import JSONField as JSONField
from .ranges import BigIntegerRangeField as BigIntegerRangeField
from .ranges import DateRangeField as DateRangeField
from .ranges import DateTimeRangeField as DateTimeRangeField
from .ranges import DecimalRangeField as DecimalRangeField
from .ranges import FloatRangeField as FloatRangeField
from .ranges import IntegerRangeField as IntegerRangeField
from .ranges import RangeBoundary as RangeBoundary
from .ranges import RangeField as RangeField

View File

@@ -1,9 +1,10 @@
from typing import Any, Iterable, List, Optional, Sequence, TypeVar, Union
from typing import Any, Iterable, List, Optional, Sequence, Type, TypeVar, Union
from django.core.validators import _ValidatorCallable
from django.db.models import Field, Transform
from django.db.models.expressions import Combinable
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
from .mixins import CheckFieldDefaultMixin
from django.db.models.fields import _ErrorMessagesT, _FieldChoices
from django.db.models.fields.mixins import CheckFieldDefaultMixin
# __set__ value type
_ST = TypeVar("_ST")
@@ -15,15 +16,16 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]):
_pyi_private_get_type: List[Any]
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
base_field: Any = ...
size: Any = ...
default_validators: Any = ...
default_error_messages: _ErrorMessagesT = ...
base_field: Field = ...
size: Optional[int] = ...
default_validators: Sequence[_ValidatorCallable] = ...
from_db_value: Any = ...
def __init__(
self,
base_field: Field,
size: Optional[int] = ...,
*,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
@@ -44,8 +46,8 @@ class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]):
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
error_messages: Optional[_ErrorMessagesT] = ...,
) -> None: ...
@property
def description(self): ...
def get_transform(self, name: Any): ...
def description(self) -> str: ... # type: ignore
def get_transform(self, name: Any) -> Optional[Type[Transform]]: ...

View File

@@ -1,8 +1,7 @@
from typing import Any
from django.db.models import Field, Transform
from .mixins import CheckFieldDefaultMixin
from django.db.models.fields.mixins import CheckFieldDefaultMixin
class HStoreField(CheckFieldDefaultMixin, Field):
def get_transform(self, name) -> Any: ...

View File

@@ -1,32 +1,8 @@
from json import JSONEncoder
from typing import Any, Optional, Type
from django.db.models import JSONField as BuiltinJSONField
from django.db.models.fields.json import KeyTextTransform as BuiltinKeyTextTransform
from django.db.models.fields.json import KeyTransform as BuiltinKeyTransform
from django.db.models import Field
from django.db.models.lookups import Transform
from .mixins import CheckFieldDefaultMixin
class JsonAdapter:
encoder: Any = ...
def __init__(self, adapted: Any, dumps: Optional[Any] = ..., encoder: Optional[Any] = ...) -> None: ...
def dumps(self, obj: Any): ...
class JSONField(CheckFieldDefaultMixin, Field):
empty_strings_allowed: bool = ...
description: Any = ...
default_error_messages: Any = ...
encoder: Any = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
name: Optional[str] = ...,
encoder: Optional[Type[JSONEncoder]] = ...,
**kwargs: Any
) -> None: ...
class KeyTransform(Transform):
operator: str = ...
nested_operator: str = ...
def __init__(self, key_name: str, *args: Any, **kwargs: Any) -> None: ...
class KeyTextTransform(KeyTransform): ...
# All deprecated
class JSONField(BuiltinJSONField): ...
class KeyTransform(BuiltinKeyTransform): ...
class KeyTextTransform(BuiltinKeyTextTransform): ...

View File

@@ -1,4 +0,0 @@
from typing import Any, List
class CheckFieldDefaultMixin:
def check(self, **kwargs: Any) -> List[Any]: ...

View File

@@ -1,14 +1,38 @@
from typing import Any
import sys
from typing import Any, Dict, Optional, Type
from django.db import models
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange
from django.db.models.lookups import PostgresOperatorLookup
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange, Range
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
class RangeBoundary(models.Expression):
lower: str
upper: str
def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...): ...
class RangeOperators:
EQUAL: Literal["="]
NOT_EQUAL: Literal["<>"]
CONTAINS: Literal["@>"]
CONTAINED_BY: Literal["<@"]
OVERLAPS: Literal["&&"]
FULLY_LT: Literal["<<"]
FULLY_GT: Literal[">>"]
NOT_LT: Literal["&>"]
NOT_GT: Literal["&<"]
ADJACENT_TO: Literal["-|-"]
class RangeField(models.Field):
empty_strings_allowed: bool = ...
base_field: Any = ...
range_type: Any = ...
def get_prep_value(self, value: Any): ...
def to_python(self, value: Any): ...
base_field: models.Field = ...
range_type: Type[Range] = ...
def get_prep_value(self, value: Any) -> Optional[Any]: ...
def to_python(self, value: Any) -> Any: ...
class IntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
@@ -19,28 +43,74 @@ class BigIntegerRangeField(RangeField):
class DecimalRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class FloatRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class DateTimeRangeField(RangeField):
def __get__(self, instance, owner) -> DateTimeTZRange: ...
class DateRangeField(RangeField):
def __get__(self, instance, owner) -> DateRange: ...
class RangeOperators:
EQUAL: str
NOT_EQUAL: str
CONTAINS: str
CONTAINED_BY: str
OVERLAPS: str
FULLY_LT: str
FULLY_GT: str
NOT_LT: str
NOT_GT: str
ADJACENT_TO: str
class DateTimeRangeContains(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
class RangeBoundary(models.Expression):
lower: str
upper: str
def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...): ...
class RangeContainedBy(PostgresOperatorLookup):
lookup_name: str = ...
type_mapping: Dict[str, str] = ...
postgres_operator: str = ...
class FullyLessThan(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
class FullGreaterThan(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
class NotLessThan(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
class NotGreaterThan(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
class AdjacentToLookup(PostgresOperatorLookup):
lookup_name: str = ...
postgres_operator: str = ...
class RangeStartsWith(models.Transform):
lookup_name: str = ...
function: str = ...
@property
def output_field(self) -> models.Field: ...
class RangeEndsWith(models.Transform):
lookup_name: str = ...
function: str = ...
@property
def output_field(self) -> models.Field: ...
class IsEmpty(models.Transform):
lookup_name: str = ...
function: str = ...
output_field: models.BooleanField = ...
class LowerInclusive(models.Transform):
lookup_name: str = ...
function: str = ...
output_field: models.BooleanField = ...
class LowerInfinite(models.Transform):
lookup_name: str = ...
function: str = ...
output_field: models.BooleanField = ...
class UpperInclusive(models.Transform):
lookup_name: str = ...
function: str = ...
output_field: models.BooleanField = ...
class UpperInfinite(models.Transform):
lookup_name: str = ...
function: str = ...
output_field: models.BooleanField = ...

View File

@@ -0,0 +1,4 @@
from .array import *
from .hstore import *
from .jsonb import *
from .ranges import *

View File

@@ -0,0 +1,62 @@
from typing import Any, Dict, Optional, Sequence, Type, Union
from django import forms as forms
from django.contrib.postgres.validators import ArrayMaxLengthValidator as ArrayMaxLengthValidator
from django.contrib.postgres.validators import ArrayMinLengthValidator as ArrayMinLengthValidator
from django.core.exceptions import ValidationError as ValidationError
from django.db.models.fields import _ErrorMessagesT
from django.forms.fields import _ClassLevelWidgetT
from django.forms.utils import _DataT, _FilesT
from django.forms.widgets import Media, _OptAttrs
from ..utils import prefix_validation_error as prefix_validation_error
class SimpleArrayField(forms.CharField):
default_error_messages: _ErrorMessagesT = ...
base_field: Type[forms.Field]
delimiter: str
min_length: Optional[int]
max_length: Optional[int]
def __init__(
self,
base_field: Type[forms.Field],
*,
delimiter: str = ...,
max_length: Optional[int] = ...,
min_length: Optional[int] = ...,
**kwargs: Any
) -> None: ...
def clean(self, value: Any) -> Sequence[Any]: ...
def prepare_value(self, value: Any) -> Any: ...
def to_python(self, value: Any) -> Sequence[Any]: ... # type: ignore
def validate(self, value: Sequence[Any]) -> None: ...
def run_validators(self, value: Sequence[Any]) -> None: ...
def has_changed(self, initial: Any, data: Any) -> bool: ...
class SplitArrayWidget(forms.Widget):
template_name: str
widget: _ClassLevelWidgetT
size: int
def __init__(self, widget: Union[forms.Widget, Type[forms.Widget]], size: int, **kwargs: Any) -> None: ...
@property
def is_hidden(self) -> bool: ...
def value_from_datadict(self, data: _DataT, files: _FilesT, name: str) -> Any: ...
def value_omitted_from_data(self, data: _DataT, files: _FilesT, name: str) -> bool: ...
def id_for_label(self, id_: str) -> str: ...
def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs] = ...) -> Dict[str, Any]: ...
@property
def media(self) -> Media: ... # type: ignore
@property
def needs_multipart_form(self) -> bool: ... # type: ignore
class SplitArrayField(forms.Field):
default_error_messages: _ErrorMessagesT = ...
base_field: Type[forms.Field]
size: int
remove_trailing_nulls: bool
def __init__(
self, base_field: Type[forms.Field], size: int, *, remove_trailing_nulls: bool = ..., **kwargs: Any
) -> None: ...
def to_python(self, value: Any) -> Sequence[Any]: ...
def clean(self, value: Any) -> Sequence[Any]: ...
def has_changed(self, initial: Any, data: Any) -> bool: ...

View File

@@ -0,0 +1,12 @@
from typing import Any, Dict, Optional, Type, Union
from django import forms
from django.db.models.fields import _ErrorMessagesT
from django.forms.fields import _ClassLevelWidgetT
class HStoreField(forms.CharField):
widget: _ClassLevelWidgetT
default_error_messages: _ErrorMessagesT = ...
def prepare_value(self, value: Any) -> Any: ...
def to_python(self, value: Any) -> Dict[str, Optional[str]]: ... # type: ignore
def has_changed(self, initial: Any, data: Any) -> bool: ...

View File

@@ -0,0 +1,9 @@
from typing import Any
from django.forms import JSONField as BuiltinJSONField
# Deprecated, removed in 4.0
class JSONField(BuiltinJSONField):
def __init__(self, *args: Any, **kwargs: Any) -> None:
...

View File

@@ -0,0 +1,44 @@
from typing import Any, Optional, Tuple, Type, Union
from django import forms
from django.db.models.fields import _ErrorMessagesT
from django.forms.widgets import MultiWidget, _OptAttrs
from psycopg2.extras import Range
class RangeWidget(MultiWidget):
def __init__(
self, base_widget: Union[forms.Widget, Type[forms.Widget]], attrs: Optional[_OptAttrs] = ...
) -> None: ...
def decompress(self, value: Any) -> Tuple[Optional[Any], Optional[Any]]: ...
class HiddenRangeWidget(RangeWidget):
def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
class BaseRangeField(forms.MultiValueField):
default_error_messages: _ErrorMessagesT
base_field: Type[forms.Field]
range_type: Type[Range]
hidden_widget: Type[forms.Widget]
def __init__(self, **kwargs: Any) -> None: ...
def prepare_value(self, value: Any) -> Any: ...
def compress(self, values: Tuple[Optional[Any], Optional[Any]]) -> Optional[Range]: ...
class IntegerRangeField(BaseRangeField):
default_error_messages: _ErrorMessagesT
base_field: Type[forms.Field]
range_type: Type[Range]
class DecimalRangeField(BaseRangeField):
default_error_messages: _ErrorMessagesT
base_field: Type[forms.Field]
range_type: Type[Range]
class DateTimeRangeField(BaseRangeField):
default_error_messages: _ErrorMessagesT
base_field: Type[forms.Field]
range_type: Type[Range]
class DateRangeField(BaseRangeField):
default_error_messages: _ErrorMessagesT
base_field: Type[forms.Field]
range_type: Type[Range]

View File

@@ -1,10 +1,34 @@
from typing import Optional, Sequence, Union
from typing import Any, List, Optional, Sequence, Tuple, Type, Union
from django.db.models import Func, Index
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.ddl_references import Statement
from django.db.models import Func, Index, Model
from django.db.models.expressions import BaseExpression, Combinable
from django.db.models.query_utils import Q
from django.utils.datastructures import _ListOrTuple
class PostgresIndex(Index): ...
class PostgresIndex(Index):
@property
def max_name_length(self) -> int: ... # type: ignore
def create_sql(
self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ..., **kwargs: Any
) -> Statement: ...
def check_supported(self, schema_editor: BaseDatabaseSchemaEditor) -> None: ...
def get_with_params(self) -> Sequence[str]: ...
class BloomIndex(PostgresIndex):
def __init__(
self,
*expressions: Union[BaseExpression, Combinable, str],
length: Optional[int] = ...,
columns: _ListOrTuple[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...,
include: Optional[Sequence[str]] = ...,
) -> None: ...
class BrinIndex(PostgresIndex):
def __init__(

View File

@@ -1,18 +1,14 @@
from django.db.models import Lookup, Transform
from django.db.models.lookups import Exact
from django.db.models.lookups import Exact, PostgresOperatorLookup
from .search import SearchVectorExact
class PostgresSimpleLookup(Lookup):
operator: str
class DataContains(PostgresSimpleLookup): ...
class ContainedBy(PostgresSimpleLookup): ...
class Overlap(PostgresSimpleLookup): ...
class HasKey(PostgresSimpleLookup): ...
class HasKeys(PostgresSimpleLookup): ...
class DataContains(PostgresOperatorLookup): ...
class ContainedBy(PostgresOperatorLookup): ...
class Overlap(PostgresOperatorLookup): ...
class HasKey(PostgresOperatorLookup): ...
class HasKeys(PostgresOperatorLookup): ...
class HasAnyKeys(HasKeys): ...
class Unaccent(Transform): ...
class SearchLookup(SearchVectorExact): ...
class TrigramSimilar(PostgresSimpleLookup): ...
class JSONExact(Exact): ...
class TrigramSimilar(PostgresOperatorLookup): ...

View File

@@ -1,7 +1,7 @@
from typing import Any, Dict, Optional, TypeVar, Union
from django.db.models import Field
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value, _OutputField
from django.db.models import Expression, Field
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value
from django.db.models.lookups import Lookup
_Expression = Union[str, Combinable, "SearchQueryCombinable"]
@@ -10,17 +10,33 @@ class SearchVectorExact(Lookup): ...
class SearchVectorField(Field): ...
class SearchQueryField(Field): ...
class SearchConfig(Expression):
config: Optional[_Expression] = ...
def __init__(self, config: _Expression) -> None: ...
@classmethod
def from_parameter(cls, config: Optional[_Expression]) -> SearchConfig: ...
class SearchVectorCombinable:
ADD: str = ...
class SearchVector(SearchVectorCombinable, Func):
config: Optional[Any] = ...
def __init__(self, *expressions: _Expression, **extra: Any): ...
config: Optional[_Expression] = ...
function: str = ...
arg_joiner: str = ...
output_field: Field
def __init__(
self, *expressions: _Expression, config: Optional[_Expression] = ..., weight: Optional[Any] = ...
) -> None: ...
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
def __init__(
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
): ...
self,
lhs: Combinable,
connector: str,
rhs: Combinable,
config: Optional[_Expression],
output_field: Optional[Field] = None,
) -> None: ...
_T = TypeVar("_T", bound="SearchQueryCombinable")
@@ -32,31 +48,65 @@ class SearchQueryCombinable:
def __and__(self: _T, other: SearchQueryCombinable) -> _T: ...
def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ...
class SearchQuery(SearchQueryCombinable, Value): # type: ignore
class SearchQuery(SearchQueryCombinable, Func): # type: ignore
SEARCH_TYPES: Dict[str, str] = ...
def __init__(
self,
value: str,
output_field: Optional[_OutputField] = ...,
value: _Expression,
output_field: Optional[Field] = ...,
*,
config: Optional[_Expression] = ...,
invert: bool = ...,
search_type: str = ...
search_type: str = ...,
): ...
def __invert__(self: _T) -> _T: ...
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: ignore
def __init__(
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
self,
lhs: Combinable,
connector: str,
rhs: Combinable,
config: Optional[_Expression],
output_field: Optional[Field] = None,
) -> None: ...
class SearchRank(Func):
def __init__(
self, vector: Union[SearchVector, _Expression], query: Union[SearchQuery, _Expression], **extra: Any
self,
vector: Union[SearchVector, _Expression],
query: Union[SearchQuery, _Expression],
weights: Optional[Any] = ...,
normalization: Optional[Any] = ...,
cover_density: bool = ...,
) -> None: ...
class SearchHeadline(Func):
function: str = ...
template: str = ...
output_field: Field = ...
def __init__(
self,
expression: _Expression,
query: _Expression,
*,
config: Optional[_Expression] = ...,
start_sel: Optional[Any] = ...,
stop_sel: Optional[Any] = ...,
max_words: Optional[int] = ...,
min_words: Optional[int] = ...,
short_word: Optional[str] = ...,
highlight_all: Optional[bool] = ...,
max_fragments: Optional[int] = ...,
fragment_delimiter: Optional[str] = ...,
) -> None: ...
class TrigramBase(Func):
def __init__(self, expression: _Expression, string, **extra: Any) -> None: ...
def __init__(self, expression: _Expression, string: str, **extra: Any) -> None: ...
class TrigramSimilarity(TrigramBase): ...
class TrigramDistance(TrigramBase): ...
class TrigramSimilarity(TrigramBase):
function: str
class TrigramDistance(TrigramBase):
function: str
arg_joiner: str

View File

@@ -9,5 +9,6 @@ class SessionStore(SessionBase):
def __init__(self, session_key: Optional[str] = ...) -> None: ...
@classmethod
def get_model_class(cls) -> Type[Session]: ...
@property
def model(self) -> Type[AbstractBaseSession]: ...
def create_model_instance(self, data: Dict[str, Model]) -> AbstractBaseSession: ...

View File

@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Dict, List, Optional, Protocol, Union
from typing import Any, Dict, List, Optional, Sequence, Union
from django.contrib.sites.models import Site
from django.contrib.sites.requests import RequestSite
@@ -11,22 +11,17 @@ PING_URL: str
class SitemapNotFound(Exception): ...
def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None: ...
class _SupportsLen(Protocol):
def __len__(self) -> int: ...
class _SupportsCount(Protocol):
def count(self) -> int: ...
class _SupportsOrdered(Protocol):
ordered: bool = ...
def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ..., sitemap_uses_https: bool = ...) -> None: ...
class Sitemap:
limit: int = ...
protocol: Optional[str] = ...
def items(self) -> Union[_SupportsLen, _SupportsCount, _SupportsOrdered]: ...
def location(self, obj: Model) -> str: ...
i18n: bool = ...
languages: Optional[Sequence[str]] = ...
alternates: bool = ...
x_default: bool = ...
def items(self) -> Union[Sequence[Any], QuerySet[Any]]: ...
def location(self, item: Model) -> str: ...
@property
def paginator(self) -> Paginator: ...
def get_urls(
@@ -36,15 +31,15 @@ class Sitemap:
class GenericSitemap(Sitemap):
priority: Optional[float] = ...
changefreq: Optional[str] = ...
queryset: QuerySet = ...
date_field: None = ...
queryset: QuerySet[Model] = ...
date_field: Optional[str] = ...
protocol: Optional[str] = ...
def __init__(
self,
info_dict: Dict[str, Union[datetime, QuerySet, str]],
info_dict: Dict[str, Union[datetime, QuerySet[Model], str]],
priority: Optional[float] = ...,
changefreq: Optional[str] = ...,
protocol: Optional[str] = ...,
) -> None: ...
def lastmod(self, item: Model) -> Optional[datetime]: ...
default_app_config: str
def items(self) -> QuerySet[Model]: ...

View File

@@ -1,11 +1,12 @@
from collections import OrderedDict
from typing import Callable, Dict, Optional, Type, Union
from typing import Callable, Dict, Optional, Type, TypeVar, Union
from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.http.request import HttpRequest
from django.template.response import TemplateResponse
def x_robots_tag(func: Callable) -> Callable: ...
_C = TypeVar("_C", bound=Callable)
def x_robots_tag(func: _C) -> _C: ...
def index(
request: HttpRequest,
sitemaps: Dict[str, Union[Type[Sitemap], Sitemap]],
@@ -15,7 +16,7 @@ def index(
) -> TemplateResponse: ...
def sitemap(
request: HttpRequest,
sitemaps: Union[Dict[str, Type[Sitemap]], Dict[str, GenericSitemap], OrderedDict],
sitemaps: Dict[str, Union[Type[Sitemap], Sitemap]],
section: Optional[str] = ...,
template_name: str = ...,
content_type: str = ...,

View File

@@ -1,6 +1,6 @@
from typing import Any, List, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import Error
from django.core.checks.messages import CheckMessage
def check_finders(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
def check_finders(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...

View File

@@ -1,51 +1,74 @@
import os
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, Union, overload
import sys
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, Tuple, Type, overload
from django.core.checks.messages import CheckMessage
from django.core.files.storage import Storage
from typing_extensions import Literal
from django.core.files.storage import FileSystemStorage, Storage
from django.utils._os import _PathCompatible
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
_PathType = Union[str, bytes, os.PathLike]
searched_locations: Any
class BaseFinder:
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
@overload
def find(self, path: _PathType, all: Literal[True]) -> List[_PathType]: ...
def find(self, path: _PathCompatible, all: Literal[False] = False) -> Optional[_PathCompatible]: ... # type: ignore
@overload
def find(self, path: _PathType, all: Literal[False] = ...) -> Optional[_PathType]: ...
def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
def find(self, path: _PathCompatible, all: Literal[True] = ...) -> List[_PathCompatible]: ...
def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ...
class FileSystemFinder(BaseFinder):
locations: List[Tuple[str, _PathType]] = ...
storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def find_location(self, root: _PathType, path: _PathType, prefix: str = ...) -> Optional[_PathType]: ...
locations: List[Tuple[str, _PathCompatible]] = ...
storages: Dict[_PathCompatible, Any] = ...
def __init__(self, app_names: Sequence[str] = ..., *args: Any, **kwargs: Any) -> None: ...
def find_location(
self, root: _PathCompatible, path: str, prefix: Optional[str] = ...
) -> Optional[_PathCompatible]: ...
@overload
def find(self, path: _PathCompatible, all: Literal[False] = False) -> Optional[_PathCompatible]: ... # type: ignore
@overload
def find(self, path: _PathCompatible, all: Literal[True] = ...) -> List[_PathCompatible]: ...
def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ...
class AppDirectoriesFinder(BaseFinder):
storage_class: Type[Storage] = ...
storage_class: Type[FileSystemStorage] = ...
source_dir: str = ...
apps: List[str] = ...
storages: Mapping[str, Storage] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def find_in_app(self, app: str, path: _PathType) -> Optional[_PathType]: ...
storages: Dict[_PathCompatible, FileSystemStorage] = ...
def __init__(self, app_names: Optional[Iterable[str]] = ..., *args: Any, **kwargs: Any) -> None: ...
def find_in_app(self, app: str, path: _PathCompatible) -> Optional[_PathCompatible]: ...
@overload
def find(self, path: _PathCompatible, all: Literal[False] = False) -> Optional[_PathCompatible]: ... # type: ignore
@overload
def find(self, path: _PathCompatible, all: Literal[True] = ...) -> List[_PathCompatible]: ...
def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ...
class BaseStorageFinder(BaseFinder):
storage: Storage = ...
def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ...
@overload
def find(self, path: _PathCompatible, all: Literal[False] = False) -> Optional[_PathCompatible]: ... # type: ignore
@overload
def find(self, path: _PathCompatible, all: Literal[True] = ...) -> List[_PathCompatible]: ...
def list(self, ignore_patterns: Optional[Iterable[str]]) -> Iterable[Any]: ...
class DefaultStorageFinder(BaseStorageFinder): ...
class DefaultStorageFinder(BaseStorageFinder):
storage: Storage = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@overload
def find(path: str, all: Literal[True]) -> List[_PathType]: ...
def find(path: _PathCompatible, all: Literal[False] = False) -> Optional[_PathCompatible]: ... # type: ignore
@overload
def find(path: str, all: Literal[False] = ...) -> Optional[_PathType]: ...
def find(path: _PathCompatible, all: Literal[True] = ...) -> List[_PathCompatible]: ...
def get_finders() -> Iterator[BaseFinder]: ...
@overload
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
def get_finder(
import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"],
) -> FileSystemFinder: ...
@overload
def get_finder(
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"],
) -> AppDirectoriesFinder: ...
@overload
def get_finder(import_path: str) -> BaseFinder: ...

View File

@@ -1,12 +1,41 @@
from typing import Any
from typing import Any, Awaitable, Callable, Dict, Mapping, Sequence, Tuple
from urllib.parse import ParseResult
from django.core.handlers.asgi import ASGIHandler, ASGIRequest
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
from django.http import HttpRequest
from django.http.response import HttpResponseBase
class StaticFilesHandler(WSGIHandler):
class StaticFilesHandlerMixin:
handles_files: bool = ...
application: WSGIHandler = ...
base_url: Any = ...
def __init__(self, application: WSGIHandler) -> None: ...
application: BaseHandler
base_url: ParseResult
def load_middleware(self) -> None: ...
def get_base_url(self) -> str: ...
def _should_handle(self, path: str) -> bool: ...
def file_path(self, url: str) -> str: ...
def serve(self, request: WSGIRequest) -> Any: ...
def serve(self, request: HttpRequest) -> HttpResponseBase: ...
def get_response(self, request: HttpRequest) -> HttpResponseBase: ...
async def get_response_async(self, request: HttpRequest) -> HttpResponseBase: ...
class StaticFilesHandler(StaticFilesHandlerMixin, WSGIHandler): # type: ignore
application: WSGIHandler
base_url: ParseResult
def __init__(self, application: WSGIHandler) -> None: ...
def __call__(
self,
environ: Dict[str, Any],
start_response: Callable[[str, Sequence[Tuple[str, str]]], None],
) -> HttpResponseBase: ...
class ASGIStaticFilesHandler(StaticFilesHandlerMixin, ASGIHandler): # type: ignore
application: ASGIHandler
base_url: ParseResult
def __init__(self, application: ASGIHandler) -> None: ...
async def __call__(
self,
scope: Dict[str, Any],
receive: Callable[[], Awaitable[Mapping[str, Any]]],
send: Callable[[Mapping[str, Any]], Awaitable[None]],
) -> None: ...

View File

@@ -10,6 +10,7 @@ class Command(BaseCommand):
post_processed_files: Any = ...
storage: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@property
def local(self) -> bool: ...
interactive: Any = ...
verbosity: Any = ...

View File

@@ -1,29 +1,32 @@
from collections import OrderedDict
from typing import Any, Callable, Iterator, Optional, Tuple
from typing import Any, Callable, Dict, Iterator, Optional, Tuple, Union
from django.core.files.base import File
from django.core.files.storage import FileSystemStorage, Storage
from django.utils._os import _PathCompatible
from django.utils.functional import LazyObject
_PostProcessT = Iterator[Union[Tuple[str, str, bool], Tuple[str, None, RuntimeError]]]
class StaticFilesStorage(FileSystemStorage):
base_location: Any = ...
location: Any = ...
def __init__(self, location: Optional[str] = ..., base_url: None = ..., *args: Any, **kwargs: Any) -> None: ...
def path(self, name: str) -> str: ...
base_location: str
location: _PathCompatible
def __init__(
self, location: Optional[_PathCompatible] = ..., base_url: Optional[str] = ..., *args: Any, **kwargs: Any
) -> None: ...
def path(self, name: _PathCompatible) -> str: ...
class HashedFilesMixin:
default_template: str = ...
max_post_process_passes: int = ...
patterns: Any = ...
hashed_files: Any = ...
keep_intermediate_files: bool = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def file_hash(self, name: str, content: File = ...) -> str: ...
def hashed_name(self, name: str, content: Optional[File] = ..., filename: Optional[str] = ...) -> str: ...
def url(self, name: Optional[str], force: bool = ...) -> str: ...
def url_converter(self, name: str, hashed_files: OrderedDict, template: str = ...) -> Callable: ...
def post_process(
self, paths: OrderedDict, dry_run: bool = ..., **options: Any
) -> Iterator[Tuple[str, str, bool]]: ...
def url(self, name: str, force: bool = ...) -> str: ...
def url_converter(self, name: str, hashed_files: Dict[str, Any], template: str = ...) -> Callable: ...
def post_process(self, paths: Dict[str, Any], dry_run: bool = ..., **options: Any) -> _PostProcessT: ...
def clean_name(self, name: str) -> str: ...
def hash_key(self, name: str) -> str: ...
def stored_name(self, name: str) -> str: ...
@@ -32,25 +35,15 @@ class ManifestFilesMixin(HashedFilesMixin):
manifest_version: str = ...
manifest_name: str = ...
manifest_strict: bool = ...
keep_intermediate_files: bool = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def read_manifest(self) -> Any: ...
def load_manifest(self) -> OrderedDict: ...
def read_manifest(self) -> str: ...
def load_manifest(self) -> Dict[str, Any]: ...
def save_manifest(self) -> None: ...
def post_process(self, *args: Any, **kwargs: Any) -> _PostProcessT: ...
def stored_name(self, name: str) -> str: ...
class _MappingCache:
cache: Any = ...
def __init__(self, cache: Any) -> None: ...
def __setitem__(self, key: Any, value: Any) -> None: ...
def __getitem__(self, key: Any): ...
def clear(self) -> None: ...
def update(self, data: Any) -> None: ...
def get(self, key: Any, default: Optional[Any] = ...): ...
class CachedFilesMixin(HashedFilesMixin):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): ...
class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ...
class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ... # type: ignore
class ConfiguredStorage(LazyObject): ...
staticfiles_storage: Storage

View File

@@ -1,9 +0,0 @@
from typing import Any
from django.template.base import Parser, Token
from django.templatetags.static import StaticNode
register: Any
def static(path: str) -> str: ...
def do_static(parser: Parser, token: Token) -> StaticNode: ...

View File

@@ -1,8 +1,9 @@
from collections import OrderedDict
from typing import Iterator, List, Optional, Tuple, Union
from typing import Iterable, Iterator, Optional
from django.core.files.storage import FileSystemStorage
from django.core.files.storage import Storage
def matches_patterns(path: str, patterns: Union[List[str], Tuple[str], OrderedDict] = ...) -> bool: ...
def get_files(storage: FileSystemStorage, ignore_patterns: List[str] = ..., location: str = ...) -> Iterator[str]: ...
def matches_patterns(path: str, patterns: Iterable[str]) -> bool: ...
def get_files(
storage: Storage, ignore_patterns: Optional[Iterable[str]] = ..., location: str = ...
) -> Iterator[str]: ...
def check_settings(base_url: Optional[str] = ...) -> None: ...

View File

@@ -1,6 +1,6 @@
from typing import Any
from django.http.request import HttpRequest
from django.http.response import FileResponse
from django.http.response import HttpResponseBase
def serve(request: HttpRequest, path: str, insecure: bool = ..., **kwargs: Any) -> FileResponse: ...
def serve(request: HttpRequest, path: str, insecure: bool = ..., **kwargs: Any) -> HttpResponseBase: ...

View File

@@ -1,8 +1,8 @@
import datetime
from typing import Any, Callable, Dict, Generic, Iterable, Optional, Type, TypeVar, Union
from typing import Any, Dict, Generic, List, Optional, Type, TypeVar
from django.core.exceptions import ObjectDoesNotExist
from django.core.handlers.wsgi import WSGIRequest
from django.db.models import Model
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.utils.feedgenerator import Enclosure, SyndicationFeed
@@ -10,7 +10,7 @@ def add_domain(domain: str, url: str, secure: bool = ...) -> str: ...
class FeedDoesNotExist(ObjectDoesNotExist): ...
_Item = TypeVar("_Item")
_Item = TypeVar("_Item", bound=Model)
_Object = TypeVar("_Object")
class Feed(Generic[_Item, _Object]):
@@ -18,38 +18,40 @@ class Feed(Generic[_Item, _Object]):
title_template: Optional[str] = ...
description_template: Optional[str] = ...
language: Optional[str] = ...
title: Any = ...
link: Any = ...
feed_url: Any = ...
feed_guid: Any = ...
description: Any = ...
author_name: Any = ...
author_email: Any = ...
author_link: Any = ...
categories: Any = ...
feed_copyright: Any = ...
ttl: Any = ...
items: Any = ...
item_title: Any = ...
item_description: Any = ...
item_link: Any = ...
item_guid: Any = ...
item_guid_is_permalink: Any = ...
item_author_name: Any = ...
item_author_email: Any = ...
item_author_link: Any = ...
item_enclosures: Any = ...
item_enclosure_url: Any = ...
item_enclosure_length: Any = ...
item_enclosure_mime_type: Any = ...
item_pubdate: Any = ...
item_updateddate: Any = ...
item_categories: Any = ...
item_copyright: Any = ...
item_comments: Any = ...
def __call__(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_object(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> Optional[_Object]: ...
# Dynamic attributes:
title: Any
link: Any
feed_url: Any
feed_guid: Any
description: Any
author_name: Any
author_email: Any
author_link: Any
categories: Any
feed_copyright: Any
ttl: Any
items: Any
item_guid: Any
item_guid_is_permalink: Any
item_author_name: Any
item_author_email: Any
item_author_link: Any
item_enclosure_url: Any
item_enclosure_length: Any
item_enclosure_mime_type: Any
item_pubdate: Any
item_updateddate: Any
item_categories: Any
item_copyright: Any
item_comments: Any
def __call__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_object(self, request: HttpRequest, *args: Any, **kwargs: Any) -> Optional[_Object]: ...
def feed_extra_kwargs(self, obj: _Object) -> Dict[Any, Any]: ...
def item_extra_kwargs(self, item: _Item) -> Dict[Any, Any]: ...
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ...
def get_feed(self, obj: _Object, request: WSGIRequest) -> SyndicationFeed: ...
def get_feed(self, obj: _Object, request: HttpRequest) -> SyndicationFeed: ...
def item_title(self, item: _Item) -> str: ...
def item_description(self, item: _Item) -> str: ...
def item_link(self, item: _Item) -> str: ...
def item_enclosures(self, item: _Item) -> List[Enclosure]: ...

View File

@@ -1,5 +1,6 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, Union
from typing import Any, Type
from django.utils.connection import BaseConnectionHandler, ConnectionProxy
from .backends.base import BaseCache as BaseCache
from .backends.base import CacheKeyWarning as CacheKeyWarning
@@ -7,16 +8,13 @@ from .backends.base import InvalidCacheBackendError as InvalidCacheBackendError
DEFAULT_CACHE_ALIAS: str
class CacheHandler:
def __init__(self) -> None: ...
def __getitem__(self, alias: str) -> BaseCache: ...
def all(self): ...
class CacheHandler(BaseConnectionHandler):
settings_name: str = ...
exception_class: Type[Exception] = ...
def create_connection(self, alias: str) -> BaseCache: ...
def all(self, initialized_only: bool = ...): ...
class DefaultCacheProxy:
def __getattr__(self, name: str) -> Union[Callable, Dict[str, float], OrderedDict, int]: ...
def __setattr__(self, name: str, value: Callable) -> None: ...
def __delattr__(self, name: Any): ...
def __contains__(self, key: str) -> bool: ...
def close_caches(**kwargs: Any) -> None: ...
cache: Any
cache: ConnectionProxy
caches: CacheHandler

View File

@@ -1,8 +1,8 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage
from django.core.checks.messages import Error
E001: Any
E001: Error
def check_async_unsafe(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_async_unsafe(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...

View File

@@ -1,10 +1,14 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import Error
from django.core.checks.messages import Error, Warning
E001: Any
E001: Error
def check_default_cache_is_configured(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> List[Error]: ...
def check_default_cache_is_configured(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...
def check_cache_location_not_exposed(
app_configs: Optional[Sequence[AppConfig]], **kwargs: Any
) -> Sequence[Warning]: ...
def check_file_based_cache_is_absolute(
app_configs: Optional[Sequence[AppConfig]], **kwargs: Any
) -> Sequence[Warning]: ...

View File

@@ -1,3 +1,5 @@
from typing import Any, List
from typing import Any, Iterable, Optional, Sequence
def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ...
from django.core.checks import CheckMessage
def check_database_backends(databases: Optional[Iterable[str]] = ..., **kwargs: Any) -> Sequence[CheckMessage]: ...

View File

@@ -1,7 +1,9 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage, Warning
from django.core.checks.messages import CheckMessage
def check_all_models(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_lazy_references(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_all_models(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> Sequence[CheckMessage]: ...
def check_lazy_references(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> Sequence[CheckMessage]: ...

View File

@@ -1,8 +1,14 @@
from typing import Any, Callable, List, Optional, Set, Union
import sys
from typing import Any, Callable, List, Optional, Sequence, Set, TypeVar, Union
from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage
if sys.version_info < (3, 8):
from typing_extensions import Protocol
else:
from typing import Protocol
class Tags:
admin: str = ...
caches: str = ...
@@ -11,28 +17,38 @@ class Tags:
models: str = ...
security: str = ...
signals: str = ...
sites: str = ...
staticfiles: str = ...
templates: str = ...
translation: str = ...
urls: str = ...
_CheckCallable = Callable[..., List[CheckMessage]]
_CheckCallable = Callable[..., Sequence[CheckMessage]]
_C = TypeVar("_C", bound=_CheckCallable)
class _ProcessedCheckCallable(Protocol[_C]):
tags: Sequence[str]
__call__: _C
class CheckRegistry:
registered_checks: Set[Callable] = ...
deployment_checks: Set[Callable] = ...
registered_checks: Set[_ProcessedCheckCallable] = ...
deployment_checks: Set[_ProcessedCheckCallable] = ...
def __init__(self) -> None: ...
def register(self, check: Optional[Union[_CheckCallable, str]] = ..., *tags: str, **kwargs: Any) -> Callable: ...
def register(
self, check: Optional[Union[_CheckCallable, str]] = ..., *tags: str, **kwargs: Any
) -> Union[Callable[[_CheckCallable], _ProcessedCheckCallable], _ProcessedCheckCallable]: ...
def run_checks(
self,
app_configs: Optional[List[AppConfig]] = ...,
tags: Optional[List[str]] = ...,
app_configs: Optional[Sequence[AppConfig]] = ...,
tags: Optional[Sequence[str]] = ...,
include_deployment_checks: bool = ...,
databases: Optional[Any] = ...,
) -> List[CheckMessage]: ...
def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ...
def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ...
def get_checks(self, include_deployment_checks: bool = ...) -> List[Callable]: ...
def get_checks(self, include_deployment_checks: bool = ...) -> List[_ProcessedCheckCallable]: ...
registry: Any
register: Any
run_checks: Any
tag_exists: Any
registry: CheckRegistry = ...
register: Any = ...
run_checks: Any = ...
tag_exists: Any = ...

View File

@@ -1,34 +1,36 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import Warning
from django.core.checks.messages import CheckMessage, Error, Warning
SECRET_KEY_MIN_LENGTH: int
SECRET_KEY_MIN_UNIQUE_CHARACTERS: int
W001: Any
W002: Any
W004: Any
W005: Any
W006: Any
W007: Any
W008: Any
W009: Any
W018: Any
W019: Any
W020: Any
W021: Any
W001: Warning
W002: Warning
W004: Warning
W005: Warning
W006: Warning
W007: Warning
W008: Warning
W009: Warning
W018: Warning
W019: Warning
W020: Warning
W021: Warning
W022: Warning
E023: Error
E100: Error
def check_security_middleware(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_xframe_options_middleware(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> List[Warning]: ...
def check_sts(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_sts_include_subdomains(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_sts_preload(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_content_type_nosniff(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_xss_filter(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_ssl_redirect(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_secret_key(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_debug(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_xframe_deny(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_allowed_hosts(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_security_middleware(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_xframe_options_middleware(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_sts(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_sts_include_subdomains(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_sts_preload(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_content_type_nosniff(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_ssl_redirect(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_secret_key(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_debug(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_xframe_deny(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_allowed_hosts(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_referrer_policy(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[CheckMessage]: ...
def check_default_hashing_algorithm(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...

View File

@@ -1,10 +1,10 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import Warning
W003: Any
W016: Any
W003: Warning
W016: Warning
def check_csrf_middleware(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_csrf_cookie_secure(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_csrf_middleware(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_csrf_cookie_secure(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...

View File

@@ -1,19 +1,19 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import Warning
def add_session_cookie_message(message: Any): ...
def add_session_cookie_message(message: str) -> str: ...
W010: Any
W011: Any
W012: Any
W010: Warning
W011: Warning
W012: Warning
def add_httponly_message(message: Any): ...
def add_httponly_message(message: str) -> str: ...
W013: Any
W014: Any
W015: Any
W013: Warning
W014: Warning
W015: Warning
def check_session_cookie_secure(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_session_cookie_httponly(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_session_cookie_secure(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def check_session_cookie_httponly(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...

View File

@@ -1,12 +1,10 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from django.core.checks.messages import Error
E001: Any
E002: Any
E001: Error
E002: Error
def check_setting_app_dirs_loaders(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
def check_string_if_invalid_is_string(
app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any
) -> List[Error]: ...
def check_setting_app_dirs_loaders(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...
def check_string_if_invalid_is_string(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...

View File

@@ -1,9 +1,17 @@
from typing import Any, List, Optional, Sequence
from typing import Any, Optional, Sequence
from django.apps.config import AppConfig
from . import Error
E001: Error = ...
E002: Error = ...
E003: Error = ...
E004: Error = ...
def check_setting_language_code(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
def check_setting_language_code(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...
def check_setting_languages(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...
def check_setting_languages_bidi(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...
def check_language_settings_consistent(
app_configs: Optional[Sequence[AppConfig]], **kwargs: Any
) -> Sequence[Error]: ...

View File

@@ -1,12 +1,12 @@
from typing import Any, Callable, List, Optional, Sequence, Tuple, Union
from typing import Any, Optional, Sequence, Union
from django.apps.config import AppConfig
from django.core.checks.messages import CheckMessage, Error, Warning
from django.urls.resolvers import URLPattern, URLResolver
def check_url_config(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_resolver(resolver: Union[Tuple[str, Callable], URLPattern, URLResolver]) -> List[CheckMessage]: ...
def check_url_namespaces_unique(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def get_warning_for_invalid_pattern(pattern: Any) -> List[Error]: ...
def check_url_settings(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
def check_url_config(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[CheckMessage]: ...
def check_resolver(resolver: Union[URLPattern, URLResolver]) -> Sequence[CheckMessage]: ...
def check_url_namespaces_unique(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Warning]: ...
def get_warning_for_invalid_pattern(pattern: Any) -> Sequence[Error]: ...
def check_url_settings(app_configs: Optional[Sequence[AppConfig]], **kwargs: Any) -> Sequence[Error]: ...
def E006(name: str) -> Error: ...

View File

@@ -1,7 +1,12 @@
from typing import Any, Dict, Iterator, List, Mapping, Optional, Tuple, Union
import sys
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
from django.forms.utils import ErrorDict
from typing_extensions import Literal
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
class FieldDoesNotExist(Exception): ...
class AppRegistryNotReady(Exception): ...
@@ -25,27 +30,37 @@ class MiddlewareNotUsed(Exception): ...
class ImproperlyConfigured(Exception): ...
class FieldError(Exception): ...
NON_FIELD_ERRORS: Literal["__all__"]
NON_FIELD_ERRORS: Literal["__all__"] = ...
_MsgTypeBase = Union[str, ValidationError]
# Yeah, it's really ugly, but __init__ checks with isinstance()
_MsgType = Union[
_MsgTypeBase,
Dict[str, _MsgTypeBase],
List[_MsgTypeBase],
Dict[str, str],
Dict[str, ValidationError],
List[str],
List[ValidationError],
]
class ValidationError(Exception):
error_dict: Dict[str, ValidationError] = ...
error_list: List[ValidationError] = ...
message: str = ...
code: Optional[str] = ...
params: Optional[Mapping[str, Any]] = ...
params: Optional[Dict[str, Any]] = ...
def __init__(
self,
message: Union[str, ValidationError, Dict[str, Any], List[Any]],
message: _MsgType,
code: Optional[str] = ...,
params: Optional[Mapping[str, Any]] = ...,
params: Optional[Dict[str, Any]] = ...,
) -> None: ...
@property
def message_dict(self) -> Dict[str, List[str]]: ...
def message_dict(self) -> Optional[Dict[str, List[str]]]: ...
@property
def messages(self) -> List[str]: ...
def update_error_dict(
self, error_dict: Mapping[str, Any]
) -> Union[Dict[str, List[ValidationError]], ErrorDict]: ...
def update_error_dict(self, error_dict: Dict[str, List[ValidationError]]) -> Dict[str, List[ValidationError]]: ...
def __iter__(self) -> Iterator[Union[Tuple[str, List[str]], str]]: ...
class EmptyResultSet(Exception): ...

View File

@@ -1,41 +1,48 @@
import os
import types
from io import StringIO
from typing import IO, Any, Iterator, Optional, Type, TypeVar, Union
from typing import IO, AnyStr, Iterator, Optional, Type, TypeVar, Union, type_check_only
from django.core.files.utils import FileProxyMixin
_T = TypeVar("_T", bound="File")
class File(FileProxyMixin, IO[Any]):
DEFAULT_CHUNK_SIZE: Any = ...
file: IO[Any] = ...
name: str = ...
class File(FileProxyMixin[AnyStr], IO[AnyStr]):
DEFAULT_CHUNK_SIZE: int = ...
file: Optional[IO[AnyStr]] = ...
name: Optional[str] = ... # type: ignore[assignment]
mode: str = ...
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
def __init__(self, file: Optional[IO[AnyStr]], name: Optional[str] = ...) -> None: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
@property
def size(self) -> int: ...
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
def __iter__(self) -> Iterator[Union[bytes, str]]: ...
def __next__(self) -> Union[bytes, str]: ...
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[AnyStr]: ...
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> Optional[bool]: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
tb: Optional[types.TracebackType],
) -> bool: ...
) -> None: ...
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
def close(self) -> None: ...
@type_check_only
def __next__(self) -> AnyStr: ...
class ContentFile(File):
file: StringIO
size: Any = ...
def __init__(self, content: Union[bytes, str], name: Optional[str] = ...) -> None: ...
def write(self, data: str) -> int: ...
class ContentFile(File[AnyStr]):
file: IO[AnyStr]
size: int = ...
def __init__(self, content: AnyStr, name: Optional[str] = ...) -> None: ...
def __str__(self) -> str: ...
def __bool__(self) -> bool: ...
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
def close(self) -> None: ...
def write(self, data: AnyStr) -> int: ...
def endswith_cr(line: bytes) -> bool: ...
def endswith_cr(line: Union[bytes, str]) -> bool: ...
def endswith_lf(line: Union[bytes, str]) -> bool: ...
def equals_lf(line: bytes) -> bool: ...
def equals_lf(line: Union[bytes, str]) -> bool: ...

Some files were not shown because too many files have changed in this diff Show More