diff --git a/django/apps/config.pyi b/django/apps/config.pyi index 0434123..f94d2a2 100644 --- a/django/apps/config.pyi +++ b/django/apps/config.pyi @@ -1,6 +1,8 @@ +from django.db.models.base import Model from typing import ( Any, Iterator, + Type, ) @@ -9,7 +11,11 @@ class AppConfig: def _path_from_module(self, module: Any) -> str: ... @classmethod def create(cls, entry: str) -> AppConfig: ... - def get_model(self, model_name: str, require_ready: bool = ...) -> Any: ... - def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> Iterator[Any]: ... + def get_model(self, model_name: str, require_ready: bool = ...) -> Type[Model]: ... + def get_models( + self, + include_auto_created: bool = ..., + include_swapped: bool = ... + ) -> Iterator[Type[Model]]: ... def import_models(self) -> None: ... def ready(self) -> None: ... \ No newline at end of file diff --git a/django/apps/registry.pyi b/django/apps/registry.pyi index b545ff8..042f1a3 100644 --- a/django/apps/registry.pyi +++ b/django/apps/registry.pyi @@ -1,10 +1,11 @@ from django.apps.config import AppConfig from django.db.migrations.state import AppConfigStub +from django.db.models.base import Model from typing import ( - Any, List, Optional, Tuple, + Type, Union, ) @@ -12,12 +13,17 @@ from typing import ( class Apps: def __init__( self, - installed_apps: Union[Tuple, List[AppConfigStub], List[str]] = ... + installed_apps: Union[Tuple, List[str], List[AppConfigStub]] = ... ) -> None: ... def check_apps_ready(self) -> None: ... def check_models_ready(self) -> None: ... def clear_cache(self) -> None: ... - def do_pending_operations(self, model: Any) -> None: ... + def do_pending_operations(self, model: Type[Model]) -> None: ... def get_app_config(self, app_label: str) -> AppConfig: ... def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ... - def get_model(self, app_label: str, model_name: None = ..., require_ready: bool = ...) -> Any: ... \ No newline at end of file + def get_model( + self, + app_label: str, + model_name: None = ..., + require_ready: bool = ... + ) -> Type[Model]: ... \ No newline at end of file diff --git a/django/conf/urls/__init__.pyi b/django/conf/urls/__init__.pyi index 9b33458..b761535 100644 --- a/django/conf/urls/__init__.pyi +++ b/django/conf/urls/__init__.pyi @@ -14,4 +14,4 @@ def url( view: Any, kwargs: Any = ..., name: Optional[str] = ... -) -> Union[URLResolver, URLPattern]: ... \ No newline at end of file +) -> Union[URLPattern, URLResolver]: ... \ No newline at end of file diff --git a/django/conf/urls/i18n.pyi b/django/conf/urls/i18n.pyi index cab06b7..caebeed 100644 --- a/django/conf/urls/i18n.pyi +++ b/django/conf/urls/i18n.pyi @@ -10,7 +10,7 @@ from typing import ( def i18n_patterns( *urls, prefix_default_language = ... -) -> Union[List[List[Any]], List[URLResolver]]: ... +) -> Union[List[URLResolver], List[List[Any]]]: ... def is_language_prefix_patterns_used(urlconf: str) -> Tuple[bool, bool]: ... \ No newline at end of file diff --git a/django/contrib/admin/checks.pyi b/django/contrib/admin/checks.pyi index 2d81ba0..d9a65e7 100644 --- a/django/contrib/admin/checks.pyi +++ b/django/contrib/admin/checks.pyi @@ -1,5 +1,4 @@ from django.contrib.admin.options import ( - BaseModelAdmin, InlineModelAdmin, ModelAdmin, TabularInline, @@ -20,7 +19,10 @@ from typing import ( class BaseModelAdminChecks: - def _check_autocomplete_fields(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_autocomplete_fields( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_autocomplete_fields_item( self, obj: Union[ModelAdmin, InlineModelAdmin], @@ -28,32 +30,44 @@ class BaseModelAdminChecks: field_name: str, label: str ) -> List[Any]: ... - def _check_exclude(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_exclude( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_field_spec( self, - obj: BaseModelAdmin, - model: Any, + obj: Union[ModelAdmin, InlineModelAdmin], + model: Type[Model], fields: Union[str, Tuple[str, str, str, str], Tuple[str, str]], label: str ) -> List[Any]: ... def _check_field_spec_item( self, - obj: BaseModelAdmin, - model: Any, + obj: Union[ModelAdmin, TabularInline], + model: Type[Model], field_name: str, label: str ) -> List[Any]: ... - def _check_fields(self, obj: BaseModelAdmin) -> List[Any]: ... - def _check_fieldsets(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_fields( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... + def _check_fieldsets( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_fieldsets_item( self, - obj: BaseModelAdmin, - model: Any, + obj: Union[ModelAdmin, InlineModelAdmin], + model: Type[Model], fieldset: Any, label: str, seen_fields: List[str] ) -> List[Any]: ... - def _check_filter_horizontal(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_filter_horizontal( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_filter_item( self, obj: ModelAdmin, @@ -61,17 +75,29 @@ class BaseModelAdminChecks: field_name: str, label: str ) -> List[Any]: ... - def _check_filter_vertical(self, obj: BaseModelAdmin) -> List[Any]: ... - def _check_form(self, obj: BaseModelAdmin) -> List[Any]: ... - def _check_ordering(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_filter_vertical( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... + def _check_form( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... + def _check_ordering( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_ordering_item( self, obj: ModelAdmin, - model: Any, + model: Type[Model], field_name: str, label: str ) -> List[Any]: ... - def _check_prepopulated_fields(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_prepopulated_fields( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_prepopulated_fields_key( self, obj: Union[ModelAdmin, InlineModelAdmin], @@ -81,9 +107,9 @@ class BaseModelAdminChecks: ) -> List[Any]: ... def _check_prepopulated_fields_value( self, - obj: BaseModelAdmin, + obj: Union[ModelAdmin, InlineModelAdmin], model: Type[Model], - val: Union[Tuple[str], List[str]], + val: Union[List[str], Tuple[str]], label: str ) -> List[Any]: ... def _check_prepopulated_fields_value_item( @@ -93,8 +119,14 @@ class BaseModelAdminChecks: field_name: str, label: str ) -> List[Any]: ... - def _check_radio_fields(self, obj: BaseModelAdmin) -> List[Any]: ... - def _check_raw_id_fields(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_radio_fields( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... + def _check_raw_id_fields( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_raw_id_fields_item( self, obj: ModelAdmin, @@ -102,18 +134,24 @@ class BaseModelAdminChecks: field_name: str, label: str ) -> List[Any]: ... - def _check_readonly_fields(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_readonly_fields( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def _check_readonly_fields_item( self, - obj: BaseModelAdmin, - model: Any, + obj: Union[ModelAdmin, TabularInline], + model: Type[Model], field_name: str, label: str ) -> List[Any]: ... - def _check_view_on_site_url(self, obj: BaseModelAdmin) -> List[Any]: ... + def _check_view_on_site_url( + self, + obj: Union[ModelAdmin, InlineModelAdmin] + ) -> List[Any]: ... def check( self, - admin_obj: BaseModelAdmin, + admin_obj: Union[ModelAdmin, InlineModelAdmin], **kwargs ) -> List[Error]: ... @@ -122,11 +160,15 @@ class InlineModelAdminChecks: def _check_exclude_of_parent_model( self, obj: InlineModelAdmin, - parent_model: Any + parent_model: Type[Model] ) -> List[Any]: ... def _check_extra(self, obj: InlineModelAdmin) -> List[Any]: ... def _check_formset(self, obj: InlineModelAdmin) -> List[Any]: ... def _check_has_add_permission(self, obj: InlineModelAdmin) -> None: ... def _check_max_num(self, obj: InlineModelAdmin) -> List[Any]: ... def _check_min_num(self, obj: InlineModelAdmin) -> List[Any]: ... - def _check_relation(self, obj: InlineModelAdmin, parent_model: Any) -> List[Any]: ... \ No newline at end of file + def _check_relation( + self, + obj: InlineModelAdmin, + parent_model: Type[Model] + ) -> List[Any]: ... \ No newline at end of file diff --git a/django/contrib/admin/filters.pyi b/django/contrib/admin/filters.pyi index 90ec1c4..7f681a8 100644 --- a/django/contrib/admin/filters.pyi +++ b/django/contrib/admin/filters.pyi @@ -13,7 +13,6 @@ from django.db.models.fields.related import ( from django.db.models.fields.reverse_related import ForeignObjectRel from django.db.models.query import QuerySet from typing import ( - Any, Callable, Dict, List, @@ -79,20 +78,20 @@ class DateFieldListFilter: class FieldListFilter: def __init__( self, - field: Any, + field: Union[ForeignObjectRel, Field], request: WSGIRequest, params: Dict[str, str], - model: Any, + model: Type[Model], model_admin: ModelAdmin, field_path: str ) -> None: ... @classmethod def create( cls, - field: Any, + field: Union[ForeignObjectRel, Field], request: WSGIRequest, params: Dict[str, str], - model: Any, + model: Type[Model], model_admin: ModelAdmin, field_path: str ) -> FieldListFilter: ... @@ -103,7 +102,12 @@ class FieldListFilter: queryset: QuerySet ) -> QuerySet: ... @classmethod - def register(cls, test: Callable, list_filter_class: Any, take_priority: bool = ...) -> None: ... + def register( + cls, + test: Callable, + list_filter_class: Type[FieldListFilter], + take_priority: bool = ... + ) -> None: ... class ListFilter: @@ -111,7 +115,7 @@ class ListFilter: self, request: WSGIRequest, params: Dict[str, str], - model: Any, + model: Type[Model], model_admin: ModelAdmin ) -> None: ... @@ -122,7 +126,7 @@ class RelatedFieldListFilter: field: Union[ForeignObjectRel, ManyToManyField, ForeignKey], request: WSGIRequest, params: Dict[str, str], - model: Any, + model: Type[Model], model_admin: ModelAdmin, field_path: str ) -> None: ... @@ -144,7 +148,7 @@ class RelatedOnlyFieldListFilter: field: Union[ManyToManyField, ForeignKey], request: WSGIRequest, model_admin: ModelAdmin - ) -> Union[List[Tuple[int, str]], List[Tuple[str, str]]]: ... + ) -> Union[List[Tuple[str, str]], List[Tuple[int, str]]]: ... class SimpleListFilter: diff --git a/django/contrib/admin/options.pyi b/django/contrib/admin/options.pyi index f03e484..5c6a337 100644 --- a/django/contrib/admin/options.pyi +++ b/django/contrib/admin/options.pyi @@ -1,12 +1,16 @@ from django.core.checks.messages import Error 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 ( ForeignKey, ManyToManyField, ) from django.db.models.query import QuerySet -from django.forms.fields import TypedChoiceField +from django.forms.fields import ( + Field, + TypedChoiceField, +) from django.forms.models import ( ModelChoiceField, ModelMultipleChoiceField, @@ -32,7 +36,12 @@ class BaseModelAdmin: request: object, **kwargs ) -> TypedChoiceField: ... - def formfield_for_dbfield(self, db_field: Field, request: object, **kwargs) -> Any: ... + def formfield_for_dbfield( + self, + db_field: Field, + request: object, + **kwargs + ) -> Optional[Field]: ... def formfield_for_foreignkey( self, db_field: ForeignKey, @@ -47,27 +56,43 @@ class BaseModelAdmin: ) -> ModelMultipleChoiceField: ... def get_autocomplete_fields(self, request: object) -> Tuple: ... def get_empty_value_display(self) -> SafeText: ... - def get_exclude(self, request: object, obj: Any = ...) -> None: ... + def get_exclude(self, request: object, obj: Optional[Model] = ...) -> None: ... def get_field_queryset( self, db: None, db_field: Union[ManyToManyField, ForeignKey], request: object ) -> Optional[QuerySet]: ... - def get_fields(self, request: object, obj: Any = ...) -> Union[List[Union[str, Callable]], List[str]]: ... - def get_fieldsets(self, request: WSGIRequest, obj: Any = ...) -> Any: ... + def get_fields( + self, + request: object, + obj: Optional[Model] = ... + ) -> Union[List[str], List[Union[str, Callable]]]: ... + def get_fieldsets( + self, + request: WSGIRequest, + obj: Optional[Model] = ... + ) -> Any: ... def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ... def get_prepopulated_fields( self, request: WSGIRequest, - obj: Any = ... + obj: Optional[Model] = ... ) -> Dict[str, Tuple[str]]: ... def get_queryset(self, request: object) -> QuerySet: ... - def get_readonly_fields(self, request: object, obj: Any = ...) -> Union[Tuple, List[str]]: ... - def get_sortable_by(self, request: WSGIRequest) -> Union[Tuple, List[str]]: ... - def get_view_on_site_url(self, obj: Any = ...) -> Optional[str]: ... + def get_readonly_fields( + self, + request: object, + obj: Optional[Model] = ... + ) -> Union[List[str], Tuple]: ... + def get_sortable_by(self, request: WSGIRequest) -> Union[List[str], Tuple]: ... + def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ... def has_add_permission(self, request: WSGIRequest) -> bool: ... - def has_change_permission(self, request: object, obj: Any = ...) -> bool: ... - def has_delete_permission(self, request: object, obj: Any = ...) -> bool: ... + def has_change_permission(self, request: object, obj: Optional[Model] = ...) -> bool: ... + def has_delete_permission(self, request: object, obj: Optional[Model] = ...) -> bool: ... def has_module_permission(self, request: object) -> bool: ... - def has_view_permission(self, request: WSGIRequest, obj: Any = ...) -> bool: ... \ No newline at end of file + def has_view_permission( + self, + request: WSGIRequest, + obj: Optional[Model] = ... + ) -> bool: ... \ No newline at end of file diff --git a/django/contrib/admin/sites.pyi b/django/contrib/admin/sites.pyi index 1b139a3..082730c 100644 --- a/django/contrib/admin/sites.pyi +++ b/django/contrib/admin/sites.pyi @@ -1,4 +1,5 @@ from django.core.handlers.wsgi import WSGIRequest +from django.db.models.base import Model from django.http.response import ( HttpResponse, HttpResponseRedirect, @@ -14,6 +15,7 @@ from typing import ( Dict, List, Tuple, + Type, Union, ) @@ -44,12 +46,12 @@ class AdminSite: request: WSGIRequest, extra_context: None = ... ) -> TemplateResponse: ... - def is_registered(self, model: Any) -> bool: ... + def is_registered(self, model: Type[Model]) -> bool: ... def login( self, request: WSGIRequest, extra_context: None = ... - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def logout( self, request: WSGIRequest, @@ -66,11 +68,11 @@ class AdminSite: extra_context: None = ... ) -> TemplateResponse: ... def register(self, model_or_iterable: Any, admin_class: Any = ..., **options) -> None: ... - def unregister(self, model_or_iterable: Any) -> None: ... + def unregister(self, model_or_iterable: Type[Model]) -> None: ... @property def urls( self - ) -> Union[Tuple[List[Union[URLPattern, URLResolver]], str, str], Tuple[List[URLPattern], str, str]]: ... + ) -> Union[Tuple[List[URLPattern], str, str], Tuple[List[Union[URLPattern, URLResolver]], str, str]]: ... class DefaultAdminSite: diff --git a/django/contrib/admin/templatetags/admin_list.pyi b/django/contrib/admin/templatetags/admin_list.pyi index 85d371e..4233bb1 100644 --- a/django/contrib/admin/templatetags/admin_list.pyi +++ b/django/contrib/admin/templatetags/admin_list.pyi @@ -74,7 +74,7 @@ def pagination_tag( def paginator_number(cl: ChangeList, i: int) -> SafeText: ... -def result_headers(cl: ChangeList) -> Iterator[Dict[str, Union[None, int, str]]]: ... +def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ... def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ... diff --git a/django/contrib/admin/templatetags/admin_urls.pyi b/django/contrib/admin/templatetags/admin_urls.pyi index 959c7d6..220bfe8 100644 --- a/django/contrib/admin/templatetags/admin_urls.pyi +++ b/django/contrib/admin/templatetags/admin_urls.pyi @@ -20,4 +20,4 @@ def add_preserved_filters( def admin_urlname(value: Options, arg: SafeText) -> str: ... -def admin_urlquote(value: Union[str, UUID, int]) -> Union[str, UUID, int]: ... \ No newline at end of file +def admin_urlquote(value: Union[str, int, UUID]) -> Union[str, int, UUID]: ... \ No newline at end of file diff --git a/django/contrib/admin/utils.pyi b/django/contrib/admin/utils.pyi index d667889..e323be7 100644 --- a/django/contrib/admin/utils.pyi +++ b/django/contrib/admin/utils.pyi @@ -4,8 +4,15 @@ from django.contrib.admin.options import ( TabularInline, ) from django.contrib.auth.forms import AdminPasswordChangeForm +from django.contrib.auth.models import User from django.db.models.base import Model -from django.db.models.fields.reverse_related import ManyToOneRel +from django.db.models.fields import Field +from django.db.models.fields.reverse_related import ( + ForeignObjectRel, + ManyToManyRel, + ManyToOneRel, + OneToOneRel, +) from django.db.models.options import Options from django.db.models.query import QuerySet from typing import ( @@ -14,6 +21,7 @@ from typing import ( Dict, List, Optional, + Set, Tuple, Type, Union, @@ -21,7 +29,10 @@ from typing import ( from uuid import UUID -def _get_non_gfk_field(opts: Options, name: Union[str, Callable]) -> Any: ... +def _get_non_gfk_field( + opts: Options, + name: Union[str, Callable] +) -> Union[Field, reverse_related.ManyToManyRel, reverse_related.OneToOneRel]: ... def construct_change_message( @@ -31,7 +42,11 @@ def construct_change_message( ) -> List[Dict[str, Dict[str, List[str]]]]: ... -def display_for_field(value: Any, field: Any, empty_value_display: str) -> str: ... +def display_for_field( + value: Any, + field: Union[Field, reverse_related.OneToOneRel], + empty_value_display: str +) -> str: ... def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ... @@ -40,21 +55,23 @@ def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) def flatten(fields: Union[Tuple, List[Union[str, Callable]], List[str]]) -> Union[List[Union[str, Callable]], List[str]]: ... -def flatten_fieldsets(fieldsets: Any) -> Union[List[Union[str, Callable]], List[str]]: ... +def flatten_fieldsets(fieldsets: Any) -> Union[List[str], List[Union[str, Callable]]]: ... -def get_fields_from_path(model: Any, path: str) -> Any: ... +def get_fields_from_path(model: Type[Model], path: str) -> Any: ... -def get_model_from_relation(field: Any) -> Any: ... +def get_model_from_relation( + field: Union[ForeignObjectRel, Field] +) -> Type[Model]: ... -def help_text_for_field(name: str, model: Any) -> str: ... +def help_text_for_field(name: str, model: Type[Model]) -> str: ... def label_for_field( name: Union[str, Callable], - model: Any, + model: Type[Model], model_admin: Optional[Union[ModelAdmin, TabularInline]] = ..., return_attr: bool = ... ) -> Any: ... @@ -79,7 +96,10 @@ def prepare_lookup_value(key: str, value: Union[str, datetime]) -> Union[bool, d def quote(s: Union[str, UUID, int]) -> Union[str, UUID, int]: ... -def reverse_field_path(model: Type[Model], path: str) -> Any: ... +def reverse_field_path( + model: Type[Model], + path: str +) -> Union[Tuple[Type[Model], str], Tuple[Type[User], str]]: ... def unquote(s: str) -> str: ... @@ -87,13 +107,24 @@ def unquote(s: str) -> str: ... class NestedObjects: def __init__(self, *args, **kwargs) -> None: ... - def _nested(self, obj: Model, seen: Any, format_callback: Callable) -> Any: ... - def add_edge(self, source: Any, target: Model) -> None: ... + def _nested( + self, + obj: Model, + seen: Set[Model], + format_callback: Callable + ) -> Any: ... + def add_edge(self, source: Optional[Model], target: Model) -> None: ... def can_fast_delete(self, *args, **kwargs) -> bool: ... - def collect(self, objs: Any, source: Any = ..., source_attr: Optional[str] = ..., **kwargs) -> None: ... + def collect( + self, + objs: Union[List[Model], QuerySet], + source: Optional[Type[Model]] = ..., + source_attr: Optional[str] = ..., + **kwargs + ) -> None: ... def nested(self, format_callback: Callable = ...) -> Any: ... def related_objects( self, related: ManyToOneRel, - objs: Any + objs: Union[List[User], List[Model]] ) -> QuerySet: ... \ No newline at end of file diff --git a/django/contrib/admin/views/main.pyi b/django/contrib/admin/views/main.pyi index d3c4a48..2ef5cc5 100644 --- a/django/contrib/admin/views/main.pyi +++ b/django/contrib/admin/views/main.pyi @@ -21,10 +21,10 @@ class ChangeList: def __init__( self, request: WSGIRequest, - model: Any, - list_display: Union[Tuple[str, str, str, str], List[Union[str, Callable]], List[str]], - list_display_links: Union[Tuple[str, str], List[str]], - list_filter: Union[List[Type[SimpleListFilter]], Tuple, List[str]], + model: Type[Model], + list_display: Union[List[str], List[Union[str, Callable]], Tuple[str, str, str, str]], + list_display_links: Union[List[str], Tuple[str, str]], + list_filter: Union[List[Type[SimpleListFilter]], List[str], Tuple], date_hierarchy: Optional[str], search_fields: Union[List[str], Tuple], list_select_related: bool, diff --git a/django/contrib/admin/widgets.pyi b/django/contrib/admin/widgets.pyi index 0998b7f..1bb4807 100644 --- a/django/contrib/admin/widgets.pyi +++ b/django/contrib/admin/widgets.pyi @@ -45,7 +45,7 @@ class AdminSplitDateTime: name: str, value: Optional[datetime], attrs: Dict[str, Union[bool, str]] - ) -> Dict[str, Any]: ... + ) -> Dict[str, Union[Dict[str, Any], str, Dict[str, Union[str, bool, Dict[str, Union[bool, str]], List[Dict[str, Union[str, bool, Dict[str, Union[bool, str]]]]]]], Dict[str, Union[str, bool, Dict[str, str], List[Dict[str, Union[str, bool, Dict[str, str]]]]]]]]: ... class AdminTextInputWidget: diff --git a/django/contrib/auth/__init__.pyi b/django/contrib/auth/__init__.pyi index 627f1bb..aa85a5f 100644 --- a/django/contrib/auth/__init__.pyi +++ b/django/contrib/auth/__init__.pyi @@ -9,7 +9,6 @@ from django.db.models.base import Model from django.db.models.options import Options from django.http.request import HttpRequest from django.utils.functional import SimpleLazyObject -from test_client.auth_backends import BackendWithoutGetUserMethod from typing import ( Any, Dict, @@ -20,7 +19,7 @@ from typing import ( ) -def _clean_credentials(credentials: Dict[str, Union[str, None]]) -> Dict[str, Union[str, None]]: ... +def _clean_credentials(credentials: Dict[str, Optional[str]]) -> Dict[str, Optional[str]]: ... def _get_backends(return_tuples: bool = ...) -> Any: ... @@ -49,9 +48,7 @@ def get_user( def get_user_model() -> Type[Model]: ... -def load_backend( - path: str -) -> Union[ModelBackend, BackendWithoutGetUserMethod]: ... +def load_backend(path: str) -> object: ... def login( diff --git a/django/contrib/auth/admin.pyi b/django/contrib/auth/admin.pyi index bf4af0a..2d097ea 100644 --- a/django/contrib/auth/admin.pyi +++ b/django/contrib/auth/admin.pyi @@ -28,7 +28,7 @@ class UserAdmin: request: WSGIRequest, form_url: str = ..., extra_context: None = ... - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def add_view( self, request: WSGIRequest, @@ -53,4 +53,4 @@ class UserAdmin: request: WSGIRequest, id: str, form_url: str = ... - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... \ No newline at end of file + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... \ No newline at end of file diff --git a/django/contrib/auth/context_processors.pyi b/django/contrib/auth/context_processors.pyi index 5885600..ae194ec 100644 --- a/django/contrib/auth/context_processors.pyi +++ b/django/contrib/auth/context_processors.pyi @@ -1,4 +1,3 @@ -from auth_tests.test_context_processors import MockUser from django.contrib.auth.models import ( AnonymousUser, User, @@ -12,20 +11,17 @@ from typing import ( def auth( request: HttpRequest -) -> Dict[str, Union[AnonymousUser, PermWrapper, User]]: ... +) -> Dict[str, Union[PermWrapper, AnonymousUser, User]]: ... class PermLookupDict: def __bool__(self) -> bool: ... def __getitem__(self, perm_name: str) -> bool: ... - def __init__(self, user: MockUser, app_label: str) -> None: ... + def __init__(self, user: object, app_label: str) -> None: ... class PermWrapper: def __contains__(self, perm_name: str) -> bool: ... def __getitem__(self, app_label: str) -> PermLookupDict: ... - def __init__( - self, - user: Union[MockUser, AnonymousUser, User] - ) -> None: ... + def __init__(self, user: object) -> None: ... def __iter__(self): ... \ No newline at end of file diff --git a/django/contrib/auth/hashers.pyi b/django/contrib/auth/hashers.pyi index 9e319e5..a51e689 100644 --- a/django/contrib/auth/hashers.pyi +++ b/django/contrib/auth/hashers.pyi @@ -20,7 +20,7 @@ def get_hasher(algorithm: str = ...) -> BasePasswordHasher: ... def get_hashers( -) -> Union[List[MD5PasswordHasher], List[BasePasswordHasher], List[PBKDF2PasswordHasher], List[UnsaltedMD5PasswordHasher]]: ... +) -> Union[List[UnsaltedMD5PasswordHasher], List[MD5PasswordHasher], List[BasePasswordHasher], List[PBKDF2PasswordHasher]]: ... def get_hashers_by_algorithm() -> Dict[str, BasePasswordHasher]: ... diff --git a/django/contrib/auth/models.pyi b/django/contrib/auth/models.pyi index 233f2ad..17674d0 100644 --- a/django/contrib/auth/models.pyi +++ b/django/contrib/auth/models.pyi @@ -42,7 +42,7 @@ class AnonymousUser: def get_username(self) -> str: ... def has_module_perms(self, module: str) -> bool: ... def has_perm(self, perm: str, obj: None = ...) -> bool: ... - def has_perms(self, perm_list: Union[Tuple[str], List[str]], obj: None = ...) -> bool: ... + def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ... @property def is_anonymous(self) -> bool: ... @property @@ -71,7 +71,7 @@ class PermissionsMixin: def get_all_permissions(self, obj: None = ...) -> Set[str]: ... def has_module_perms(self, app_label: str) -> bool: ... def has_perm(self, perm: str, obj: None = ...) -> bool: ... - def has_perms(self, perm_list: Union[Tuple[str], List[str]], obj: None = ...) -> bool: ... + def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ... class UserManager: diff --git a/django/contrib/auth/password_validation.pyi b/django/contrib/auth/password_validation.pyi index f451e70..d2bc030 100644 --- a/django/contrib/auth/password_validation.pyi +++ b/django/contrib/auth/password_validation.pyi @@ -14,12 +14,12 @@ def _password_validators_help_text_html(password_validators: None = ...) -> str: def get_default_password_validators( -) -> Union[List[UserAttributeSimilarityValidator], List[NumericPasswordValidator]]: ... +) -> Union[List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]]: ... def get_password_validators( validator_config: List[Dict[str, str]] -) -> Union[List[UserAttributeSimilarityValidator], List[NumericPasswordValidator]]: ... +) -> Union[List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]]: ... def password_changed( diff --git a/django/contrib/auth/views.pyi b/django/contrib/auth/views.pyi index 0d5c4c3..1989bd2 100644 --- a/django/contrib/auth/views.pyi +++ b/django/contrib/auth/views.pyi @@ -15,6 +15,7 @@ from typing import ( Dict, Optional, Set, + Type, Union, ) @@ -32,16 +33,16 @@ class LoginView: request: HttpRequest, *args, **kwargs - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def form_valid( self, form: AuthenticationForm ) -> HttpResponseRedirect: ... def get_context_data(self, **kwargs) -> Dict[str, Any]: ... - def get_form_class(self) -> Any: ... + def get_form_class(self) -> Type[AuthenticationForm]: ... def get_form_kwargs( self - ) -> Dict[str, Union[None, MultiValueDict, WSGIRequest]]: ... + ) -> Dict[str, Optional[Union[MultiValueDict, WSGIRequest]]]: ... def get_redirect_url(self) -> str: ... def get_success_url(self) -> str: ... @@ -52,7 +53,7 @@ class LogoutView: request: HttpRequest, *args, **kwargs - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def get_next_page(self) -> Optional[str]: ... def post( self, @@ -71,14 +72,14 @@ class PasswordChangeView: self, *args, **kwargs - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def form_valid( self, form: PasswordChangeForm ) -> HttpResponseRedirect: ... def get_form_kwargs( self - ) -> Dict[str, Union[None, User, MultiValueDict]]: ... + ) -> Dict[str, Optional[Union[MultiValueDict, User]]]: ... class PasswordResetConfirmView: @@ -86,11 +87,11 @@ class PasswordResetConfirmView: self, *args, **kwargs - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def form_valid(self, form: SetPasswordForm) -> HttpResponseRedirect: ... def get_form_kwargs( self - ) -> Dict[str, Union[None, User, MultiValueDict]]: ... + ) -> Dict[str, Optional[Union[MultiValueDict, User]]]: ... def get_user(self, uidb64: str) -> Optional[User]: ... @@ -99,7 +100,7 @@ class PasswordResetView: self, *args, **kwargs - ) -> Union[HttpResponseRedirect, TemplateResponse]: ... + ) -> Union[TemplateResponse, HttpResponseRedirect]: ... def form_valid(self, form: PasswordResetForm) -> HttpResponseRedirect: ... diff --git a/django/contrib/contenttypes/fields.pyi b/django/contrib/contenttypes/fields.pyi index cf5b763..ba3a9f6 100644 --- a/django/contrib/contenttypes/fields.pyi +++ b/django/contrib/contenttypes/fields.pyi @@ -25,26 +25,30 @@ from typing import ( class GenericForeignKey: - def __get__(self, instance: Any, cls: Any = ...) -> Any: ... + def __get__( + self, + instance: Optional[Model], + cls: Type[Model] = ... + ) -> Optional[Union[Model, GenericForeignKey]]: ... def __init__(self, ct_field: str = ..., fk_field: str = ..., for_concrete_model: bool = ...) -> None: ... - def __set__(self, instance: Model, value: Any) -> None: ... + def __set__(self, instance: Model, value: Optional[Model]) -> None: ... def __str__(self) -> str: ... def _check_content_type_field(self) -> List[Error]: ... def _check_field_name(self) -> List[Any]: ... def _check_object_id_field(self) -> List[Any]: ... def check(self, **kwargs) -> List[Error]: ... - def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ... + def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ... def get_cache_name(self) -> str: ... def get_content_type( self, - obj: Any = ..., + obj: Optional[Model] = ..., id: Optional[int] = ..., using: Optional[str] = ... ) -> ContentType: ... def get_filter_kwargs_for_object( self, obj: Model - ) -> Dict[str, Union[None, ContentType, int]]: ... + ) -> Dict[str, Optional[Union[ContentType, int]]]: ... def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ... def get_prefetch_queryset( self, @@ -57,7 +61,7 @@ class GenericRel: def __init__( self, field: GenericRelation, - to: Any, + to: Union[Type[Model], str], related_name: None = ..., related_query_name: Optional[str] = ..., limit_choices_to: None = ... @@ -67,7 +71,7 @@ class GenericRel: class GenericRelation: def __init__( self, - to: Any, + to: Union[Type[Model], str], object_id_field: str = ..., content_type_field: str = ..., for_concrete_model: bool = ..., @@ -81,9 +85,13 @@ class GenericRelation: self, field: Optional[Union[GenericForeignKey, GenericRelation]] ) -> bool: ... - def bulk_related_objects(self, objs: Any, using: str = ...) -> QuerySet: ... + def bulk_related_objects( + self, + objs: List[Model], + using: str = ... + ) -> QuerySet: ... def check(self, **kwargs) -> List[Error]: ... - def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ... + def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ... def get_content_type(self) -> ContentType: ... def get_extra_restriction( self, @@ -99,5 +107,5 @@ class GenericRelation: def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ... def resolve_related_fields( self - ) -> Union[List[Tuple[PositiveIntegerField, AutoField]], List[Tuple[PositiveIntegerField, related.OneToOneField]]]: ... + ) -> Union[List[Tuple[PositiveIntegerField, related.OneToOneField]], List[Tuple[PositiveIntegerField, AutoField]]]: ... def set_attributes_from_rel(self) -> None: ... \ No newline at end of file diff --git a/django/contrib/contenttypes/management/__init__.pyi b/django/contrib/contenttypes/management/__init__.pyi index bdeb0e6..abb7888 100644 --- a/django/contrib/contenttypes/management/__init__.pyi +++ b/django/contrib/contenttypes/management/__init__.pyi @@ -2,10 +2,14 @@ from django.apps.config import AppConfig from django.apps.registry import Apps from django.contrib.contenttypes.models import ContentType from django.db.backends.sqlite3.schema import DatabaseSchemaEditor +from django.db.migrations.migration import Migration from django.db.migrations.state import StateApps from typing import ( Any, + List, + Tuple, Type, + Union, ) @@ -27,7 +31,7 @@ def get_contenttypes_and_models( def inject_rename_contenttypes_operations( - plan: Any = ..., + plan: Union[List[Any], List[Tuple[Migration, bool]]] = ..., apps: StateApps = ..., using: str = ..., **kwargs diff --git a/django/contrib/humanize/templatetags/humanize.pyi b/django/contrib/humanize/templatetags/humanize.pyi index 438cbc7..af6f4f2 100644 --- a/django/contrib/humanize/templatetags/humanize.pyi +++ b/django/contrib/humanize/templatetags/humanize.pyi @@ -11,7 +11,7 @@ from typing import ( def apnumber(value: str) -> str: ... -def intcomma(value: Optional[Union[str, float, int]], use_l10n: bool = ...) -> str: ... +def intcomma(value: Optional[Union[str, float]], use_l10n: bool = ...) -> str: ... def intword(value: Optional[str]) -> Optional[str]: ... diff --git a/django/contrib/messages/storage/base.pyi b/django/contrib/messages/storage/base.pyi index 177645e..94a4700 100644 --- a/django/contrib/messages/storage/base.pyi +++ b/django/contrib/messages/storage/base.pyi @@ -12,7 +12,7 @@ class BaseStorage: def __len__(self) -> int: ... def _get_level(self) -> int: ... @property - def _loaded_messages(self) -> Union[List[str], List[Message]]: ... + def _loaded_messages(self) -> Union[List[Message], List[str]]: ... def _prepare_messages(self, messages: List[Message]) -> None: ... def _set_level(self, value: int = ...) -> None: ... def add(self, level: int, message: str, extra_tags: Optional[str] = ...) -> None: ... diff --git a/django/contrib/messages/storage/cookie.pyi b/django/contrib/messages/storage/cookie.pyi index 7dc2e74..a681a9c 100644 --- a/django/contrib/messages/storage/cookie.pyi +++ b/django/contrib/messages/storage/cookie.pyi @@ -13,14 +13,14 @@ class CookieStorage: def _decode(self, data: Optional[str]) -> Any: ... def _encode( self, - messages: Union[List[str], List[Message]], + messages: Union[List[Message], List[str]], encode_empty: bool = ... ) -> Optional[str]: ... def _get( self, *args, **kwargs - ) -> Union[Tuple[None, bool], Tuple[List[str], bool], Tuple[List[Any], bool], Tuple[List[Message], bool]]: ... + ) -> Union[Tuple[None, bool], Tuple[List[Any], bool], Tuple[List[str], bool], Tuple[List[Message], bool]]: ... def _hash(self, value: str) -> str: ... def _store( self, @@ -38,7 +38,7 @@ class MessageDecoder: self, s: str, **kwargs - ) -> Union[List[Message], List[Union[Message, str]], List[str]]: ... + ) -> Union[List[Union[Message, str]], List[Message], List[str]]: ... def process_messages(self, obj: Any) -> Any: ... diff --git a/django/contrib/messages/storage/fallback.pyi b/django/contrib/messages/storage/fallback.pyi index 4b15b83..06d0fc6 100644 --- a/django/contrib/messages/storage/fallback.pyi +++ b/django/contrib/messages/storage/fallback.pyi @@ -14,7 +14,7 @@ class FallbackStorage: self, *args, **kwargs - ) -> Union[Tuple[List[str], bool], Tuple[List[Any], bool], Tuple[List[Message], bool]]: ... + ) -> Union[Tuple[List[Any], bool], Tuple[List[str], bool], Tuple[List[Message], bool]]: ... def _store( self, messages: List[Message], diff --git a/django/contrib/messages/storage/session.pyi b/django/contrib/messages/storage/session.pyi index 36419be..db77841 100644 --- a/django/contrib/messages/storage/session.pyi +++ b/django/contrib/messages/storage/session.pyi @@ -27,5 +27,5 @@ class SessionStorage: def deserialize_messages( self, data: Optional[str] - ) -> Optional[Union[List[str], List[Message]]]: ... + ) -> Optional[Union[List[Message], List[str]]]: ... def serialize_messages(self, messages: Union[List[Message], List[str]]) -> str: ... \ No newline at end of file diff --git a/django/contrib/sessions/backends/base.pyi b/django/contrib/sessions/backends/base.pyi index 93e1ce4..0a54494 100644 --- a/django/contrib/sessions/backends/base.pyi +++ b/django/contrib/sessions/backends/base.pyi @@ -21,7 +21,7 @@ class SessionBase: def _get_session( self, no_load: bool = ... - ) -> Dict[str, Union[Model, int, str, datetime]]: ... + ) -> Dict[str, Union[str, int, datetime, Model]]: ... def _get_session_key(self) -> Optional[str]: ... def _hash(self, value: bytes) -> str: ... def _set_session_key(self, value: Optional[str]) -> None: ... @@ -29,7 +29,7 @@ class SessionBase: def clear(self) -> None: ... def cycle_key(self) -> None: ... def decode(self, session_data: Union[str, bytes]) -> Dict[str, Union[str, int]]: ... - def encode(self, session_dict: Dict[str, Union[int, str, datetime]]) -> str: ... + def encode(self, session_dict: Dict[str, Union[str, int, datetime]]) -> str: ... def flush(self) -> None: ... def get(self, key: str, default: Optional[str] = ...) -> Optional[Union[str, datetime, int]]: ... def get_expire_at_browser_close(self) -> bool: ... @@ -37,7 +37,7 @@ class SessionBase: def get_expiry_date(self, **kwargs) -> datetime: ... def is_empty(self) -> bool: ... def pop(self, key: str, default: object = ...) -> Union[str, int]: ... - def set_expiry(self, value: Optional[Union[int, datetime, timedelta]]) -> None: ... + def set_expiry(self, value: Optional[Union[datetime, int, timedelta]]) -> None: ... def setdefault(self, key: str, value: str) -> str: ... def test_cookie_worked(self) -> bool: ... def update(self, dict_: Dict[str, int]) -> None: ... \ No newline at end of file diff --git a/django/contrib/sessions/backends/db.pyi b/django/contrib/sessions/backends/db.pyi index fb2c15f..ab88cae 100644 --- a/django/contrib/sessions/backends/db.pyi +++ b/django/contrib/sessions/backends/db.pyi @@ -17,7 +17,7 @@ class SessionStore: def create(self) -> None: ... def create_model_instance( self, - data: Dict[str, Union[int, str, datetime]] + data: Dict[str, Union[str, int, datetime]] ) -> AbstractBaseSession: ... def delete(self, session_key: Optional[str] = ...) -> None: ... def exists(self, session_key: Optional[str]) -> bool: ... diff --git a/django/contrib/sitemaps/__init__.pyi b/django/contrib/sitemaps/__init__.pyi index ad16e2a..ab16747 100644 --- a/django/contrib/sitemaps/__init__.pyi +++ b/django/contrib/sitemaps/__init__.pyi @@ -36,13 +36,13 @@ class Sitemap: page: Union[str, int], protocol: str, domain: str - ) -> Union[List[Dict[str, Union[Model, str, None]]], List[Dict[str, object]]]: ... + ) -> Union[List[Dict[str, object]], List[Dict[str, Union[Model, str, None]]]]: ... def get_urls( self, page: Union[str, int] = ..., site: Optional[Union[RequestSite, Site]] = ..., protocol: Optional[str] = ... - ) -> Union[List[Dict[str, Union[Model, str, datetime, None]]], List[Dict[str, object]]]: ... + ) -> Union[List[Dict[str, object]], List[Dict[str, Union[Model, str, datetime, None]]]]: ... def items(self) -> List[Any]: ... def location(self, obj: Model) -> str: ... @property diff --git a/django/contrib/sitemaps/views.pyi b/django/contrib/sitemaps/views.pyi index 3bc10b8..9984150 100644 --- a/django/contrib/sitemaps/views.pyi +++ b/django/contrib/sitemaps/views.pyi @@ -1,12 +1,16 @@ -from django.contrib.sitemaps import Sitemap +from django.contrib.flatpages.sitemaps import FlatPageSitemap +from django.contrib.sitemaps import ( + GenericSitemap, + Sitemap, +) from django.core.handlers.wsgi import WSGIRequest from django.template.response import TemplateResponse from typing import ( - Any, Callable, Dict, Optional, Type, + Union, ) @@ -21,7 +25,7 @@ def index( def sitemap( request: WSGIRequest, - sitemaps: Dict[str, Any], + sitemaps: Dict[str, Union[Type[Sitemap], Type[FlatPageSitemap], GenericSitemap]], section: Optional[str] = ..., template_name: str = ..., content_type: str = ... diff --git a/django/contrib/staticfiles/utils.pyi b/django/contrib/staticfiles/utils.pyi index f533152..e561fe6 100644 --- a/django/contrib/staticfiles/utils.pyi +++ b/django/contrib/staticfiles/utils.pyi @@ -21,4 +21,4 @@ def get_files( ) -> Iterator[str]: ... -def matches_patterns(path: str, patterns: Union[OrderedDict, Tuple[str], List[str]] = ...) -> bool: ... \ No newline at end of file +def matches_patterns(path: str, patterns: Union[OrderedDict, List[str], Tuple[str]] = ...) -> bool: ... \ No newline at end of file diff --git a/django/core/cache/__init__.pyi b/django/core/cache/__init__.pyi index bc5f6c9..00f9430 100644 --- a/django/core/cache/__init__.pyi +++ b/django/core/cache/__init__.pyi @@ -19,5 +19,5 @@ class CacheHandler: class DefaultCacheProxy: def __contains__(self, key: str) -> bool: ... - def __getattr__(self, name: str) -> Union[OrderedDict, Callable, Dict[str, float]]: ... + def __getattr__(self, name: str) -> Union[OrderedDict, Dict[str, float], Callable]: ... def __setattr__(self, name: str, value: Callable) -> None: ... \ No newline at end of file diff --git a/django/core/cache/backends/base.pyi b/django/core/cache/backends/base.pyi index d14c8a8..770d3bd 100644 --- a/django/core/cache/backends/base.pyi +++ b/django/core/cache/backends/base.pyi @@ -27,7 +27,7 @@ class BaseCache: def get_or_set( self, key: str, - default: Optional[Union[str, Callable, int]], + default: Optional[Union[str, int, Callable]], timeout: object = ..., version: Optional[int] = ... ) -> Optional[Union[str, int]]: ... @@ -36,7 +36,7 @@ class BaseCache: def make_key(self, key: Union[str, int], version: Optional[Union[str, int]] = ...) -> str: ... def set_many( self, - data: Union[Dict[str, str], Dict[str, Union[Dict[str, int], str]], Dict[str, int], OrderedDict], + data: Union[Dict[str, Union[Dict[str, int], str]], OrderedDict, Dict[str, str], Dict[str, int]], timeout: object = ..., version: Optional[int] = ... ) -> List[Any]: ... diff --git a/django/core/cache/backends/db.pyi b/django/core/cache/backends/db.pyi index 8ce17d2..d21ee53 100644 --- a/django/core/cache/backends/db.pyi +++ b/django/core/cache/backends/db.pyi @@ -10,11 +10,11 @@ from typing import ( class BaseDatabaseCache: - def __init__(self, table: str, params: Dict[str, Union[int, Callable, str, Dict[str, int]]]) -> None: ... + def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], str, int]]) -> None: ... class DatabaseCache: - def _base_set(self, mode: str, key: str, value: Any, timeout: object = ...): ... + def _base_set(self, mode: str, key: str, value: object, timeout: object = ...): ... def _cull(self, db: str, cursor: CursorWrapper, now: datetime) -> None: ... def add( self, diff --git a/django/core/cache/backends/dummy.pyi b/django/core/cache/backends/dummy.pyi index 6ad42ab..b297721 100644 --- a/django/core/cache/backends/dummy.pyi +++ b/django/core/cache/backends/dummy.pyi @@ -14,7 +14,7 @@ class DummyCache: def set( self, key: str, - value: Union[str, int, Dict[str, Any]], + value: Union[str, Dict[str, Any], int], timeout: object = ..., version: Optional[str] = ... ) -> None: ... \ No newline at end of file diff --git a/django/core/cache/backends/filebased.pyi b/django/core/cache/backends/filebased.pyi index 09c4279..ac0d4fd 100644 --- a/django/core/cache/backends/filebased.pyi +++ b/django/core/cache/backends/filebased.pyi @@ -13,7 +13,7 @@ from typing import ( ) -def _write_content(f: Union[BufferedRandom, BufferedWriter], expiry: float, value: Any) -> None: ... +def _write_content(f: Union[BufferedRandom, BufferedWriter], expiry: float, value: object) -> None: ... class FileBasedCache: diff --git a/django/core/cache/backends/locmem.pyi b/django/core/cache/backends/locmem.pyi index 13a00ac..514b46b 100644 --- a/django/core/cache/backends/locmem.pyi +++ b/django/core/cache/backends/locmem.pyi @@ -14,7 +14,7 @@ class LocMemCache: def add( self, key: str, - value: Union[int, Dict[str, int], str, Dict[str, str]], + value: Union[int, str, Dict[str, str], Dict[str, int]], timeout: object = ..., version: Optional[int] = ... ): ... @@ -31,7 +31,7 @@ class LocMemCache: def set( self, key: Union[str, int], - value: Any, + value: object, timeout: object = ..., version: Optional[int] = ... ) -> None: ... diff --git a/django/core/checks/messages.pyi b/django/core/checks/messages.pyi index 9b20981..7343e13 100644 --- a/django/core/checks/messages.pyi +++ b/django/core/checks/messages.pyi @@ -1,7 +1,4 @@ -from typing import ( - Any, - Optional, -) +from typing import Optional class CheckMessage: @@ -11,7 +8,7 @@ class CheckMessage: level: int, msg: str, hint: Optional[str] = ..., - obj: Any = ..., + obj: object = ..., id: Optional[str] = ... ) -> None: ... def __str__(self) -> str: ... diff --git a/django/core/checks/registry.pyi b/django/core/checks/registry.pyi index bd26ab2..8dbd10f 100644 --- a/django/core/checks/registry.pyi +++ b/django/core/checks/registry.pyi @@ -16,5 +16,5 @@ class CheckRegistry: app_configs: None = ..., tags: Optional[List[str]] = ..., include_deployment_checks: bool = ... - ) -> Union[List[str], List[Warning], List[int]]: ... + ) -> Union[List[int], List[str], List[Warning]]: ... def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ... \ No newline at end of file diff --git a/django/core/checks/urls.pyi b/django/core/checks/urls.pyi index 8c6673b..e06cb53 100644 --- a/django/core/checks/urls.pyi +++ b/django/core/checks/urls.pyi @@ -22,8 +22,8 @@ def _load_all_namespaces(resolver: URLResolver, parents: Tuple = ...) -> List[st def check_resolver( - resolver: Union[URLResolver, URLPattern] -) -> Union[List[Error], List[Warning]]: ... + resolver: Union[URLPattern, URLResolver] +) -> Union[List[Warning], List[Error]]: ... def check_url_config(app_configs: None, **kwargs) -> List[Warning]: ... diff --git a/django/core/exceptions.pyi b/django/core/exceptions.pyi index 2821bf1..68808d0 100644 --- a/django/core/exceptions.pyi +++ b/django/core/exceptions.pyi @@ -1,3 +1,4 @@ +from collections.abc import Iterable from django.forms.utils import ErrorDict from typing import ( Any, @@ -11,7 +12,12 @@ from typing import ( class ValidationError: - def __init__(self, message: Any, code: Optional[str] = ..., params: Any = ...) -> None: ... + def __init__( + self, + message: Iterable, + code: Optional[str] = ..., + params: Any = ... + ) -> None: ... def __iter__(self) -> Iterator[Union[str, Tuple[str, List[str]]]]: ... def __str__(self) -> str: ... @property diff --git a/django/core/files/storage.pyi b/django/core/files/storage.pyi index 0733748..078d24c 100644 --- a/django/core/files/storage.pyi +++ b/django/core/files/storage.pyi @@ -6,11 +6,12 @@ from typing import ( List, Optional, Tuple, + Type, Union, ) -def get_storage_class(import_path: Optional[str] = ...) -> Any: ... +def get_storage_class(import_path: Optional[str] = ...) -> Type[Storage]: ... class FileSystemStorage: @@ -46,7 +47,7 @@ class FileSystemStorage: def listdir( self, path: str - ) -> Union[Tuple[List[Any], List[Any]], Tuple[List[Any], List[str]], Tuple[List[str], List[Any]], Tuple[List[str], List[str]]]: ... + ) -> Union[Tuple[List[str], List[Any]], Tuple[List[Any], List[Any]], Tuple[List[Any], List[str]], Tuple[List[str], List[str]]]: ... @cached_property def location(self) -> str: ... def path(self, name: str) -> str: ... diff --git a/django/core/files/uploadedfile.pyi b/django/core/files/uploadedfile.pyi index be4a30d..6a9627a 100644 --- a/django/core/files/uploadedfile.pyi +++ b/django/core/files/uploadedfile.pyi @@ -45,7 +45,7 @@ class TemporaryUploadedFile: class UploadedFile: def __init__( self, - file: Optional[Union[_TemporaryFileWrapper, StringIO, BytesIO]] = ..., + file: Optional[Union[StringIO, _TemporaryFileWrapper, BytesIO]] = ..., name: str = ..., content_type: str = ..., size: Optional[int] = ..., diff --git a/django/core/handlers/exception.pyi b/django/core/handlers/exception.pyi index cb27356..d69065a 100644 --- a/django/core/handlers/exception.pyi +++ b/django/core/handlers/exception.pyi @@ -1,7 +1,18 @@ +from django.core.exceptions import ( + PermissionDenied, + SuspiciousOperation, +) from django.core.handlers.wsgi import WSGIRequest -from django.http.response import HttpResponse +from django.http.multipartparser import MultiPartParserError +from django.http.response import ( + Http404, + HttpResponse, +) from django.urls.resolvers import URLResolver -from typing import Callable +from typing import ( + Callable, + Union, +) def convert_exception_to_response(get_response: Callable) -> Callable: ... @@ -11,7 +22,7 @@ def get_exception_response( request: WSGIRequest, resolver: URLResolver, status_code: int, - exception: Exception, + exception: Union[MultiPartParserError, PermissionDenied, Http404, SuspiciousOperation], sender: None = ... ) -> HttpResponse: ... diff --git a/django/core/mail/__init__.pyi b/django/core/mail/__init__.pyi index 630f18f..bbdd2d9 100644 --- a/django/core/mail/__init__.pyi +++ b/django/core/mail/__init__.pyi @@ -1,5 +1,4 @@ from django.core.mail.backends.base import BaseEmailBackend -from mail.custombackend import EmailBackend from typing import ( List, Optional, @@ -50,5 +49,5 @@ def send_mass_mail( fail_silently: bool = ..., auth_user: None = ..., auth_password: None = ..., - connection: EmailBackend = ... + connection: BaseEmailBackend = ... ) -> int: ... \ No newline at end of file diff --git a/django/core/mail/message.pyi b/django/core/mail/message.pyi index bd41998..4818b18 100644 --- a/django/core/mail/message.pyi +++ b/django/core/mail/message.pyi @@ -2,7 +2,6 @@ from django.core.mail.backends.base import BaseEmailBackend from email.mime.base import MIMEBase from email.mime.text import MIMEText from typing import ( - Any, Dict, List, Optional, @@ -28,7 +27,7 @@ class EmailMessage: from_email: Optional[str] = ..., to: Optional[List[str]] = ..., bcc: None = ..., - connection: Any = ..., + connection: Optional[BaseEmailBackend] = ..., attachments: Optional[List[MIMEText]] = ..., headers: Optional[Dict[str, str]] = ..., cc: Optional[List[str]] = ..., @@ -37,7 +36,7 @@ class EmailMessage: def _create_attachment( self, filename: Optional[str], - content: Union[str, bytes, SafeMIMEText], + content: Union[bytes, str, SafeMIMEText], mimetype: str = ... ) -> MIMEBase: ... def _create_attachments( @@ -71,7 +70,7 @@ class EmailMultiAlternatives: from_email: Optional[str] = ..., to: List[str] = ..., bcc: None = ..., - connection: Any = ..., + connection: Optional[BaseEmailBackend] = ..., attachments: None = ..., headers: Optional[Dict[str, str]] = ..., alternatives: None = ..., diff --git a/django/core/management/commands/inspectdb.pyi b/django/core/management/commands/inspectdb.pyi index 7deee38..6a7be58 100644 --- a/django/core/management/commands/inspectdb.pyi +++ b/django/core/management/commands/inspectdb.pyi @@ -19,7 +19,7 @@ class Command: connection: DatabaseWrapper, table_name: str, row: FieldInfo - ) -> Union[Tuple[str, OrderedDict, List[str]], Tuple[str, OrderedDict, List[Any]]]: ... + ) -> Union[Tuple[str, OrderedDict, List[Any]], Tuple[str, OrderedDict, List[str]]]: ... def get_meta( self, table_name: str, @@ -34,4 +34,4 @@ class Command: col_name: str, used_column_names: List[str], is_relation: bool - ) -> Union[Tuple[str, Dict[str, str], List[str]], Tuple[str, Dict[Any, Any], List[Any]]]: ... \ No newline at end of file + ) -> Union[Tuple[str, Dict[Any, Any], List[Any]], Tuple[str, Dict[str, str], List[str]]]: ... \ No newline at end of file diff --git a/django/core/management/commands/loaddata.pyi b/django/core/management/commands/loaddata.pyi index ad28722..653e16a 100644 --- a/django/core/management/commands/loaddata.pyi +++ b/django/core/management/commands/loaddata.pyi @@ -16,11 +16,11 @@ class Command: def fixture_dirs(self) -> List[str]: ... def handle(self, *fixture_labels, **options) -> None: ... def load_label(self, fixture_label: str) -> None: ... - def loaddata(self, fixture_labels: Union[Tuple[str], Tuple[str, str]]) -> None: ... + def loaddata(self, fixture_labels: Union[Tuple[str, str], Tuple[str]]) -> None: ... def parse_name( self, fixture_name: str - ) -> Union[Tuple[str, str, str], Tuple[str, str, None], Tuple[str, None, None]]: ... + ) -> Union[Tuple[str, None, None], Tuple[str, str, None], Tuple[str, str, str]]: ... class SingleZipReader: diff --git a/django/core/management/commands/migrate.pyi b/django/core/management/commands/migrate.pyi index 5ee9f80..5dc13a7 100644 --- a/django/core/management/commands/migrate.pyi +++ b/django/core/management/commands/migrate.pyi @@ -1,8 +1,10 @@ from django.core.management.base import CommandParser from django.db.backends.sqlite3.base import DatabaseWrapper +from django.db.migrations.migration import Migration from typing import ( Any, List, + Optional, Set, ) @@ -10,5 +12,10 @@ from typing import ( class Command: def _run_checks(self, **kwargs) -> List[Any]: ... def add_arguments(self, parser: CommandParser) -> None: ... - def migration_progress_callback(self, action: str, migration: Any = ..., fake: bool = ...) -> None: ... + def migration_progress_callback( + self, + action: str, + migration: Optional[Migration] = ..., + fake: bool = ... + ) -> None: ... def sync_apps(self, connection: DatabaseWrapper, app_labels: Set[str]) -> None: ... \ No newline at end of file diff --git a/django/core/paginator.pyi b/django/core/paginator.pyi index e9fd254..d6359e8 100644 --- a/django/core/paginator.pyi +++ b/django/core/paginator.pyi @@ -8,10 +8,10 @@ from typing import ( class Page: - def __getitem__(self, index: Union[slice, int]) -> Union[str, List[Model]]: ... + def __getitem__(self, index: Union[slice, int]) -> Union[List[Model], str]: ... def __init__( self, - object_list: Union[QuerySet, str, List[object], List[int]], + object_list: Union[List[int], str, List[object], QuerySet], number: int, paginator: Paginator ) -> None: ... @@ -28,7 +28,7 @@ class Page: class Paginator: def __init__( self, - object_list: Union[List[object], QuerySet, List[int]], + object_list: Union[List[int], QuerySet, List[object]], per_page: Union[str, int], orphans: Union[str, int] = ..., allow_empty_first_page: bool = ... @@ -43,4 +43,4 @@ class Paginator: def page(self, number: Union[str, int]) -> Page: ... @property def page_range(self) -> range: ... - def validate_number(self, number: Optional[Union[str, float, int]]) -> int: ... \ No newline at end of file + def validate_number(self, number: Optional[Union[float, str]]) -> int: ... \ No newline at end of file diff --git a/django/core/serializers/__init__.pyi b/django/core/serializers/__init__.pyi index 3ff22d8..2d7bd9a 100644 --- a/django/core/serializers/__init__.pyi +++ b/django/core/serializers/__init__.pyi @@ -50,7 +50,7 @@ def serialize( def sort_dependencies( - app_list: Union[List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None], Tuple[AppConfig, None]]], List[Tuple[str, List[Type[Model]]]], List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None]]]] + app_list: Union[List[Tuple[str, List[Type[Model]]]], List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None], Tuple[AppConfig, None]]], List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None]]]] ) -> List[Type[Model]]: ... diff --git a/django/core/serializers/base.pyi b/django/core/serializers/base.pyi index 59fd67e..adf2e6b 100644 --- a/django/core/serializers/base.pyi +++ b/django/core/serializers/base.pyi @@ -17,12 +17,17 @@ from typing import ( Dict, List, Optional, + Type, Union, ) from uuid import UUID -def build_instance(Model: Any, data: Dict[str, Any], db: str) -> Model: ... +def build_instance( + Model: Type[Model], + data: Dict[str, Any], + db: str +) -> Model: ... def deserialize_fk_value( @@ -34,7 +39,7 @@ def deserialize_fk_value( def deserialize_m2m_values( field: ManyToManyField, - field_value: Union[List[List[str]], List[Union[int, str]], List[int]], + field_value: Union[List[List[str]], List[int], List[Union[int, str]]], using: str ) -> List[int]: ... @@ -57,7 +62,7 @@ class DeserializedObject: class Deserializer: - def __init__(self, stream_or_string: Union[str, BufferedReader, TextIOWrapper], **options) -> None: ... + def __init__(self, stream_or_string: Union[str, TextIOWrapper, BufferedReader], **options) -> None: ... def __iter__(self) -> Deserializer: ... diff --git a/django/core/serializers/json.pyi b/django/core/serializers/json.pyi index 4c9a074..4a767c6 100644 --- a/django/core/serializers/json.pyi +++ b/django/core/serializers/json.pyi @@ -16,7 +16,7 @@ def Deserializer(stream_or_string: Any, **options) -> None: ... class DjangoJSONEncoder: - def default(self, o: Union[Decimal, UUID, date, timedelta]) -> str: ... + def default(self, o: Union[Decimal, date, timedelta, UUID]) -> str: ... class Serializer: diff --git a/django/core/serializers/python.pyi b/django/core/serializers/python.pyi index 99db9e0..3c48b44 100644 --- a/django/core/serializers/python.pyi +++ b/django/core/serializers/python.pyi @@ -1,4 +1,5 @@ from collections import OrderedDict +from datetime import datetime from django.core.serializers.base import DeserializedObject from django.db.models.base import Model from django.db.models.fields import Field @@ -10,6 +11,9 @@ from typing import ( Any, Iterator, List, + Optional, + Type, + Union, ) @@ -22,11 +26,15 @@ def Deserializer( ) -> Iterator[DeserializedObject]: ... -def _get_model(model_identifier: str) -> Any: ... +def _get_model(model_identifier: str) -> Type[Model]: ... class Serializer: - def _value_from_field(self, obj: Model, field: Field) -> Any: ... + def _value_from_field( + self, + obj: Model, + field: Field + ) -> Optional[Union[str, float, datetime]]: ... def end_object(self, obj: Model) -> None: ... def end_serialization(self) -> None: ... def get_dump_object(self, obj: Model) -> OrderedDict: ... diff --git a/django/core/serializers/xml_serializer.pyi b/django/core/serializers/xml_serializer.pyi index ca2c27a..3e258fd 100644 --- a/django/core/serializers/xml_serializer.pyi +++ b/django/core/serializers/xml_serializer.pyi @@ -10,9 +10,9 @@ from django.db.models.fields.related import ( ManyToManyField, ) from typing import ( - Any, List, Optional, + Type, Union, ) from xml.dom.minidom import Element @@ -36,7 +36,7 @@ class Deserializer: **options ) -> None: ... def __next__(self) -> DeserializedObject: ... - def _get_model_from_node(self, node: Element, attr: str) -> Any: ... + def _get_model_from_node(self, node: Element, attr: str) -> Type[Model]: ... def _handle_fk_field_node( self, node: Element, diff --git a/django/core/signing.pyi b/django/core/signing.pyi index 2acd4fb..dad2eb3 100644 --- a/django/core/signing.pyi +++ b/django/core/signing.pyi @@ -20,10 +20,10 @@ def base64_hmac(salt: str, value: Union[str, bytes], key: Union[str, bytes]) -> def dumps( - obj: Union[str, Dict[str, str], Dict[str, Union[str, datetime]], List[str]], + obj: Union[str, List[str], Dict[str, Union[str, datetime]], Dict[str, str]], key: None = ..., salt: str = ..., - serializer: Type[Union[JSONSerializer, PickleSerializer]] = ..., + serializer: Type[Union[PickleSerializer, JSONSerializer]] = ..., compress: bool = ... ) -> str: ... @@ -35,14 +35,14 @@ def loads( s: str, key: None = ..., salt: str = ..., - serializer: Type[Union[JSONSerializer, PickleSerializer]] = ..., + serializer: Type[Union[PickleSerializer, JSONSerializer]] = ..., max_age: Optional[int] = ... -) -> Union[str, Dict[str, str], List[str]]: ... +) -> Union[str, List[str], Dict[str, str]]: ... class JSONSerializer: def dumps(self, obj: Any) -> bytes: ... - def loads(self, data: bytes) -> Union[Dict[str, str], List[str]]: ... + def loads(self, data: bytes) -> Union[List[str], Dict[str, str]]: ... class Signer: diff --git a/django/core/validators.pyi b/django/core/validators.pyi index 4e65a2b..b0b9332 100644 --- a/django/core/validators.pyi +++ b/django/core/validators.pyi @@ -4,7 +4,6 @@ from django.core.files.base import ContentFile from django.utils.functional import SimpleLazyObject from re import RegexFlag from typing import ( - Any, List, Optional, Union, @@ -38,12 +37,16 @@ def validate_ipv6_address(value: str) -> None: ... class BaseValidator: - def __call__(self, value: Any) -> None: ... - def __init__(self, limit_value: Any, message: None = ...) -> None: ... + def __call__(self, value: Union[Decimal, float, str, datetime]) -> None: ... + def __init__( + self, + limit_value: Optional[Union[Decimal, float, datetime]], + message: None = ... + ) -> None: ... def clean( self, - x: Union[float, datetime, int, Decimal] - ) -> Union[float, datetime, int, Decimal]: ... + x: Union[Decimal, datetime, float] + ) -> Union[Decimal, datetime, float]: ... def compare(self, a: bool, b: bool) -> bool: ... @@ -82,7 +85,7 @@ class MaxLengthValidator: class MaxValueValidator: - def compare(self, a: Union[float, Decimal, int], b: Union[float, Decimal, int]) -> bool: ... + def compare(self, a: Union[float, Decimal], b: Union[float, Decimal]) -> bool: ... class MinLengthValidator: @@ -93,8 +96,8 @@ class MinLengthValidator: class MinValueValidator: def compare( self, - a: Union[float, Decimal, int, datetime], - b: Union[float, Decimal, int, datetime] + a: Union[float, Decimal, datetime], + b: Union[float, Decimal, datetime] ) -> bool: ... @@ -102,7 +105,7 @@ class ProhibitNullCharactersValidator: def __call__(self, value: Optional[str]) -> None: ... def __eq__( self, - other: Union[RegexValidator, ProhibitNullCharactersValidator] + other: Union[ProhibitNullCharactersValidator, RegexValidator] ) -> bool: ... def __init__(self, message: Optional[str] = ..., code: Optional[str] = ...) -> None: ... diff --git a/django/db/__init__.pyi b/django/db/__init__.pyi index 2c151dd..f187971 100644 --- a/django/db/__init__.pyi +++ b/django/db/__init__.pyi @@ -15,4 +15,4 @@ def reset_queries(**kwargs) -> None: ... class DefaultConnectionProxy: def __eq__(self, other: DatabaseWrapper) -> bool: ... def __getattr__(self, item: str) -> Any: ... - def __setattr__(self, name: str, value: Union[MagicMock, bool]) -> None: ... \ No newline at end of file + def __setattr__(self, name: str, value: Union[bool, MagicMock]) -> None: ... \ No newline at end of file diff --git a/django/db/backends/base/creation.pyi b/django/db/backends/base/creation.pyi index 6b1dc5f..0357dc6 100644 --- a/django/db/backends/base/creation.pyi +++ b/django/db/backends/base/creation.pyi @@ -27,5 +27,5 @@ class BaseDatabaseCreation: suffix: None = ... ) -> None: ... def serialize_db_to_string(self) -> str: ... - def set_as_test_mirror(self, primary_settings_dict: Dict[str, Union[str, int, None, Dict[str, None]]]) -> None: ... + def set_as_test_mirror(self, primary_settings_dict: Dict[str, Optional[Union[str, int, Dict[str, None]]]]) -> None: ... def test_db_signature(self) -> Tuple[str, str, str, str]: ... \ No newline at end of file diff --git a/django/db/backends/base/operations.pyi b/django/db/backends/base/operations.pyi index e2379cc..fb22eea 100644 --- a/django/db/backends/base/operations.pyi +++ b/django/db/backends/base/operations.pyi @@ -5,18 +5,27 @@ from datetime import ( timedelta, ) from decimal import Decimal +from django.contrib.auth.models import ( + Group, + User, +) +from django.contrib.sites.models import Site from django.core.management.color import Style from django.db import DefaultConnectionProxy from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.utils import CursorWrapper +from django.db.models.base import Model from django.db.models.expressions import Expression from django.db.models.fields import Field +from django.db.models.sql.compiler import SQLCompiler from typing import ( Any, List, Optional, + Set, Tuple, + Type, Union, ) @@ -35,15 +44,15 @@ class BaseDatabaseOperations: decimal_places: Optional[int] = ... ) -> Optional[str]: ... def adapt_ipaddressfield_value(self, value: Optional[str]) -> Optional[str]: ... - def adapt_timefield_value(self, value: Optional[Union[time, datetime]]) -> Optional[str]: ... - def adapt_unknown_value(self, value: Union[Decimal, time, date, int]) -> Union[str, int]: ... + def adapt_timefield_value(self, value: Optional[Union[datetime, time]]) -> Optional[str]: ... + def adapt_unknown_value(self, value: Union[date, time, int, Decimal]) -> Union[str, int]: ... def autoinc_sql(self, table: str, column: str) -> None: ... def binary_placeholder_sql(self, value: Optional[memoryview]) -> str: ... def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ... - def compiler(self, compiler_name: str) -> Any: ... + def compiler(self, compiler_name: str) -> Type[SQLCompiler]: ... def convert_durationfield_value( self, - value: Optional[Union[float, int]], + value: Optional[float], expression: Expression, connection: DatabaseWrapper ) -> Optional[timedelta]: ... @@ -70,7 +79,11 @@ class BaseDatabaseOperations: def savepoint_create_sql(self, sid: str) -> str: ... def savepoint_rollback_sql(self, sid: str) -> str: ... def sequence_reset_by_name_sql(self, style: None, sequences: List[Any]) -> List[Any]: ... - def sequence_reset_sql(self, style: Style, model_list: Any) -> List[Any]: ... + def sequence_reset_sql( + self, + style: Style, + model_list: Union[Set[Type[Model]], List[Type[Model]], Set[Type[Union[Group, User]]], List[Type[Site]]] + ) -> List[Any]: ... def set_time_zone_sql(self) -> str: ... def tablespace_sql(self, tablespace: str, inline: bool = ...) -> str: ... def time_extract_sql(self, lookup_type: None, field_name: None): ... diff --git a/django/db/backends/base/schema.pyi b/django/db/backends/base/schema.pyi index 45e28ee..742d87b 100644 --- a/django/db/backends/base/schema.pyi +++ b/django/db/backends/base/schema.pyi @@ -37,12 +37,12 @@ class BaseDatabaseSchemaEditor: def _create_index_name( self, table_name: str, - column_names: Union[Tuple[str, str, str], Tuple[str], List[str]], + column_names: Union[Tuple[str, str, str], List[str], Tuple[str]], suffix: str = ... ) -> str: ... def _create_index_sql( self, - model: Any, + model: Type[Model], fields: Any, *, name = ..., @@ -52,7 +52,11 @@ class BaseDatabaseSchemaEditor: col_suffixes = ..., sql = ... ) -> Statement: ... - def _create_unique_sql(self, model: Any, columns: List[str]) -> Statement: ... + def _create_unique_sql( + self, + model: Type[Model], + columns: List[str] + ) -> Statement: ... def _delete_composed_index( self, model: Type[Model], @@ -64,6 +68,6 @@ class BaseDatabaseSchemaEditor: def _digest(cls, *args) -> str: ... def _field_indexes_sql( self, - model: Any, + model: Type[Model], field: Field ) -> List[Statement]: ... \ No newline at end of file diff --git a/django/db/backends/mysql/client.pyi b/django/db/backends/mysql/client.pyi index 3b6af1c..b6140ee 100644 --- a/django/db/backends/mysql/client.pyi +++ b/django/db/backends/mysql/client.pyi @@ -7,4 +7,4 @@ from typing import ( class DatabaseClient: @classmethod - def settings_to_cmd_args(cls, settings_dict: Dict[str, Union[str, None]]) -> List[str]: ... \ No newline at end of file + def settings_to_cmd_args(cls, settings_dict: Dict[str, Optional[str]]) -> List[str]: ... \ No newline at end of file diff --git a/django/db/backends/sqlite3/base.pyi b/django/db/backends/sqlite3/base.pyi index 93255cb..a0f51d0 100644 --- a/django/db/backends/sqlite3/base.pyi +++ b/django/db/backends/sqlite3/base.pyi @@ -78,5 +78,5 @@ class SQLiteCursorWrapper: def executemany( self, query: str, - param_list: Union[List[Tuple[int]], List[Tuple[int, int]]] + param_list: Union[List[Tuple[int, int]], List[Tuple[int]]] ) -> SQLiteCursorWrapper: ... \ No newline at end of file diff --git a/django/db/backends/sqlite3/introspection.pyi b/django/db/backends/sqlite3/introspection.pyi index e35750c..dc52f48 100644 --- a/django/db/backends/sqlite3/introspection.pyi +++ b/django/db/backends/sqlite3/introspection.pyi @@ -27,7 +27,7 @@ class DatabaseIntrospection: self, cursor: CursorWrapper, name: str - ) -> List[Dict[str, Union[str, None, int]]]: ... + ) -> List[Dict[str, Optional[Union[str, int]]]]: ... def get_constraints( self, cursor: CursorWrapper, diff --git a/django/db/backends/sqlite3/operations.pyi b/django/db/backends/sqlite3/operations.pyi index 7de077f..8f9b24e 100644 --- a/django/db/backends/sqlite3/operations.pyi +++ b/django/db/backends/sqlite3/operations.pyi @@ -10,14 +10,19 @@ from django.db.backends.sqlite3.base import ( SQLiteCursorWrapper, ) from django.db.backends.utils import CursorDebugWrapper -from django.db.models.aggregates import Aggregate +from django.db.models.aggregates import ( + Aggregate, + Max, +) from django.db.models.expressions import ( - BaseExpression, Col, CombinedExpression, Expression, F, + OrderBy, ) +from django.db.models.functions.comparison import Cast +from django.db.models.functions.datetime import TruncBase from typing import ( Any, Callable, @@ -40,7 +45,10 @@ class DatabaseOperations: def adapt_timefield_value(self, value: Optional[time]) -> Optional[str]: ... def bulk_batch_size(self, fields: Any, objs: Any) -> int: ... def bulk_insert_sql(self, fields: Any, placeholder_rows: Any) -> str: ... - def check_expression_support(self, expression: BaseExpression) -> None: ... + def check_expression_support( + self, + expression: Union[OrderBy, Expression] + ) -> None: ... def combine_duration_expression(self, connector: str, sub_expressions: List[str]) -> str: ... def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ... def convert_booleanfield_value( @@ -52,7 +60,7 @@ class DatabaseOperations: def convert_datefield_value( self, value: Optional[Union[str, date]], - expression: Expression, + expression: Union[Col, Cast, Aggregate, django.db.models.functions.TruncBase], connection: DatabaseWrapper ) -> Optional[date]: ... def convert_datetimefield_value( @@ -64,7 +72,7 @@ class DatabaseOperations: def convert_timefield_value( self, value: Optional[Union[str, time]], - expression: Expression, + expression: Union[Col, Max, django.db.models.functions.TruncBase], connection: DatabaseWrapper ) -> Optional[time]: ... def convert_uuidfield_value( @@ -92,7 +100,7 @@ class DatabaseOperations: self, cursor: Union[SQLiteCursorWrapper, CursorDebugWrapper], sql: str, - params: Optional[Union[Tuple, List[str]]] + params: Optional[Union[List[str], Tuple]] ) -> str: ... def no_limit_value(self) -> int: ... def pk_default_value(self) -> str: ... @@ -108,7 +116,7 @@ class DatabaseOperations: self, internal_type: str, lhs: Tuple[str, List[Any]], - rhs: Union[Tuple[str, List[Any]], Tuple[str, List[str]]] - ) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + rhs: Union[Tuple[str, List[str]], Tuple[str, List[Any]]] + ) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ... def time_extract_sql(self, lookup_type: str, field_name: str) -> str: ... def time_trunc_sql(self, lookup_type: str, field_name: str) -> str: ... \ No newline at end of file diff --git a/django/db/backends/sqlite3/schema.pyi b/django/db/backends/sqlite3/schema.pyi index 469a00e..1c6cad7 100644 --- a/django/db/backends/sqlite3/schema.pyi +++ b/django/db/backends/sqlite3/schema.pyi @@ -20,13 +20,13 @@ class DatabaseSchemaEditor: def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ... def _alter_field( self, - model: Any, + model: Type[Model], old_field: Field, new_field: Field, old_type: str, new_type: str, - old_db_params: Dict[str, Union[str, None]], - new_db_params: Dict[str, Union[str, None]], + old_db_params: Dict[str, Optional[str]], + new_db_params: Dict[str, Optional[str]], strict: bool = ... ) -> None: ... def _is_referenced_by_fk_constraint( @@ -37,7 +37,7 @@ class DatabaseSchemaEditor: ) -> bool: ... def _remake_table( self, - model: Any, + model: Type[Model], create_field: Optional[Union[IntegerField, TimeField]] = ..., delete_field: Optional[Union[AutoField, SlugField]] = ..., alter_field: Any = ... @@ -45,18 +45,18 @@ class DatabaseSchemaEditor: def add_field(self, model: Type[Model], field: Field) -> None: ... def alter_db_table( self, - model: Any, + model: Type[Model], old_db_table: str, new_db_table: str, disable_constraints: bool = ... ) -> None: ... def alter_field( self, - model: Any, + model: Type[Model], old_field: Field, new_field: Field, strict: bool = ... ) -> None: ... - def delete_model(self, model: Any, handle_autom2m: bool = ...) -> None: ... + def delete_model(self, model: Type[Model], handle_autom2m: bool = ...) -> None: ... def quote_value(self, value: Optional[Union[int, memoryview, str]]) -> str: ... def remove_field(self, model: Type[Model], field: Field) -> None: ... \ No newline at end of file diff --git a/django/db/backends/utils.pyi b/django/db/backends/utils.pyi index b332dbe..a7385da 100644 --- a/django/db/backends/utils.pyi +++ b/django/db/backends/utils.pyi @@ -47,7 +47,7 @@ def typecast_timestamp(s: str) -> date: ... class CursorDebugWrapper: - def execute(self, sql: str, params: Optional[Union[Tuple, List[str]]] = ...): ... + def execute(self, sql: str, params: Optional[Union[List[str], Tuple]] = ...): ... class CursorWrapper: diff --git a/django/db/migrations/autodetector.pyi b/django/db/migrations/autodetector.pyi index bd0595c..bf5d11f 100644 --- a/django/db/migrations/autodetector.pyi +++ b/django/db/migrations/autodetector.pyi @@ -1,12 +1,13 @@ from django.db.migrations.graph import MigrationGraph from django.db.migrations.migration import Migration -from django.db.migrations.operations.base import Operation from django.db.migrations.operations.fields import FieldOperation from django.db.migrations.operations.models import ( + AddIndex, CreateModel, DeleteModel, FieldRelatedOptionOperation, ModelOperation, + RemoveIndex, ) from django.db.migrations.questioner import MigrationQuestioner from django.db.migrations.state import ProjectState @@ -62,7 +63,7 @@ class MigrationAutodetector: def add_operation( self, app_label: str, - operation: Operation, + operation: Union[FieldOperation, RemoveIndex, ModelOperation], dependencies: Any = ..., beginning: bool = ... ) -> None: ... @@ -81,11 +82,11 @@ class MigrationAutodetector: ) -> Dict[str, List[Migration]]: ... def check_dependency( self, - operation: Operation, - dependency: Union[Tuple[str, str, str, str], Tuple[str, str, str, bool], Tuple[str, str, None, bool]] + operation: Union[FieldOperation, AddIndex, ModelOperation], + dependency: Union[Tuple[str, str, None, bool], Tuple[str, str, str, str], Tuple[str, str, str, bool]] ) -> bool: ... def create_altered_indexes(self) -> None: ... - def deep_deconstruct(self, obj: Any) -> Any: ... + def deep_deconstruct(self, obj: object) -> Any: ... def generate_added_fields(self) -> None: ... def generate_added_indexes(self) -> None: ... def generate_altered_db_table(self) -> None: ... diff --git a/django/db/migrations/executor.pyi b/django/db/migrations/executor.pyi index 929378f..acae884 100644 --- a/django/db/migrations/executor.pyi +++ b/django/db/migrations/executor.pyi @@ -20,12 +20,17 @@ class MigrationExecutor: progress_callback: Optional[Callable] = ... ) -> None: ... def _create_project_state(self, with_applied_migrations: bool = ...) -> ProjectState: ... - def _migrate_all_backwards(self, plan: Any, full_plan: Any, fake: bool) -> ProjectState: ... + def _migrate_all_backwards( + self, + plan: List[Tuple[Migration, bool]], + full_plan: Union[List[Any], List[Tuple[Migration, bool]]], + fake: bool + ) -> ProjectState: ... def _migrate_all_forwards( self, state: ProjectState, - plan: Any, - full_plan: Any, + plan: Union[List[Any], List[Tuple[Migration, bool]]], + full_plan: Union[List[Any], List[Tuple[Migration, bool]]], fake: bool, fake_initial: bool ) -> ProjectState: ... @@ -44,17 +49,17 @@ class MigrationExecutor: ) -> Tuple[bool, ProjectState]: ... def migrate( self, - targets: Optional[Union[List[Tuple[str, str]], List[Tuple[str, None]]]], - plan: Any = ..., + targets: Optional[Union[List[Tuple[str, None]], List[Tuple[str, str]]]], + plan: Optional[Union[List[Any], List[Tuple[Migration, bool]]]] = ..., state: Optional[ProjectState] = ..., fake: bool = ..., fake_initial: bool = ... ) -> ProjectState: ... def migration_plan( self, - targets: Union[Set[Tuple[str, str]], List[Tuple[str, str]], List[Tuple[str, None]]], + targets: Union[List[Tuple[str, None]], List[Tuple[str, str]], Set[Tuple[str, str]]], clean_start: bool = ... - ) -> Any: ... + ) -> Union[List[Any], List[Tuple[Migration, bool]], List[Tuple[object, bool]]]: ... def unapply_migration( self, state: ProjectState, diff --git a/django/db/migrations/graph.pyi b/django/db/migrations/graph.pyi index da8eda3..c1ba6e4 100644 --- a/django/db/migrations/graph.pyi +++ b/django/db/migrations/graph.pyi @@ -1,7 +1,9 @@ -from django.db.migrations.migration import SwappableTuple +from django.db.migrations.migration import ( + Migration, + SwappableTuple, +) from django.db.migrations.state import ProjectState from typing import ( - Any, Callable, List, Optional, @@ -11,7 +13,12 @@ from typing import ( class DummyNode: - def __init__(self, key: Tuple[str, str], origin: Any, error_message: str) -> None: ... + def __init__( + self, + key: Tuple[str, str], + origin: Union[Migration, str], + error_message: str + ) -> None: ... def promote(self) -> None: ... def raise_error(self): ... @@ -25,14 +32,19 @@ class MigrationGraph: def _nodes_and_edges(self) -> Tuple[int, int]: ... def add_dependency( self, - migration: Any, + migration: Optional[Union[Migration, str]], child: Tuple[str, str], parent: Tuple[str, str], skip_validation: bool = ... ) -> None: ... - def add_dummy_node(self, key: Tuple[str, str], origin: Any, error_message: str) -> None: ... - def add_node(self, key: Tuple[str, str], migration: Any) -> None: ... - def backwards_plan(self, target: Union[Tuple[str, str], Node]) -> List[Tuple[str, str]]: ... + def add_dummy_node( + self, + key: Tuple[str, str], + origin: Union[Migration, str], + error_message: str + ) -> None: ... + def add_node(self, key: Tuple[str, str], migration: object) -> None: ... + def backwards_plan(self, target: Union[Node, Tuple[str, str]]) -> List[Tuple[str, str]]: ... def clear_cache(self) -> None: ... def ensure_not_cyclic( self, diff --git a/django/db/migrations/operations/base.pyi b/django/db/migrations/operations/base.pyi index b23b270..c60772f 100644 --- a/django/db/migrations/operations/base.pyi +++ b/django/db/migrations/operations/base.pyi @@ -4,13 +4,18 @@ from typing import ( List, Optional, Tuple, + Type, Union, ) class Operation: @staticmethod - def __new__(cls: Any, *args, **kwargs) -> Operation: ... + def __new__( + cls: Type[Operation], + *args, + **kwargs + ) -> Operation: ... def _get_model_tuple(self, remote_model: str, app_label: str, model_name: str) -> Tuple[str, str]: ... def reduce( self, diff --git a/django/db/migrations/operations/fields.pyi b/django/db/migrations/operations/fields.pyi index 9827662..2a4ab3a 100644 --- a/django/db/migrations/operations/fields.pyi +++ b/django/db/migrations/operations/fields.pyi @@ -1,8 +1,10 @@ from django.db.backends.sqlite3.schema import DatabaseSchemaEditor -from django.db.migrations.operations.base import Operation from django.db.migrations.operations.models import ( AlterUniqueTogether, + CreateModel, DeleteModel, + FieldRelatedOptionOperation, + ModelOperation, ) from django.db.migrations.state import ProjectState from django.db.models.fields import ( @@ -47,7 +49,7 @@ class AddField: def describe(self) -> str: ... def reduce( self, - operation: Operation, + operation: Union[FieldOperation, CreateModel, FieldRelatedOptionOperation], in_between: List[AddField], app_label: Optional[str] = ... ) -> Union[bool, List[AddField]]: ... @@ -82,7 +84,7 @@ class AlterField: def describe(self) -> str: ... def reduce( self, - operation: Union[DeleteModel, AlterField, AlterUniqueTogether], + operation: Union[AlterField, DeleteModel, AlterUniqueTogether], in_between: List[Any], app_label: str = ... ) -> bool: ... @@ -99,7 +101,7 @@ class FieldOperation: def name_lower(self) -> str: ... def reduce( self, - operation: Operation, + operation: Union[ModelOperation, FieldOperation], in_between: Any, app_label: str = ... ) -> bool: ... diff --git a/django/db/migrations/operations/models.pyi b/django/db/migrations/operations/models.pyi index fed2226..e32cc68 100644 --- a/django/db/migrations/operations/models.pyi +++ b/django/db/migrations/operations/models.pyi @@ -1,5 +1,6 @@ from django.db.backends.sqlite3.schema import DatabaseSchemaEditor from django.db.migrations.operations.base import Operation +from django.db.migrations.operations.fields import FieldOperation from django.db.migrations.state import ProjectState from django.db.models.indexes import Index from typing import ( @@ -183,7 +184,7 @@ class DeleteModel: class FieldRelatedOptionOperation: def reduce( self, - operation: Operation, + operation: Union[FieldOperation, CreateModel, AlterIndexTogether], in_between: List[DeleteModel], app_label: Optional[str] = ... ) -> Any: ... @@ -200,7 +201,7 @@ class ModelOperation: def name_lower(self) -> str: ... def reduce( self, - operation: Operation, + operation: Union[FieldOperation, ModelOperation], in_between: Any, app_label: Optional[str] = ... ) -> bool: ... @@ -210,7 +211,7 @@ class ModelOperation: class ModelOptionOperation: def reduce( self, - operation: Operation, + operation: Union[FieldOperation, CreateModel, FieldRelatedOptionOperation], in_between: List[DeleteModel], app_label: Optional[str] = ... ) -> Union[bool, List[AlterUniqueTogether]]: ... diff --git a/django/db/migrations/operations/special.pyi b/django/db/migrations/operations/special.pyi index da9b3b1..88a6f70 100644 --- a/django/db/migrations/operations/special.pyi +++ b/django/db/migrations/operations/special.pyi @@ -77,7 +77,7 @@ class SeparateDatabaseAndState: def __init__( self, database_operations: List[ModelOperation] = ..., - state_operations: Union[List[AddField], List[CreateModel], List[ModelOperation]] = ... + state_operations: Union[List[CreateModel], List[AddField], List[ModelOperation]] = ... ) -> None: ... def database_forwards( self, diff --git a/django/db/migrations/serializer.pyi b/django/db/migrations/serializer.pyi index 4fcefb1..4fb7102 100644 --- a/django/db/migrations/serializer.pyi +++ b/django/db/migrations/serializer.pyi @@ -12,7 +12,7 @@ def serializer_factory(value: Any) -> BaseSerializer: ... class BaseSequenceSerializer: - def serialize(self) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ... + def serialize(self) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ... class BaseSerializer: @@ -38,8 +38,8 @@ class DeconstructableSerializer: @staticmethod def serialize_deconstructed( path: str, - args: Union[Tuple, List[str]], - kwargs: Dict[str, Any] + args: Union[List[str], Tuple], + kwargs: Dict[str, object] ) -> Tuple[str, Set[str]]: ... @@ -96,7 +96,7 @@ class TupleSerializer: class TypeSerializer: - def serialize(self) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ... + def serialize(self) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ... class UUIDSerializer: diff --git a/django/db/migrations/state.pyi b/django/db/migrations/state.pyi index 7962254..93da09d 100644 --- a/django/db/migrations/state.pyi +++ b/django/db/migrations/state.pyi @@ -1,9 +1,11 @@ from django.apps.registry import Apps +from django.db.models.base import Model from django.db.models.fields import Field from django.db.models.indexes import Index from typing import ( Any, Iterator, + Type, ) @@ -27,7 +29,11 @@ class ModelState: def clone(self) -> ModelState: ... def construct_managers(self) -> Iterator[Any]: ... @classmethod - def from_model(cls, model: Any, exclude_rels: bool = ...) -> ModelState: ... + def from_model( + cls, + model: Type[Model], + exclude_rels: bool = ... + ) -> ModelState: ... def get_field_by_name(self, name: str) -> Field: ... def get_index_by_name(self, name: str) -> Index: ... @cached_property diff --git a/django/db/migrations/writer.pyi b/django/db/migrations/writer.pyi index fa6b639..68331f6 100644 --- a/django/db/migrations/writer.pyi +++ b/django/db/migrations/writer.pyi @@ -19,7 +19,7 @@ class MigrationWriter: @property def path(self) -> str: ... @classmethod - def serialize(cls, value: Any) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ... + def serialize(cls, value: Any) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ... class OperationWriter: @@ -27,7 +27,7 @@ class OperationWriter: def feed(self, line: str) -> None: ... def indent(self) -> None: ... def render(self) -> str: ... - def serialize(self) -> Union[Tuple[str, Set[Any]], Tuple[str, Set[str]]]: ... + def serialize(self) -> Union[Tuple[str, Set[str]], Tuple[str, Set[Any]]]: ... def unindent(self) -> None: ... diff --git a/django/db/models/deletion.pyi b/django/db/models/deletion.pyi index a7e9565..26394d0 100644 --- a/django/db/models/deletion.pyi +++ b/django/db/models/deletion.pyi @@ -1,3 +1,8 @@ +from django.contrib.auth.models import ( + Permission, + User, +) +from django.contrib.contenttypes.models import ContentType from django.db.models.base import Model from django.db.models.fields.related import ForeignKey from django.db.models.fields.reverse_related import ManyToOneRel @@ -11,6 +16,7 @@ from typing import ( List, Optional, Tuple, + Type, Union, ) @@ -50,7 +56,7 @@ class Collector: def add( self, objs: Any, - source: Any = ..., + source: Optional[Union[Type[Model], Type[ContentType]]] = ..., nullable: bool = ..., reverse_dependency: bool = ... ) -> Any: ... @@ -68,15 +74,19 @@ class Collector: def collect( self, objs: Any, - source: Any = ..., + source: Optional[Union[Type[Model], Type[ContentType]]] = ..., nullable: bool = ..., collect_related: bool = ..., source_attr: Optional[str] = ..., reverse_dependency: bool = ..., keep_parents: bool = ... ) -> None: ... - def delete(self) -> Union[Tuple[int, Dict[Any, Any]], Tuple[int, Dict[str, int]]]: ... - def get_del_batches(self, objs: Any, field: ForeignKey) -> Any: ... + def delete(self) -> Union[Tuple[int, Dict[str, int]], Tuple[int, Dict[Any, Any]]]: ... + def get_del_batches( + self, + objs: Union[List[User], List[Model], List[ContentType], List[Permission]], + field: ForeignKey + ) -> Union[List[List[Model]], List[List[ContentType]], List[List[User]], List[List[Permission]]]: ... def instances_with_model(self) -> Iterator[Any]: ... def related_objects( self, @@ -90,5 +100,5 @@ class ProtectedError: def __init__( self, msg: str, - protected_objects: Union[QuerySet, List[Model]] + protected_objects: Union[List[Model], QuerySet] ) -> None: ... \ No newline at end of file diff --git a/django/db/models/expressions.pyi b/django/db/models/expressions.pyi index 182a4cb..157b588 100644 --- a/django/db/models/expressions.pyi +++ b/django/db/models/expressions.pyi @@ -4,10 +4,19 @@ from datetime import ( timedelta, ) from django.db.backends.sqlite3.base import DatabaseWrapper -from django.db.models.aggregates import Count -from django.db.models.fields import Field +from django.db.models.aggregates import ( + Aggregate, + Count, +) +from django.db.models.fields import ( + DateTimeCheckMixin, + Field, +) from django.db.models.fields.related import ForeignKey -from django.db.models.fields.reverse_related import ForeignObjectRel +from django.db.models.fields.reverse_related import ( + ForeignObjectRel, + OneToOneRel, +) from django.db.models.functions.datetime import Trunc from django.db.models.functions.text import BytesToCharFieldConversionMixin from django.db.models.query_utils import Q @@ -42,10 +51,17 @@ class BaseExpression: connection: DatabaseWrapper ) -> str: ... @cached_property - def _output_field_or_none(self) -> Any: ... + def _output_field_or_none( + self + ) -> Optional[Union[Field, DateTimeCheckMixin]]: ... def _parse_expressions(self, *expressions) -> Any: ... - def _prepare(self, field: Any) -> Expression: ... - def _resolve_output_field(self) -> Any: ... + def _prepare( + self, + field: Union[Field, DateTimeCheckMixin, reverse_related.OneToOneRel] + ) -> Expression: ... + def _resolve_output_field( + self + ) -> Optional[Union[Field, DateTimeCheckMixin]]: ... def asc(self, **kwargs) -> OrderBy: ... @cached_property def contains_aggregate(self) -> bool: ... @@ -55,21 +71,25 @@ class BaseExpression: def contains_over_clause(self) -> bool: ... @cached_property def convert_value(self) -> Callable: ... - def copy(self) -> BaseExpression: ... + def copy( + self + ) -> Union[OrderBy, Expression, SQLiteNumericMixin]: ... def desc(self, **kwargs) -> OrderBy: ... @property - def field(self) -> Any: ... + def field( + self + ) -> Union[ForeignObjectRel, Field, DateTimeCheckMixin]: ... def flatten(self) -> Iterator[Union[Value, Func]]: ... def get_db_converters(self, connection: DatabaseWrapper) -> List[Callable]: ... def get_group_by_cols( self ) -> Union[List[CombinedExpression], List[Trunc], List[Col]]: ... - def get_lookup(self, lookup: str) -> Any: ... + def get_lookup(self, lookup: str) -> object: ... def get_source_expressions(self) -> List[Any]: ... def get_source_fields(self) -> Any: ... def get_transform(self, name: str) -> Any: ... @cached_property - def output_field(self) -> Field: ... + def output_field(self) -> Union[Field, DateTimeCheckMixin]: ... def relabeled_clone( self, change_map: Union[OrderedDict, Dict[Union[str, None], str]] @@ -81,7 +101,7 @@ class BaseExpression: reuse: Optional[Set[str]] = ..., summarize: bool = ..., for_save: bool = ... - ) -> BaseExpression: ... + ) -> Union[OrderBy, Expression]: ... def set_source_expressions(self, exprs: List[Any]) -> None: ... @@ -110,7 +130,12 @@ class Case: class Col: - def __init__(self, alias: str, target: Field, output_field: Any = ...) -> None: ... + def __init__( + self, + alias: str, + target: Union[Field, DateTimeCheckMixin], + output_field: Optional[Union[reverse_related.ForeignObjectRel, Field]] = ... + ) -> None: ... def __repr__(self) -> str: ... def as_sql( self, @@ -126,7 +151,10 @@ class Col: class Combinable: - def __add__(self, other: Any) -> CombinedExpression: ... + def __add__( + self, + other: Union[float, timedelta, F, Aggregate] + ) -> CombinedExpression: ... def __mod__(self, other: int) -> CombinedExpression: ... def __mul__( self, @@ -134,16 +162,16 @@ class Combinable: ) -> CombinedExpression: ... def __radd__( self, - other: Optional[Union[float, int, timedelta]] + other: Optional[Union[float, timedelta]] ) -> CombinedExpression: ... def __rand__(self, other: object): ... def __rmul__(self, other: float) -> CombinedExpression: ... def __ror__(self, other: object): ... - def __rsub__(self, other: Union[float, int]) -> CombinedExpression: ... + def __rsub__(self, other: float) -> CombinedExpression: ... def __rtruediv__(self, other: int) -> CombinedExpression: ... def __sub__( self, - other: Union[float, timedelta, int, F] + other: Union[float, timedelta, F] ) -> CombinedExpression: ... def __truediv__( self, @@ -158,7 +186,7 @@ class CombinedExpression: self, lhs: Combinable, connector: str, - rhs: Combinable, + rhs: Union[F, Expression], output_field: None = ... ) -> None: ... def __str__(self) -> str: ... @@ -166,7 +194,7 @@ class CombinedExpression: self, compiler: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[datetime]], Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[float]]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[float]], Tuple[str, List[Any]], Tuple[str, List[datetime]]]: ... def get_source_expressions(self) -> Any: ... def resolve_expression( self, @@ -209,7 +237,7 @@ class Exists: connection: DatabaseWrapper, template: None = ..., **extra_context - ) -> Union[Tuple[str, Tuple[int]], Tuple[str, Tuple]]: ... + ) -> Union[Tuple[str, Tuple], Tuple[str, Tuple[int]]]: ... def resolve_expression( self, query: Query = ..., @@ -236,10 +264,10 @@ class ExpressionWrapper: ) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]]]: ... def get_source_expressions( self - ) -> Union[List[Q], List[CombinedExpression], List[WhereNode]]: ... + ) -> Union[List[CombinedExpression], List[Q], List[WhereNode]]: ... def set_source_expressions( self, - exprs: Union[List[WhereNode], List[CombinedExpression]] + exprs: Union[List[CombinedExpression], List[WhereNode]] ) -> None: ... @@ -289,7 +317,7 @@ class Func: class OrderBy: def __init__( self, - expression: Combinable, + expression: Union[F, Expression], descending: bool = ..., nulls_first: bool = ..., nulls_last: bool = ... diff --git a/django/db/models/fields/__init__.pyi b/django/db/models/fields/__init__.pyi index 9ab7c3b..d7f8f11 100644 --- a/django/db/models/fields/__init__.pyi +++ b/django/db/models/fields/__init__.pyi @@ -19,6 +19,7 @@ from typing import ( Any, List, Optional, + Type, Union, ) @@ -27,7 +28,7 @@ class AutoField: def __init__(self, *args, **kwargs) -> None: ... def _check_primary_key(self) -> List[Any]: ... def check(self, **kwargs) -> List[Any]: ... - def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ... + def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ... def deconstruct(self) -> Any: ... def formfield(self, **kwargs) -> None: ... def get_db_prep_value( @@ -86,7 +87,7 @@ class CharField: def check(self, **kwargs) -> List[Error]: ... def formfield(self, **kwargs) -> Union[CharField, TypedChoiceField]: ... def get_internal_type(self) -> str: ... - def get_prep_value(self, value: Any) -> object: ... + def get_prep_value(self, value: object) -> object: ... def to_python(self, value: Optional[Union[int, str, Model]]) -> Optional[str]: ... @@ -100,15 +101,15 @@ class DateField: **kwargs ) -> None: ... def _check_fix_default_value(self) -> List[Warning]: ... - def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ... + def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ... def deconstruct(self) -> Any: ... def formfield( self, **kwargs - ) -> Union[SplitDateTimeField, BaseTemporalField]: ... + ) -> Union[BaseTemporalField, SplitDateTimeField]: ... def get_db_prep_value( self, - value: Optional[Union[date, str]], + value: Optional[Union[str, date]], connection: DatabaseWrapper, prepared: bool = ... ) -> Optional[str]: ... diff --git a/django/db/models/fields/files.pyi b/django/db/models/fields/files.pyi index 5673539..673512c 100644 --- a/django/db/models/fields/files.pyi +++ b/django/db/models/fields/files.pyi @@ -18,13 +18,14 @@ from typing import ( List, Optional, Tuple, + Type, Union, ) class FieldFile: - def __eq__(self, other: Optional[Union[Tuple, str, FieldFile]]) -> bool: ... - def __getstate__(self) -> Dict[str, Union[str, bool, None]]: ... + def __eq__(self, other: Optional[Union[str, Tuple, FieldFile]]) -> bool: ... + def __getstate__(self) -> Dict[str, Optional[Union[str, bool]]]: ... def __init__( self, instance: Model, @@ -51,8 +52,8 @@ class FieldFile: class FileDescriptor: def __get__( self, - instance: Any, - cls: Any = ... + instance: Optional[Model], + cls: Type[Model] = ... ) -> Union[FileDescriptor, FieldFile]: ... def __init__(self, field: FileField) -> None: ... def __set__( @@ -74,10 +75,10 @@ class FileField: def _check_primary_key(self) -> List[Error]: ... def _check_upload_to(self) -> List[Any]: ... def check(self, **kwargs) -> List[Any]: ... - def contribute_to_class(self, cls: Any, name: str, **kwargs) -> None: ... + def contribute_to_class(self, cls: Type[Model], name: str, **kwargs) -> None: ... def deconstruct(self) -> Any: ... def formfield(self, **kwargs) -> FileField: ... - def generate_filename(self, instance: Any, filename: str) -> str: ... + def generate_filename(self, instance: Optional[Model], filename: str) -> str: ... def get_internal_type(self) -> str: ... def get_prep_value(self, value: FieldFile) -> str: ... def pre_save( diff --git a/django/db/models/fields/mixins.pyi b/django/db/models/fields/mixins.pyi index 966265c..a6ab33a 100644 --- a/django/db/models/fields/mixins.pyi +++ b/django/db/models/fields/mixins.pyi @@ -1,9 +1,17 @@ from django.db.models.base import Model -from typing import Any +from typing import Optional class FieldCacheMixin: def delete_cached_value(self, instance: Model) -> None: ... - def get_cached_value(self, instance: Model, default: object = ...) -> Any: ... + def get_cached_value( + self, + instance: Model, + default: object = ... + ) -> Optional[Model]: ... def is_cached(self, instance: Model) -> bool: ... - def set_cached_value(self, instance: Model, value: Any) -> None: ... \ No newline at end of file + def set_cached_value( + self, + instance: Model, + value: Optional[Model] + ) -> None: ... \ No newline at end of file diff --git a/django/db/models/fields/related.pyi b/django/db/models/fields/related.pyi index c20ee9a..2fdada5 100644 --- a/django/db/models/fields/related.pyi +++ b/django/db/models/fields/related.pyi @@ -3,11 +3,13 @@ from django.core.checks.messages import ( Warning, ) from django.db.backends.sqlite3.base import DatabaseWrapper +from django.db.models.base import Model from django.db.models.expressions import Col from django.db.models.fields import Field from django.db.models.fields.reverse_related import ( ForeignObjectRel, ManyToOneRel, + OneToOneRel, ) from django.db.models.query_utils import ( FilteredRelation, @@ -21,6 +23,7 @@ from typing import ( List, Optional, Tuple, + Type, Union, ) from uuid import UUID @@ -44,10 +47,10 @@ class ForeignKey: def check( self, **kwargs - ) -> Union[List[Error], List[Warning]]: ... + ) -> Union[List[Warning], List[Error]]: ... def contribute_to_related_class( self, - cls: Any, + cls: Type[Model], related: ManyToOneRel ) -> None: ... def db_check(self, connection: DatabaseWrapper) -> List[Any]: ... @@ -57,16 +60,20 @@ class ForeignKey: def formfield(self, *, using = ..., **kwargs) -> ModelChoiceField: ... def get_attname(self) -> str: ... def get_attname_column(self) -> Tuple[str, str]: ... - def get_col(self, alias: str, output_field: Any = ...) -> Col: ... + def get_col( + self, + alias: str, + output_field: Optional[Union[Field, reverse_related.OneToOneRel]] = ... + ) -> Col: ... def get_db_converters(self, connection: DatabaseWrapper) -> List[Any]: ... def get_db_prep_save( self, - value: Any, + value: object, connection: DatabaseWrapper ) -> Optional[Union[str, int]]: ... def get_db_prep_value( self, - value: Union[str, UUID, int], + value: Union[str, int, UUID], connection: DatabaseWrapper, prepared: bool = ... ) -> Union[str, int]: ... @@ -78,7 +85,7 @@ class ForeignKey: @property def target_field(self) -> Field: ... def to_python(self, value: Union[str, int]) -> Union[str, int]: ... - def validate(self, value: int, model_instance: Any) -> None: ... + def validate(self, value: int, model_instance: Optional[Model]) -> None: ... class ForeignObject: @@ -86,8 +93,8 @@ class ForeignObject: self, to: Any, on_delete: Callable, - from_fields: Union[Tuple[str, str], List[str]], - to_fields: Union[List[str], List[None], Tuple[str, str]], + from_fields: Union[List[str], Tuple[str, str]], + to_fields: Union[List[None], List[str], Tuple[str, str]], rel: Optional[ForeignObjectRel] = ..., related_name: Optional[str] = ..., related_query_name: None = ..., diff --git a/django/db/models/fields/related_descriptors.pyi b/django/db/models/fields/related_descriptors.pyi index 949b581..1ae023f 100644 --- a/django/db/models/fields/related_descriptors.pyi +++ b/django/db/models/fields/related_descriptors.pyi @@ -1,5 +1,6 @@ from django.core.exceptions import ObjectDoesNotExist from django.db.models.base import Model +from django.db.models.expressions import F from django.db.models.fields.related import ForeignObject from django.db.models.fields.reverse_related import ( ForeignObjectRel, @@ -8,24 +9,33 @@ from django.db.models.fields.reverse_related import ( ) from django.db.models.query import QuerySet from typing import ( - Any, Callable, + List, Optional, Tuple, Type, + Union, ) class ForwardManyToOneDescriptor: @cached_property def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ... - def __get__(self, instance: Any, cls: Any = ...) -> Any: ... + def __get__( + self, + instance: Optional[Model], + cls: Type[Model] = ... + ) -> Optional[Union[Model, ForwardManyToOneDescriptor]]: ... def __init__(self, field_with_rel: ForeignObject) -> None: ... - def __set__(self, instance: Model, value: Any) -> None: ... + def __set__( + self, + instance: Model, + value: Optional[Union[Model, F]] + ) -> None: ... def get_object(self, instance: Model) -> Model: ... def get_prefetch_queryset( self, - instances: Any, + instances: List[Model], queryset: Optional[QuerySet] = ... ) -> Tuple[QuerySet, Callable, Callable, bool, str, bool]: ... def get_queryset(self, **hints) -> QuerySet: ... @@ -33,7 +43,7 @@ class ForwardManyToOneDescriptor: class ForwardOneToOneDescriptor: - def __set__(self, instance: Model, value: Any) -> None: ... + def __set__(self, instance: Model, value: Optional[Model]) -> None: ... def get_object(self, instance: Model) -> Model: ... @@ -45,7 +55,7 @@ class ReverseManyToOneDescriptor: def __get__( self, instance: Optional[Model], - cls: Any = ... + cls: Type[Model] = ... ) -> ReverseManyToOneDescriptor: ... def __init__(self, rel: ForeignObjectRel) -> None: ... def _get_set_deprecation_msg_params(self) -> Tuple[str, str]: ... @@ -54,7 +64,11 @@ class ReverseManyToOneDescriptor: class ReverseOneToOneDescriptor: @cached_property def RelatedObjectDoesNotExist(self) -> Type[ObjectDoesNotExist]: ... - def __get__(self, instance: Any, cls: Any = ...) -> Any: ... + def __get__( + self, + instance: Optional[Model], + cls: Type[Model] = ... + ) -> Union[Model, ReverseOneToOneDescriptor]: ... def __init__(self, related: OneToOneRel) -> None: ... def __set__(self, instance: Model, value: Optional[Model]) -> None: ... def get_queryset(self, **hints) -> QuerySet: ... diff --git a/django/db/models/fields/related_lookups.pyi b/django/db/models/fields/related_lookups.pyi index 3aa58a6..00add2e 100644 --- a/django/db/models/fields/related_lookups.pyi +++ b/django/db/models/fields/related_lookups.pyi @@ -32,13 +32,13 @@ class MultiColSource: self, alias: str, targets: Union[Tuple[IntegerField, related.ForeignKey], Tuple[IntegerField, IntegerField]], - sources: Union[Tuple[AutoField, IntegerField], Tuple[IntegerField, AutoField]], + sources: Union[Tuple[IntegerField, AutoField], Tuple[AutoField, IntegerField]], field: related.ForeignObject ) -> None: ... def get_lookup( self, lookup: str - ) -> Type[Union[RelatedIn, RelatedExact]]: ... + ) -> Type[Union[RelatedExact, RelatedIn]]: ... def relabeled_clone( self, relabels: OrderedDict @@ -50,8 +50,8 @@ class RelatedIn: self, compiler: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ... - def get_prep_lookup(self) -> Union[List[UUID], Query, List[int], List[str]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ... + def get_prep_lookup(self) -> Union[Query, List[int], List[UUID], List[str]]: ... class RelatedLookupMixin: @@ -59,5 +59,5 @@ class RelatedLookupMixin: self, compiler: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ... def get_prep_lookup(self) -> Any: ... \ No newline at end of file diff --git a/django/db/models/fields/reverse_related.pyi b/django/db/models/fields/reverse_related.pyi index 3a464e7..0f949f9 100644 --- a/django/db/models/fields/reverse_related.pyi +++ b/django/db/models/fields/reverse_related.pyi @@ -44,7 +44,7 @@ class ForeignObjectRel: def __repr__(self) -> str: ... @property def db_type(self) -> Callable: ... - def get_accessor_name(self, model: Any = ...) -> Optional[str]: ... + def get_accessor_name(self, model: Optional[Type[Model]] = ...) -> Optional[str]: ... def get_cache_name(self) -> str: ... def get_choices( self, @@ -62,7 +62,7 @@ class ForeignObjectRel: def get_lookup( self, lookup_name: str - ) -> Type[Union[RelatedIsNull, RelatedIn, RelatedExact]]: ... + ) -> Type[Union[RelatedIsNull, RelatedExact, RelatedIn]]: ... def get_path_info( self, filtered_relation: Optional[FilteredRelation] = ... @@ -81,7 +81,7 @@ class ForeignObjectRel: @cached_property def one_to_one(self) -> bool: ... @cached_property - def related_model(self) -> Any: ... + def related_model(self) -> Type[Model]: ... @property def remote_field( self diff --git a/django/db/models/functions/text.pyi b/django/db/models/functions/text.pyi index fb600ae..2c5e4a8 100644 --- a/django/db/models/functions/text.pyi +++ b/django/db/models/functions/text.pyi @@ -35,7 +35,7 @@ class Concat: def __init__(self, *expressions, **extra) -> None: ... def _paired( self, - expressions: Union[Tuple[Value, str], Tuple[str, str], Tuple[Value, str, Value]] + expressions: Union[Tuple[Value, str, Value], Tuple[Value, str], Tuple[str, str]] ) -> ConcatPair: ... @@ -75,7 +75,7 @@ class Ord: compiler: SQLCompiler, connection: DatabaseWrapper, **extra_context - ) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ... class Replace: diff --git a/django/db/models/lookups.pyi b/django/db/models/lookups.pyi index b06c5b4..394ef51 100644 --- a/django/db/models/lookups.pyi +++ b/django/db/models/lookups.pyi @@ -7,6 +7,7 @@ from django.db.models.expressions import ( Expression, Ref, ) +from django.db.models.fields.related_lookups import MultiColSource from django.db.models.sql.compiler import SQLCompiler from django.db.models.sql.query import Query from django.utils.datastructures import OrderedSet @@ -34,7 +35,7 @@ class BuiltinLookup: compiler: SQLCompiler, connection: DatabaseWrapper, lhs: Optional[Col] = ... - ) -> Union[Tuple[str, List[str]], Tuple[str, List[int]], Tuple[str, List[Union[str, int]]], Tuple[str, List[Any]]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[Union[str, int]]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ... class Exact: @@ -64,11 +65,11 @@ class FieldGetDbPrepValueIterableMixin: connection: DatabaseWrapper, sql: str, param: Any - ) -> Union[Tuple[str, List[None]], Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[None]], Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ... class FieldGetDbPrepValueMixin: - def get_db_prep_lookup(self, value: Any, connection: DatabaseWrapper) -> Any: ... + def get_db_prep_lookup(self, value: object, connection: DatabaseWrapper) -> Any: ... class IExact: @@ -76,7 +77,7 @@ class IExact: self, qn: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ... class In: @@ -108,7 +109,11 @@ class IsNull: class Lookup: - def __init__(self, lhs: Any, rhs: Any) -> None: ... + def __init__( + self, + lhs: Union[MultiColSource, Expression], + rhs: object + ) -> None: ... def apply_bilateral_transforms( self, value: Expression @@ -130,7 +135,7 @@ class Lookup: ) -> Union[Tuple[str, List[int]], Tuple[str, List[SafeText]], Tuple[str, List[str]]]: ... def get_group_by_cols( self - ) -> Union[List[Col], List[CombinedExpression]]: ... + ) -> Union[List[CombinedExpression], List[Col]]: ... def get_prep_lookup(self) -> Any: ... def get_source_expressions(self) -> List[Col]: ... def process_lhs( @@ -147,7 +152,7 @@ class Lookup: def relabeled_clone( self, relabels: Union[OrderedDict, Dict[str, str], Dict[Union[str, None], str]] - ) -> BuiltinLookup: ... + ) -> Union[IsNull, StartsWith, FieldGetDbPrepValueMixin, IContains]: ... def rhs_is_direct_value(self) -> bool: ... def set_source_expressions(self, new_exprs: List[Ref]) -> None: ... @@ -158,7 +163,7 @@ class PatternLookup: self, qn: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[str]], Tuple[str, List[int]], Tuple[str, List[Any]]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ... class Range: @@ -194,7 +199,7 @@ class YearExact: self, compiler: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ... class YearGt: diff --git a/django/db/models/manager.pyi b/django/db/models/manager.pyi index 5323661..2e18464 100644 --- a/django/db/models/manager.pyi +++ b/django/db/models/manager.pyi @@ -1,3 +1,5 @@ +from django.contrib.admin.models import LogEntry +from django.contrib.auth.models import Permission from django.db.models.base import Model from django.db.models.query import QuerySet from typing import ( @@ -16,16 +18,20 @@ class BaseManager: def __eq__(self, other: Optional[Manager]) -> bool: ... def __init__(self) -> None: ... @staticmethod - def __new__(cls: Any, *args, **kwargs) -> Manager: ... + def __new__(cls: Type[Manager], *args, **kwargs) -> Manager: ... @classmethod - def _get_queryset_methods(cls, queryset_class: Any) -> Dict[str, Callable]: ... + def _get_queryset_methods(cls, queryset_class: Type[QuerySet]) -> Dict[str, Callable]: ... def _set_creation_counter(self) -> None: ... def all(self) -> QuerySet: ... def check(self, **kwargs) -> List[Any]: ... - def contribute_to_class(self, model: Any, name: str) -> None: ... + def contribute_to_class(self, model: Type[Model], name: str) -> None: ... @property def db(self) -> str: ... - def db_manager(self, using: Optional[str] = ..., hints: Any = ...) -> Manager: ... + def db_manager( + self, + using: Optional[str] = ..., + hints: Optional[Union[Dict[str, Model], Dict[str, LogEntry], Dict[str, Permission]]] = ... + ) -> Manager: ... def deconstruct( self ) -> Union[Tuple[bool, str, None, Tuple[str, str, int, int], Dict[Any, Any]], Tuple[bool, str, None, Tuple, Dict[Any, Any]]]: ... diff --git a/django/db/models/options.pyi b/django/db/models/options.pyi index d43dfb3..4655fb9 100644 --- a/django/db/models/options.pyi +++ b/django/db/models/options.pyi @@ -1,7 +1,17 @@ +from django.contrib.contenttypes.fields import GenericForeignKey +from django.db.models.base import Model +from django.db.models.fields import ( + DateTimeCheckMixin, + Field, +) from django.utils.datastructures import ImmutableList from typing import ( Any, Dict, + Optional, + Set, + Type, + Union, ) @@ -11,14 +21,16 @@ class Options: def __str__(self) -> str: ... def _expire_cache(self, forward: bool = ..., reverse: bool = ...) -> None: ... @cached_property - def _forward_fields_map(self) -> Dict[str, Any]: ... + def _forward_fields_map( + self + ) -> Dict[str, Union[GenericForeignKey, Field, DateTimeCheckMixin]]: ... def _get_fields( self, forward: bool = ..., reverse: bool = ..., include_parents: object = ..., include_hidden: bool = ..., - seen_models: Any = ... + seen_models: Optional[Set[Type[Model]]] = ... ) -> ImmutableList: ... def _populate_directed_relation_graph(self) -> Any: ... - def _prepare(self, model: Any) -> None: ... \ No newline at end of file + def _prepare(self, model: Type[Model]) -> None: ... \ No newline at end of file diff --git a/django/db/models/query.pyi b/django/db/models/query.pyi index 72b45f5..b8af3ef 100644 --- a/django/db/models/query.pyi +++ b/django/db/models/query.pyi @@ -6,6 +6,7 @@ from typing import ( Iterator, Optional, Tuple, + Type, Union, ) @@ -37,7 +38,7 @@ class NamedValuesListIterable: class Prefetch: def __eq__(self, other: None) -> bool: ... - def __getstate__(self) -> Dict[str, Union[str, QuerySet, None]]: ... + def __getstate__(self) -> Dict[str, Optional[Union[str, QuerySet]]]: ... def __hash__(self) -> int: ... def __init__( self, @@ -58,7 +59,7 @@ class QuerySet: def __getstate__(self) -> Dict[str, Any]: ... def __init__( self, - model: Any = ..., + model: Type[Model] = ..., query: Optional[Query] = ..., using: Optional[str] = ..., hints: Dict[str, Model] = ... diff --git a/django/db/models/query_utils.pyi b/django/db/models/query_utils.pyi index 89227a8..ad2b1db 100644 --- a/django/db/models/query_utils.pyi +++ b/django/db/models/query_utils.pyi @@ -2,9 +2,16 @@ from collections import OrderedDict from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.models.base import Model from django.db.models.expressions import F -from django.db.models.fields import Field +from django.db.models.fields import ( + DateTimeCheckMixin, + Field, +) from django.db.models.fields.related import ForeignKey from django.db.models.fields.reverse_related import ManyToOneRel +from django.db.models.lookups import ( + Lookup, + Transform, +) from django.db.models.options import Options from django.db.models.sql.compiler import SQLCompiler from django.db.models.sql.query import Query @@ -17,12 +24,13 @@ from typing import ( Optional, Set, Tuple, + Type, Union, ) def check_rel_lookup_compatibility( - model: Any, + model: Type[Model], target_opts: Options, field: Union[ManyToOneRel, ForeignKey] ) -> bool: ... @@ -32,7 +40,7 @@ def refs_expression(lookup_parts: List[str], annotations: OrderedDict) -> Any: . def select_related_descend( - field: Field, + field: Union[Field, DateTimeCheckMixin], restricted: bool, requested: Any, load_fields: Optional[Set[str]], @@ -40,15 +48,17 @@ def select_related_descend( ) -> bool: ... -def subclasses(cls: Any) -> Iterator[Any]: ... +def subclasses( + cls: Type[Union[Field, Transform]] +) -> Iterator[Type[Union[Field, Transform]]]: ... class DeferredAttribute: def __get__( self, - instance: Any, - cls: Any = ... - ) -> Optional[Union[DeferredAttribute, str, int]]: ... + instance: Optional[Model], + cls: Type[Model] = ... + ) -> Optional[Union[str, int, DeferredAttribute]]: ... def __init__(self, field_name: str) -> None: ... def _check_parent_chain(self, instance: Model, name: str) -> None: ... @@ -60,7 +70,7 @@ class FilteredRelation: self, compiler: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[str]], Tuple[str, List[int]], Tuple[str, List[Union[int, str]]], Tuple[str, List[Any]]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]], Tuple[str, List[Union[int, str]]]]: ... def clone(self) -> FilteredRelation: ... @@ -72,7 +82,7 @@ class Q: def _combine(self, other: Q, conn: str) -> Q: ... def deconstruct( self - ) -> Union[Tuple[str, Tuple, Dict[str, F]], Tuple[str, Tuple[Tuple[str, F], Tuple[str, F]], Dict[Any, Any]], Tuple[str, Tuple[Q], Dict[Any, Any]]]: ... + ) -> Union[Tuple[str, Tuple[Tuple[str, F], Tuple[str, F]], Dict[Any, Any]], Tuple[str, Tuple, Dict[str, F]], Tuple[str, Tuple[Q], Dict[Any, Any]]]: ... def resolve_expression( self, query: Query = ..., @@ -98,12 +108,22 @@ class RegisterLookupMixin: @classmethod def _get_lookup(cls, lookup_name: str) -> Any: ... @classmethod - def _unregister_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> None: ... + def _unregister_lookup( + cls, + lookup: Type[Union[Lookup, Transform]], + lookup_name: Optional[str] = ... + ) -> None: ... def get_lookup(self, lookup_name: str) -> Any: ... @classmethod - def get_lookups(cls) -> Dict[str, Any]: ... - def get_transform(self, lookup_name: str) -> Any: ... + def get_lookups(cls) -> Dict[str, Type[Union[Lookup, Transform]]]: ... + def get_transform(self, lookup_name: str) -> object: ... @staticmethod - def merge_dicts(dicts: Any) -> Dict[str, Any]: ... + def merge_dicts( + dicts: Any + ) -> Dict[str, Type[Union[Lookup, Transform]]]: ... @classmethod - def register_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> Any: ... \ No newline at end of file + def register_lookup( + cls, + lookup: Type[Union[Lookup, Transform]], + lookup_name: Optional[str] = ... + ) -> Type[Union[Lookup, Transform]]: ... \ No newline at end of file diff --git a/django/db/models/signals.pyi b/django/db/models/signals.pyi index b68d1f5..0405c13 100644 --- a/django/db/models/signals.pyi +++ b/django/db/models/signals.pyi @@ -1,8 +1,12 @@ from django.apps.registry import Apps +from django.contrib.sites.models import Site +from django.db.models.base import Model from typing import ( Any, Callable, Optional, + Type, + Union, ) @@ -18,7 +22,7 @@ class ModelSignal: def connect( self, receiver: Callable, - sender: Any = ..., + sender: Optional[Union[Type[Site], Type[Model]]] = ..., weak: bool = ..., dispatch_uid: None = ..., apps: None = ... @@ -26,7 +30,7 @@ class ModelSignal: def disconnect( self, receiver: Callable = ..., - sender: Any = ..., + sender: Optional[Type[Model]] = ..., dispatch_uid: None = ..., apps: None = ... ) -> bool: ... \ No newline at end of file diff --git a/django/db/models/sql/compiler.pyi b/django/db/models/sql/compiler.pyi index 8c3ee58..3ba71a3 100644 --- a/django/db/models/sql/compiler.pyi +++ b/django/db/models/sql/compiler.pyi @@ -1,5 +1,6 @@ from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.utils import CursorWrapper +from django.db.models.base import Model from django.db.models.expressions import ( Col, CombinedExpression, @@ -21,6 +22,7 @@ from typing import ( Optional, Set, Tuple, + Type, Union, ) @@ -44,14 +46,14 @@ class SQLCompiler: alias: str, columns: List[str], compiler: SQLCompiler - ) -> Union[Tuple[str, Tuple[str]], Tuple[str, Tuple]]: ... + ) -> Union[Tuple[str, Tuple], Tuple[str, Tuple[str]]]: ... def collapse_group_by( self, - expressions: Union[List[Col], List[Union[Col, Trunc]], List[Expression], List[Union[Col, CombinedExpression]]], - having: Union[List[Col], Tuple, List[CombinedExpression]] - ) -> Union[List[Col], List[Union[Col, Trunc]], List[Expression], List[Union[Col, CombinedExpression]]]: ... + expressions: Union[List[Union[Col, CombinedExpression]], List[Expression], List[Col], List[Union[Col, Trunc]]], + having: Union[List[CombinedExpression], List[Col], Tuple] + ) -> Union[List[Union[Col, CombinedExpression]], List[Expression], List[Col], List[Union[Col, Trunc]]]: ... def compile(self, node: Any, select_format: object = ...) -> Any: ... - def deferred_to_columns(self) -> Any: ... + def deferred_to_columns(self) -> Dict[Type[Model], Set[str]]: ... def execute_sql( self, result_type: str = ..., @@ -65,7 +67,7 @@ class SQLCompiler: opts: Options, alias: Optional[str] = ..., default_order: str = ..., - already_seen: Optional[Union[Set[Tuple[None, Tuple[Tuple[str, str]]]], Set[Tuple[None, Tuple[Tuple[str, str]], Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]], Set[Union[Tuple[None, Tuple[Tuple[str, str]]], Tuple[Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]]]]] = ... + already_seen: Optional[Union[Set[Tuple[None, Tuple[Tuple[str, str]]]], Set[Union[Tuple[None, Tuple[Tuple[str, str]]], Tuple[Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]]], Set[Tuple[None, Tuple[Tuple[str, str]], Tuple[Tuple[str, str]], Tuple[Tuple[str, str]]]]]] = ... ) -> List[Tuple[OrderBy, bool]]: ... def get_combinator_sql( self, @@ -77,22 +79,22 @@ class SQLCompiler: self, start_alias: Optional[str] = ..., opts: Optional[Options] = ..., - from_parent: Any = ... + from_parent: Optional[Type[Model]] = ... ) -> List[Col]: ... def get_distinct(self) -> Tuple[List[Any], List[Any]]: ... def get_extra_select( self, - order_by: Union[List[Tuple[OrderBy, Tuple[str, List[Any], bool]]], List[Union[Tuple[OrderBy, Tuple[str, List[int], bool]], Tuple[OrderBy, Tuple[str, List[Any], bool]]]], List[Tuple[OrderBy, Tuple[str, Tuple, bool]]]], + order_by: Union[List[Tuple[OrderBy, Tuple[str, List[Any], bool]]], List[Tuple[OrderBy, Tuple[str, Tuple, bool]]], List[Union[Tuple[OrderBy, Tuple[str, List[int], bool]], Tuple[OrderBy, Tuple[str, List[Any], bool]]]]], select: Any ) -> List[Tuple[OrderBy, Tuple[str, List[Any]], None]]: ... def get_from_clause( self - ) -> Union[Tuple[List[str], List[Union[int, str]]], Tuple[List[str], List[Any]], Tuple[List[str], List[int]], Tuple[List[str], List[str]]]: ... + ) -> Union[Tuple[List[str], List[Any]], Tuple[List[str], List[Union[int, str]]], Tuple[List[str], List[int]], Tuple[List[str], List[str]]]: ... def get_group_by( self, select: Any, order_by: Any - ) -> Union[List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]], List[Tuple[str, List[Any]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[int]]]]]: ... + ) -> Union[List[Tuple[str, List[Any]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[int]]]]]: ... def get_order_by(self) -> Any: ... def get_related_selections( self, @@ -102,7 +104,7 @@ class SQLCompiler: cur_depth: int = ..., requested: Any = ..., restricted: Optional[bool] = ... - ) -> Any: ... + ) -> List[Dict[str, Any]]: ... def get_select(self) -> Any: ... def has_results(self) -> bool: ... def pre_sql_setup(self) -> Any: ... diff --git a/django/db/models/sql/datastructures.pyi b/django/db/models/sql/datastructures.pyi index affaddd..a87d8e7 100644 --- a/django/db/models/sql/datastructures.pyi +++ b/django/db/models/sql/datastructures.pyi @@ -31,7 +31,7 @@ class BaseTable: class Join: def __eq__( self, - other: Union[Join, BaseTable] + other: Union[BaseTable, Join] ) -> bool: ... def __init__( self, @@ -47,17 +47,17 @@ class Join: self, compiler: SQLCompiler, connection: DatabaseWrapper - ) -> Union[Tuple[str, List[int]], Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[int]], Tuple[str, List[str]], Tuple[str, List[Any]]]: ... def demote(self) -> Join: ... def equals( self, - other: Union[Join, BaseTable], + other: Union[BaseTable, Join], with_filtered_relation: bool ) -> bool: ... def promote(self) -> Join: ... def relabeled_clone( self, - change_map: Union[Dict[str, str], OrderedDict] + change_map: Union[OrderedDict, Dict[str, str]] ) -> Join: ... diff --git a/django/db/models/sql/query.pyi b/django/db/models/sql/query.pyi index 170692b..fc426ea 100644 --- a/django/db/models/sql/query.pyi +++ b/django/db/models/sql/query.pyi @@ -1,6 +1,6 @@ +from django.db.models.base import Model from django.db.models.sql.where import WhereNode from typing import ( - Any, Set, Tuple, Type, @@ -10,9 +10,13 @@ from typing import ( class JoinPromoter: def __init__(self, connector: str, num_children: int, negated: bool) -> None: ... - def add_votes(self, votes: Union[Tuple, Set[str]]) -> None: ... + def add_votes(self, votes: Union[Set[str], Tuple]) -> None: ... def update_join_types(self, query: Query) -> Set[str]: ... class Query: - def __init__(self, model: Any, where: Type[WhereNode] = ...) -> None: ... \ No newline at end of file + def __init__( + self, + model: Type[Model], + where: Type[WhereNode] = ... + ) -> None: ... \ No newline at end of file diff --git a/django/db/models/sql/subqueries.pyi b/django/db/models/sql/subqueries.pyi index cebf397..957dd0d 100644 --- a/django/db/models/sql/subqueries.pyi +++ b/django/db/models/sql/subqueries.pyi @@ -41,4 +41,4 @@ class UpdateQuery: def add_update_values(self, values: Dict[str, Any]) -> None: ... def clone(self) -> UpdateQuery: ... def get_related_updates(self) -> List[UpdateQuery]: ... - def update_batch(self, pk_list: List[int], values: Dict[str, Union[None, int]], using: str) -> None: ... \ No newline at end of file + def update_batch(self, pk_list: List[int], values: Dict[str, Optional[int]], using: str) -> None: ... \ No newline at end of file diff --git a/django/db/models/sql/where.pyi b/django/db/models/sql/where.pyi index 14173b1..05f8fca 100644 --- a/django/db/models/sql/where.pyi +++ b/django/db/models/sql/where.pyi @@ -79,7 +79,7 @@ class WhereNode: ) -> Union[List[CombinedExpression], List[Col]]: ... def get_source_expressions( self - ) -> Union[List[GreaterThan], List[IntegerLessThan], List[Exact], List[LessThanOrEqual]]: ... + ) -> Union[List[GreaterThan], List[LessThanOrEqual], List[Exact], List[IntegerLessThan]]: ... def relabel_aliases( self, change_map: Union[OrderedDict, Dict[str, str], Dict[Union[str, None], str]] @@ -96,4 +96,4 @@ class WhereNode: def split_having( self, negated: bool = ... - ) -> Union[Tuple[WhereNode, None], Tuple[None, WhereNode], Tuple[WhereNode, WhereNode]]: ... \ No newline at end of file + ) -> Union[Tuple[None, WhereNode], Tuple[WhereNode, WhereNode], Tuple[WhereNode, None]]: ... \ No newline at end of file diff --git a/django/db/utils.pyi b/django/db/utils.pyi index 2330f26..7b1964f 100644 --- a/django/db/utils.pyi +++ b/django/db/utils.pyi @@ -1,4 +1,7 @@ from django.apps.config import AppConfig +from django.contrib.contenttypes.models import ContentType +from django.contrib.sessions.models import Session +from django.contrib.sites.models import Site from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.models.base import Model @@ -7,6 +10,8 @@ from typing import ( Callable, Dict, List, + Type, + Union, ) @@ -27,16 +32,16 @@ class ConnectionHandler: class ConnectionRouter: def __init__(self, routers: None = ...) -> None: ... def allow_migrate(self, db: str, app_label: str, **hints) -> bool: ... - def allow_migrate_model(self, db: str, model: Any) -> bool: ... + def allow_migrate_model(self, db: str, model: Type[Model]) -> bool: ... def allow_relation(self, obj1: Model, obj2: Model, **hints) -> bool: ... def get_migratable_models( self, app_config: AppConfig, db: str, include_auto_created: bool = ... - ) -> Any: ... + ) -> Union[List[Type[Model]], List[Type[Site]], List[Type[Session]], List[Type[ContentType]]]: ... @cached_property - def routers(self) -> Any: ... + def routers(self) -> List[object]: ... class DatabaseErrorWrapper: diff --git a/django/dispatch/dispatcher.pyi b/django/dispatch/dispatcher.pyi index 6e6b022..6e04c74 100644 --- a/django/dispatch/dispatcher.pyi +++ b/django/dispatch/dispatcher.pyi @@ -1,4 +1,4 @@ -from dispatch.tests import Callable +from django.db.models.base import Model from functools import partial from typing import ( Any, @@ -6,6 +6,7 @@ from typing import ( List, Optional, Tuple, + Type, Union, ) @@ -13,10 +14,7 @@ from typing import ( class Signal: def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ... def _clear_dead_receivers(self) -> None: ... - def _live_receivers( - self, - sender: object - ) -> Union[List[Callable], List[object], List[Callable], List[partial]]: ... + def _live_receivers(self, sender: object) -> Union[List[partial], List[Callable], List[object]]: ... def _remove_receiver(self, receiver: None = ...) -> None: ... def connect( self, @@ -32,4 +30,8 @@ class Signal: dispatch_uid: Optional[str] = ... ) -> bool: ... def has_listeners(self, sender: object = ...) -> bool: ... - def send(self, sender: Any, **named) -> Union[List[Tuple[Callable, None]], List[Tuple[object, None]]]: ... \ No newline at end of file + def send( + self, + sender: Type[Model], + **named + ) -> Union[List[Tuple[object, None]], List[Tuple[Callable, None]]]: ... \ No newline at end of file diff --git a/django/forms/boundfield.pyi b/django/forms/boundfield.pyi index a5fba5b..ec29a4f 100644 --- a/django/forms/boundfield.pyi +++ b/django/forms/boundfield.pyi @@ -1,11 +1,13 @@ from django.forms.fields import Field -from django.forms.forms import BaseForm +from django.forms.forms import Form +from django.forms.models import ModelForm from django.forms.renderers import DjangoTemplates from django.forms.utils import ErrorList from django.forms.widgets import ( ChoiceWidget, HiddenInput, SplitHiddenDateTimeWidget, + Widget, ) from django.utils.safestring import SafeText from typing import ( @@ -20,9 +22,14 @@ from typing import ( class BoundField: def __getitem__( self, - idx: Union[str, slice, int] - ) -> Union[BoundWidget, List[BoundWidget]]: ... - def __init__(self, form: BaseForm, field: Field, name: str) -> None: ... + idx: Union[slice, str, int] + ) -> Union[List[BoundWidget], BoundWidget]: ... + def __init__( + self, + form: Union[Form, ModelForm], + field: Field, + name: str + ) -> None: ... def __len__(self) -> int: ... def as_hidden(self, attrs: None = ..., **kwargs) -> SafeText: ... def as_text(self, attrs: None = ..., **kwargs) -> SafeText: ... @@ -35,7 +42,11 @@ class BoundField: ) -> SafeText: ... @property def auto_id(self) -> str: ... - def build_widget_attrs(self, attrs: Dict[str, str], widget: Any = ...) -> Dict[str, Union[bool, str]]: ... + def build_widget_attrs( + self, + attrs: Dict[str, str], + widget: Optional[Widget] = ... + ) -> Dict[str, Union[bool, str]]: ... def css_classes(self, extra_classes: None = ...) -> str: ... @property def data(self) -> Any: ... diff --git a/django/forms/fields.pyi b/django/forms/fields.pyi index 7d28556..a8f6feb 100644 --- a/django/forms/fields.pyi +++ b/django/forms/fields.pyi @@ -8,10 +8,12 @@ from decimal import Decimal from django.core.files.uploadedfile import SimpleUploadedFile from django.db.models.fields.files import FieldFile from django.forms.boundfield import BoundField -from django.forms.forms import BaseForm +from django.forms.forms import Form +from django.forms.models import ModelForm from django.forms.widgets import ( ClearableFileInput, Input, + Textarea, Widget, ) from typing import ( @@ -51,8 +53,8 @@ class CharField: empty_value = ..., **kwargs ) -> None: ... - def to_python(self, value: Optional[Union[int, Tuple, str]]) -> Optional[str]: ... - def widget_attrs(self, widget: Widget) -> Dict[str, str]: ... + def to_python(self, value: Optional[Union[int, str, Tuple]]) -> Optional[str]: ... + def widget_attrs(self, widget: Union[Textarea, Input]) -> Dict[str, str]: ... class ChoiceField: @@ -122,9 +124,13 @@ class Field: disabled = ..., label_suffix = ... ) -> None: ... - def bound_data(self, data: Any, initial: Any) -> Any: ... + def bound_data(self, data: Any, initial: Optional[Union[str, float, datetime]]) -> Any: ... def clean(self, value: Any) -> Any: ... - def get_bound_field(self, form: BaseForm, field_name: str) -> BoundField: ... + def get_bound_field( + self, + form: Union[Form, ModelForm], + field_name: str + ) -> BoundField: ... def has_changed(self, initial: Any, data: Optional[str]) -> bool: ... def prepare_value(self, value: Any) -> Any: ... def run_validators(self, value: Any) -> None: ... @@ -142,7 +148,7 @@ class FileField: ) -> Union[str, SimpleUploadedFile]: ... def clean( self, - data: Optional[Union[str, bool, SimpleUploadedFile]], + data: Optional[Union[bool, str, SimpleUploadedFile]], initial: Optional[Union[str, FieldFile]] = ... ) -> Any: ... def has_changed(self, initial: Union[str, FieldFile], data: Optional[str]) -> bool: ... @@ -182,22 +188,22 @@ class ImageField: class IntegerField: def __init__(self, *, max_value = ..., min_value = ..., **kwargs) -> None: ... - def to_python(self, value: Optional[Union[float, int, str]]) -> Optional[int]: ... - def widget_attrs(self, widget: Input) -> Dict[str, Union[Decimal, int]]: ... + def to_python(self, value: Optional[Union[str, float]]) -> Optional[int]: ... + def widget_attrs(self, widget: Input) -> Dict[str, Union[int, Decimal]]: ... class MultiValueField: def __deepcopy__(self, memo: Dict[int, Any]) -> MultiValueField: ... def __init__( self, - fields: Union[Tuple[DateField, TimeField], Tuple[CharField, MultipleChoiceField, SplitDateTimeField], Tuple[CharField, CharField]], + fields: Union[Tuple[CharField, MultipleChoiceField, SplitDateTimeField], Tuple[DateField, TimeField], Tuple[CharField, CharField]], *, require_all_fields = ..., **kwargs ) -> None: ... def clean( self, - value: Union[str, List[Union[str, List[str]]], List[str]] + value: Union[str, List[str], List[Union[str, List[str]]]] ) -> Optional[Union[str, datetime]]: ... def has_changed( self, @@ -209,7 +215,7 @@ class MultiValueField: class MultipleChoiceField: def has_changed(self, initial: Optional[Union[str, List[int]]], data: Union[str, List[str]]) -> bool: ... - def to_python(self, value: Optional[Union[Tuple, str, List[str]]]) -> List[str]: ... + def to_python(self, value: Optional[Union[str, List[str], Tuple]]) -> List[str]: ... def validate(self, value: List[str]) -> None: ... @@ -239,14 +245,14 @@ class TimeField: class TypedChoiceField: def __init__(self, *, coerce = ..., empty_value = ..., **kwargs) -> None: ... - def _coerce(self, value: Optional[Union[str, int]]) -> Optional[Union[int, str]]: ... + def _coerce(self, value: Optional[Union[str, int]]) -> Optional[Union[str, int]]: ... def clean(self, value: Optional[str]) -> Optional[Union[str, int]]: ... class TypedMultipleChoiceField: def __init__(self, *, coerce = ..., **kwargs) -> None: ... def _coerce(self, value: List[str]) -> Optional[Union[List[Decimal], List[int]]]: ... - def clean(self, value: List[str]) -> Optional[Union[List[bool], List[int]]]: ... + def clean(self, value: List[str]) -> Optional[Union[List[int], List[bool]]]: ... def validate(self, value: List[str]) -> None: ... diff --git a/django/forms/forms.pyi b/django/forms/forms.pyi index 873bdd1..5c1f880 100644 --- a/django/forms/forms.pyi +++ b/django/forms/forms.pyi @@ -23,7 +23,7 @@ class BaseForm: def __init__( self, data: Any = ..., - files: Optional[Union[Dict[str, SimpleUploadedFile], MultiValueDict]] = ..., + files: Optional[Union[MultiValueDict, Dict[str, SimpleUploadedFile]]] = ..., auto_id: Optional[Union[str, bool]] = ..., prefix: Optional[str] = ..., initial: Any = ..., diff --git a/django/forms/models.pyi b/django/forms/models.pyi index f7bbea1..3884c32 100644 --- a/django/forms/models.pyi +++ b/django/forms/models.pyi @@ -1,4 +1,8 @@ from collections import OrderedDict +from django.contrib.auth.forms import ( + UserChangeForm, + UserCreationForm, +) from django.core.exceptions import ValidationError from django.core.files.uploadedfile import SimpleUploadedFile from django.db.models.base import Model @@ -21,8 +25,8 @@ from uuid import UUID def _get_foreign_key( - parent_model: Any, - model: Any, + parent_model: Type[Model], + model: Type[Model], fk_name: Optional[str] = ..., can_fail: bool = ... ) -> ForeignKey: ... @@ -42,7 +46,7 @@ class BaseModelForm: error_class: Type[ErrorList] = ..., label_suffix: None = ..., empty_permitted: bool = ..., - instance: Any = ..., + instance: Optional[Model] = ..., use_required_attribute: None = ..., renderer: None = ... ) -> None: ... @@ -88,17 +92,17 @@ class ModelChoiceField: def _get_queryset(self) -> QuerySet: ... def _set_queryset(self, queryset: Union[QuerySet, Manager]) -> None: ... def get_limit_choices_to(self) -> Any: ... - def has_changed(self, initial: Optional[Union[int, UUID]], data: Optional[Union[str, int]]) -> bool: ... + def has_changed(self, initial: Optional[Union[UUID, int]], data: Optional[Union[str, int]]) -> bool: ... def label_from_instance(self, obj: Model) -> str: ... - def prepare_value(self, value: Any) -> Optional[Union[UUID, str, int]]: ... - def to_python(self, value: Optional[Union[str, List[List[str]], int]]) -> Any: ... - def validate(self, value: Any) -> None: ... + def prepare_value(self, value: Any) -> Optional[Union[str, UUID, int]]: ... + def to_python(self, value: Optional[Union[str, List[List[str]], int]]) -> Optional[Model]: ... + def validate(self, value: Optional[Model]) -> None: ... class ModelChoiceIterator: def __bool__(self) -> bool: ... def __init__(self, field: ModelChoiceField) -> None: ... - def __iter__(self) -> Iterator[Union[Tuple[int, str], Tuple[str, str]]]: ... + def __iter__(self) -> Iterator[Union[Tuple[str, str], Tuple[int, str]]]: ... def __len__(self) -> int: ... def choice(self, obj: Model) -> Tuple[int, str]: ... @@ -110,11 +114,14 @@ class ModelFormMetaclass: name: str, bases: Tuple[Type[ModelForm]], attrs: OrderedDict - ) -> Any: ... + ) -> Type[ModelForm]: ... class ModelFormOptions: - def __init__(self, options: Any = ...) -> None: ... + def __init__( + self, + options: Optional[Union[Type[object], Type[UserChangeForm.Meta], Type[UserCreationForm.Meta]]] = ... + ) -> None: ... class ModelMultipleChoiceField: @@ -123,7 +130,7 @@ class ModelMultipleChoiceField: self, value: Union[List[int], Tuple[int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int], List[str]] ) -> QuerySet: ... - def clean(self, value: Union[List[List[str]], str, List[int], List[str]]) -> QuerySet: ... + def clean(self, value: Union[List[List[str]], List[int], str, List[str]]) -> QuerySet: ... def has_changed(self, initial: List[Model], data: List[str]) -> bool: ... def prepare_value(self, value: Any) -> Any: ... def to_python( diff --git a/django/forms/utils.pyi b/django/forms/utils.pyi index 4adffa9..a54cc83 100644 --- a/django/forms/utils.pyi +++ b/django/forms/utils.pyi @@ -12,7 +12,7 @@ from typing import ( ) -def flatatt(attrs: Dict[str, Union[str, None]]) -> SafeText: ... +def flatatt(attrs: Dict[str, Optional[str]]) -> SafeText: ... def from_current_timezone(value: datetime) -> datetime: ... @@ -33,11 +33,11 @@ class ErrorDict: class ErrorList: def __contains__(self, item: str) -> bool: ... - def __eq__(self, other: Union[List[str], ErrorList]) -> bool: ... + def __eq__(self, other: Union[ErrorList, List[str]]) -> bool: ... def __getitem__(self, i: Union[str, int]) -> str: ... def __init__( self, - initlist: Optional[Union[List[ValidationError], ErrorList, List[str]]] = ..., + initlist: Optional[Union[ErrorList, List[str], List[ValidationError]]] = ..., error_class: Optional[str] = ... ) -> None: ... def __reduce_ex__( diff --git a/django/forms/widgets.pyi b/django/forms/widgets.pyi index 17b0ba3..d680267 100644 --- a/django/forms/widgets.pyi +++ b/django/forms/widgets.pyi @@ -30,18 +30,18 @@ class CheckboxInput: def get_context( self, name: str, - value: Optional[Union[str, int]], - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] - ) -> Dict[str, Any]: ... + value: Optional[Union[int, str]], + attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] + ) -> Dict[str, Dict[str, Any]]: ... def value_from_datadict( self, data: Any, - files: Union[Dict[str, SimpleUploadedFile], MultiValueDict], + files: Union[MultiValueDict, Dict[str, SimpleUploadedFile]], name: str ) -> bool: ... def value_omitted_from_data( self, - data: Union[Dict[str, str], Dict[str, Union[str, List[int]]], Dict[str, Union[int, str, None, datetime]], QueryDict], + data: Union[Dict[str, Union[str, List[int]]], Dict[str, str], Dict[str, Union[int, str, None, datetime]], QueryDict], files: MultiValueDict, name: str ) -> bool: ... @@ -68,30 +68,30 @@ class ChoiceWidget: selected: Union[bool, Set[str]], index: int, subindex: Optional[int] = ..., - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] = ... + attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] = ... ) -> Dict[str, Any]: ... def format_value(self, value: Any) -> List[str]: ... def get_context( self, name: str, value: Any, - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] - ) -> Dict[str, Any]: ... + attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] + ) -> Dict[str, Dict[str, Any]]: ... def id_for_label(self, id_: str, index: str = ...) -> str: ... def optgroups( self, name: str, value: List[str], - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] = ... + attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] = ... ) -> Any: ... def options(self, name: str, value: List[str], attrs: Dict[str, Union[bool, str]] = ...) -> None: ... def subwidgets(self, name: str, value: Optional[List[str]], attrs: Dict[str, Union[bool, str]] = ...) -> None: ... def value_from_datadict( self, - data: Any, + data: dict, files: MultiValueDict, name: str - ) -> Optional[Union[str, int, List[str]]]: ... + ) -> Optional[Union[str, List[str], int]]: ... class ClearableFileInput: @@ -101,12 +101,12 @@ class ClearableFileInput: self, value: Optional[Union[str, FieldFile]] ) -> Optional[FieldFile]: ... - def is_initial(self, value: Any) -> bool: ... + def is_initial(self, value: object) -> bool: ... def use_required_attribute(self, initial: Optional[FieldFile]) -> bool: ... def value_from_datadict( self, - data: Union[Dict[str, bool], Dict[str, str], Dict[str, None], QueryDict], - files: Dict[str, Union[str, SimpleUploadedFile]], + data: Union[Dict[str, bool], Dict[str, None], Dict[str, str], QueryDict], + files: Dict[str, Union[SimpleUploadedFile, str]], name: str ) -> Optional[Union[str, SimpleUploadedFile]]: ... def value_omitted_from_data(self, data: Dict[str, str], files: Dict[Any, Any], name: str) -> bool: ... @@ -121,26 +121,26 @@ class FileInput: def format_value(self, value: None) -> None: ... def value_from_datadict( self, - data: Union[Dict[str, bool], Dict[str, str], QueryDict], + data: Union[Dict[str, str], Dict[str, bool], QueryDict], files: Dict[str, SimpleUploadedFile], name: str ) -> Optional[SimpleUploadedFile]: ... def value_omitted_from_data( self, data: Dict[Any, Any], - files: Dict[str, Union[str, SimpleUploadedFile]], + files: Dict[str, Union[SimpleUploadedFile, str]], name: str ) -> bool: ... class Input: - def __init__(self, attrs: Optional[Union[Dict[str, str], Dict[str, bool], Dict[str, int]]] = ...) -> None: ... + def __init__(self, attrs: Optional[Union[Dict[str, int], Dict[str, str], Dict[str, bool]]] = ...) -> None: ... def get_context( self, name: str, value: Any, - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] - ) -> Dict[str, Any]: ... + attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] + ) -> Dict[str, Dict[str, Any]]: ... class Media: @@ -149,13 +149,13 @@ class Media: def __init__( self, media: Optional[Type[object]] = ..., - css: Optional[Union[Dict[str, Tuple[str, str]], Dict[str, Tuple[str]], Dict[str, List[str]]]] = ..., + css: Optional[Union[Dict[str, Tuple[str, str]], Dict[str, List[str]], Dict[str, Tuple[str]]]] = ..., js: Any = ... ) -> None: ... def __repr__(self) -> str: ... def absolute_path(self, path: str) -> str: ... @staticmethod - def merge(list_1: Union[List[str], Tuple[str], List[int]], list_2: Any) -> Union[List[int], List[str]]: ... + def merge(list_1: Union[List[int], List[str], Tuple[str]], list_2: Any) -> Union[List[int], List[str]]: ... def render(self) -> SafeText: ... def render_css(self) -> chain: ... def render_js(self) -> List[SafeText]: ... @@ -163,7 +163,7 @@ class Media: class MediaDefiningClass: @staticmethod - def __new__(mcs: Type[MediaDefiningClass], name: str, bases: Tuple, attrs: Any) -> Any: ... + def __new__(mcs: Type[MediaDefiningClass], name: str, bases: Tuple, attrs: Any) -> Type[Any]: ... class MultiWidget: @@ -174,8 +174,8 @@ class MultiWidget: self, name: str, value: Optional[Union[str, datetime, List[str]]], - attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, str]]] - ) -> Dict[str, Any]: ... + attrs: Optional[Union[Dict[str, Union[str, bool]], Dict[str, str]]] + ) -> Dict[str, Dict[str, Any]]: ... def id_for_label(self, id_: str) -> str: ... @property def is_hidden(self) -> bool: ... @@ -209,7 +209,7 @@ class MultipleHiddenInput: class NullBooleanSelect: def __init__(self, attrs: None = ...) -> None: ... def format_value(self, value: Optional[str]) -> str: ... - def value_from_datadict(self, data: Dict[str, Union[bool, str]], files: Dict[Any, Any], name: str) -> Optional[bool]: ... + def value_from_datadict(self, data: Dict[str, Union[str, bool]], files: Dict[Any, Any], name: str) -> Optional[bool]: ... class PasswordInput: @@ -218,7 +218,7 @@ class PasswordInput: self, name: str, value: Optional[str], - attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool]]] + attrs: Optional[Union[Dict[str, Union[str, bool]], Dict[str, bool]]] ) -> Dict[str, Dict[str, Any]]: ... @@ -229,8 +229,8 @@ class Select: self, name: str, value: Any, - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] - ) -> Dict[str, Any]: ... + attrs: Optional[Union[Dict[str, Union[str, bool]], Dict[str, bool], Dict[str, str]]] + ) -> Dict[str, Dict[str, Any]]: ... def use_required_attribute(self, initial: Any) -> bool: ... @@ -244,7 +244,7 @@ class SelectDateWidget: ) -> None: ... @staticmethod def _parse_date_fmt() -> Iterator[str]: ... - def format_value(self, value: Optional[Union[str, date]]) -> Dict[str, Union[None, int, str]]: ... + def format_value(self, value: Optional[Union[str, date]]) -> Dict[str, Optional[Union[str, int]]]: ... def value_from_datadict(self, data: Dict[str, str], files: Dict[Any, Any], name: str) -> Optional[str]: ... def value_omitted_from_data(self, data: Dict[str, str], files: Dict[Any, Any], name: str) -> bool: ... @@ -255,7 +255,7 @@ class SelectMultiple: data: Any, files: MultiValueDict, name: str - ) -> Optional[Union[str, List[int], List[str]]]: ... + ) -> Optional[Union[List[int], str, List[str]]]: ... def value_omitted_from_data(self, data: Dict[Any, Any], files: Dict[Any, Any], name: str) -> bool: ... @@ -271,7 +271,7 @@ class SplitDateTimeWidget: def decompress( self, value: Optional[datetime] - ) -> Union[List[None], List[Union[date, time]]]: ... + ) -> Union[List[Union[date, time]], List[None]]: ... class SplitHiddenDateTimeWidget: @@ -286,7 +286,7 @@ class SplitHiddenDateTimeWidget: class Textarea: - def __init__(self, attrs: Optional[Union[Dict[str, str], Dict[str, int]]] = ...) -> None: ... + def __init__(self, attrs: Optional[Union[Dict[str, int], Dict[str, str]]] = ...) -> None: ... class Widget: @@ -300,13 +300,13 @@ class Widget: ) -> SafeText: ... def build_attrs( self, - base_attrs: Dict[str, Union[str, int, float]], - extra_attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] = ... - ) -> Dict[str, Union[str, int, float]]: ... + base_attrs: Dict[str, Union[float, str]], + extra_attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] = ... + ) -> Dict[str, Union[float, str]]: ... def format_value(self, value: Any) -> Optional[str]: ... def get_context( self, name: str, value: Any, - attrs: Optional[Union[Dict[str, bool], Dict[str, Union[bool, str]], Dict[str, str]]] - ) -> Dict[str, Any]: ... \ No newline at end of file + attrs: Optional[Union[Dict[str, Union[bool, str]], Dict[str, bool], Dict[str, str]]] + ) -> Dict[str, Dict[str, Any]]: ... \ No newline at end of file diff --git a/django/http/multipartparser.pyi b/django/http/multipartparser.pyi index 7e733b2..3f50e8d 100644 --- a/django/http/multipartparser.pyi +++ b/django/http/multipartparser.pyi @@ -25,7 +25,7 @@ def exhaust(stream_or_iterable: Union[BytesIO, WSGIRequest]) -> None: ... def parse_boundary_stream( stream: LazyStream, max_header_size: int -) -> Union[Tuple[str, Dict[Any, Any], LazyStream], Tuple[str, Dict[str, Tuple[str, Dict[str, bytes]]], LazyStream], Tuple[str, Dict[str, Union[Tuple[str, Dict[str, bytes]], Tuple[str, Dict[Any, Any]]]], LazyStream], Tuple[str, Dict[str, Union[Tuple[str, Dict[str, str]], Tuple[str, Dict[Any, Any]]]], LazyStream]]: ... +) -> Union[Tuple[str, Dict[str, Union[Tuple[str, Dict[str, bytes]], Tuple[str, Dict[Any, Any]]]], LazyStream], Tuple[str, Dict[str, Tuple[str, Dict[str, bytes]]], LazyStream], Tuple[str, Dict[Any, Any], LazyStream], Tuple[str, Dict[str, Union[Tuple[str, Dict[str, str]], Tuple[str, Dict[Any, Any]]]], LazyStream]]: ... def parse_header(line: bytes) -> Union[Tuple[str, Dict[Any, Any]], Tuple[str, Dict[str, bytes]]]: ... @@ -79,4 +79,4 @@ class Parser: def __init__(self, stream: LazyStream, boundary: bytes) -> None: ... def __iter__( self - ) -> Iterator[Union[Tuple[str, Dict[Any, Any], LazyStream], Tuple[str, Dict[str, Tuple[str, Dict[str, bytes]]], LazyStream], Tuple[str, Dict[str, Union[Tuple[str, Dict[str, bytes]], Tuple[str, Dict[Any, Any]]]], LazyStream]]]: ... \ No newline at end of file + ) -> Iterator[Union[Tuple[str, Dict[Any, Any], LazyStream], Tuple[str, Dict[str, Union[Tuple[str, Dict[str, bytes]], Tuple[str, Dict[Any, Any]]]], LazyStream], Tuple[str, Dict[str, Tuple[str, Dict[str, bytes]]], LazyStream]]]: ... \ No newline at end of file diff --git a/django/http/response.pyi b/django/http/response.pyi index 00d193c..2724dec 100644 --- a/django/http/response.pyi +++ b/django/http/response.pyi @@ -7,7 +7,6 @@ from django.core.files.base import ContentFile from django.core.serializers.json import DjangoJSONEncoder from tempfile import _TemporaryFileWrapper from typing import ( - Any, Dict, List, Optional, @@ -21,13 +20,13 @@ class FileResponse: def __init__(self, *args, as_attachment = ..., filename = ..., **kwargs) -> None: ... def _set_streaming_content( self, - value: Union[BufferedReader, _TemporaryFileWrapper, ContentFile] + value: Union[_TemporaryFileWrapper, BufferedReader, ContentFile] ) -> None: ... - def set_headers(self, filelike: Union[BufferedReader, BytesIO, _TemporaryFileWrapper]) -> None: ... + def set_headers(self, filelike: Union[_TemporaryFileWrapper, BufferedReader, BytesIO]) -> None: ... class HttpResponse: - def __init__(self, content: Any = ..., *args, **kwargs) -> None: ... + def __init__(self, content: Union[int, TextIOWrapper, bytes, str] = ..., *args, **kwargs) -> None: ... def __repr__(self) -> str: ... def getvalue(self) -> bytes: ... def writable(self) -> bool: ... @@ -53,7 +52,7 @@ class HttpResponseBase: def delete_cookie(self, key: str, path: str = ..., domain: Optional[str] = ...) -> None: ... def get(self, header: str, alternate: Optional[Union[str, Tuple]] = ...) -> Optional[Union[str, Tuple]]: ... def has_header(self, header: str) -> bool: ... - def make_bytes(self, value: Union[str, bytes, int]) -> bytes: ... + def make_bytes(self, value: Union[bytes, int, str]) -> bytes: ... def seekable(self) -> bool: ... def serialize_headers(self) -> bytes: ... def set_cookie( @@ -92,7 +91,7 @@ class HttpResponseRedirectBase: class JsonResponse: def __init__( self, - data: Dict[str, Union[Dict[str, str], str, List[Dict[str, str]], Dict[str, bool]]], + data: Dict[str, Union[Dict[str, bool], str, Dict[str, str], List[Dict[str, str]]]], encoder: Type[DjangoJSONEncoder] = ..., safe: bool = ..., json_dumps_params: None = ..., @@ -103,11 +102,11 @@ class JsonResponse: class StreamingHttpResponse: def __init__( self, - streaming_content: Union[List[str], BufferedReader, str, _TemporaryFileWrapper] = ..., + streaming_content: Union[_TemporaryFileWrapper, BufferedReader, str, List[str]] = ..., *args, **kwargs ) -> None: ... def __iter__(self) -> map: ... - def _set_streaming_content(self, value: Union[TextIOWrapper, str, List[bytes], List[str]]) -> None: ... + def _set_streaming_content(self, value: Union[TextIOWrapper, str, List[str], List[bytes]]) -> None: ... @property def content(self): ... \ No newline at end of file diff --git a/django/shortcuts.pyi b/django/shortcuts.pyi index ab96948..6322cd5 100644 --- a/django/shortcuts.pyi +++ b/django/shortcuts.pyi @@ -38,7 +38,7 @@ def redirect( def render( request: WSGIRequest, template_name: str, - context: Optional[Union[Dict[str, bool], Dict[str, str], Dict[str, Union[str, None]]]] = ..., + context: Optional[Union[Dict[str, bool], Dict[str, Union[str, None]], Dict[str, str]]] = ..., content_type: None = ..., status: Optional[int] = ..., using: None = ... diff --git a/django/template/base.pyi b/django/template/base.pyi index 18f4e23..eb8d94b 100644 --- a/django/template/base.pyi +++ b/django/template/base.pyi @@ -26,7 +26,7 @@ from typing import ( def linebreak_iter(template_source: str) -> Iterator[int]: ... -def render_value_in_context(value: Any, context: Context) -> str: ... +def render_value_in_context(value: object, context: Context) -> str: ... def token_kwargs( @@ -53,7 +53,7 @@ class FilterExpression: self, context: Union[Dict[str, Dict[str, str]], Context], ignore_failures: bool = ... - ) -> Any: ... + ) -> object: ... class Lexer: @@ -72,8 +72,8 @@ class Node: def get_nodes_by_type( self, nodetype: Type[Node] - ) -> Union[List[VariableNode], List[BlockNode], List[LoadNode], List[ExtendsNode]]: ... - def render_annotated(self, context: Context) -> Union[str, int]: ... + ) -> Union[List[LoadNode], List[VariableNode], List[BlockNode], List[ExtendsNode]]: ... + def render_annotated(self, context: Context) -> Union[int, str]: ... class NodeList: @@ -110,8 +110,8 @@ class Parser: def error( self, token: Token, - e: Union[str, TemplateSyntaxError, RuntimeError] - ) -> Union[TemplateSyntaxError, RuntimeError]: ... + e: Union[str, RuntimeError, TemplateSyntaxError] + ) -> Union[RuntimeError, TemplateSyntaxError]: ... def extend_nodelist( self, nodelist: NodeList, @@ -128,11 +128,11 @@ class Parser: def next_token(self) -> Token: ... def parse( self, - parse_until: Optional[Union[Tuple[str, str, str], Tuple[str], Tuple[str, str]]] = ... + parse_until: Optional[Union[Tuple[str, str], Tuple[str], Tuple[str, str, str]]] = ... ) -> NodeList: ... def prepend_token(self, token: Token) -> None: ... def skip_past(self, endtag: str) -> None: ... - def unclosed_block_tag(self, parse_until: Union[Tuple[str, str, str], Tuple[str]]): ... + def unclosed_block_tag(self, parse_until: Union[Tuple[str], Tuple[str, str, str]]): ... class Template: @@ -171,8 +171,8 @@ class Token: class Variable: def __init__(self, var: str) -> None: ... - def _resolve_lookup(self, context: Any) -> Any: ... - def resolve(self, context: Any) -> Any: ... + def _resolve_lookup(self, context: Any) -> object: ... + def resolve(self, context: Any) -> object: ... class VariableDoesNotExist: diff --git a/django/template/context.pyi b/django/template/context.pyi index 3f50692..1207ba0 100644 --- a/django/template/context.pyi +++ b/django/template/context.pyi @@ -1,4 +1,5 @@ from django.core.handlers.wsgi import WSGIRequest +from django.db.models.options import Options from django.http.request import HttpRequest from django.template.base import ( Origin, @@ -31,7 +32,7 @@ class BaseContext: def __contains__(self, key: str) -> bool: ... def __copy__(self) -> BaseContext: ... def __eq__(self, other: Context) -> bool: ... - def __getitem__(self, key: Union[str, int]) -> Any: ... + def __getitem__(self, key: Union[str, int]) -> object: ... def __init__(self, dict_: Any = ...) -> None: ... def __iter__(self) -> None: ... def __repr__(self) -> str: ... @@ -41,8 +42,12 @@ class BaseContext: value: Any ) -> None: ... def _reset_dicts(self, value: Any = ...) -> None: ... - def flatten(self) -> Dict[str, Union[None, int, str, Dict[str, Union[Type[object], str]]]]: ... - def get(self, key: str, otherwise: Optional[int] = ...) -> Any: ... + def flatten(self) -> Dict[str, Optional[Union[int, str, Dict[str, Union[Type[object], str]]]]]: ... + def get( + self, + key: str, + otherwise: Optional[int] = ... + ) -> Optional[Union[Options, int, str]]: ... def new(self, values: Any = ...) -> Context: ... def pop(self) -> ContextDict: ... def push(self, *args, **kwargs) -> ContextDict: ... @@ -78,13 +83,13 @@ class RenderContext: def __getitem__( self, key: Union[str, CycleNode] - ) -> Union[List[Origin], BlockContext, cycle]: ... + ) -> Union[BlockContext, List[Origin], cycle]: ... def __iter__(self): ... def get( self, key: Union[str, InclusionNode], otherwise: None = ... - ) -> Optional[Union[BlockContext, Template]]: ... + ) -> Optional[Union[Template, BlockContext]]: ... def push_state(self, template: Template, isolated_context: bool = ...) -> Iterator[None]: ... diff --git a/django/template/defaultfilters.pyi b/django/template/defaultfilters.pyi index 2ea3261..a74a993 100644 --- a/django/template/defaultfilters.pyi +++ b/django/template/defaultfilters.pyi @@ -3,6 +3,7 @@ from datetime import ( time, timedelta, ) +from decimal import Decimal from django.utils.safestring import SafeText from typing import ( Any, @@ -19,8 +20,8 @@ def _property_resolver(arg: Union[str, int]) -> Callable: ... def add( - value: Union[str, Tuple[int, int], date, int], - arg: Union[int, timedelta, Tuple[int, int], SafeText] + value: Union[date, Tuple[int, int], str, int], + arg: Union[SafeText, Tuple[int, int], timedelta, int] ) -> Union[str, Tuple[int, int, int, int], date, int]: ... @@ -39,7 +40,7 @@ def cut(value: str, arg: str) -> str: ... def date(value: Optional[Union[time, date, str]], arg: Optional[str] = ...) -> str: ... -def default(value: Optional[Union[str, int]], arg: Union[int, SafeText]) -> Union[str, int]: ... +def default(value: Optional[Union[int, str]], arg: Union[SafeText, int]) -> Union[int, str]: ... def default_if_none(value: Optional[str], arg: Union[str, int]) -> Union[str, int]: ... @@ -69,7 +70,7 @@ def filesizeformat(bytes_: Union[str, int]) -> str: ... def first(value: Union[str, List[str]]) -> str: ... -def floatformat(text: Any, arg: Union[str, int] = ...) -> str: ... +def floatformat(text: Optional[Union[Decimal, str, float]], arg: Union[str, int] = ...) -> str: ... def force_escape(value: str) -> SafeText: ... @@ -93,7 +94,7 @@ def last(value: List[str]) -> str: ... def length(value: Any) -> int: ... -def length_is(value: Any, arg: Union[int, SafeText]) -> Union[bool, str]: ... +def length_is(value: Any, arg: Union[SafeText, int]) -> Union[bool, str]: ... def linebreaks_filter(value: str, autoescape: bool = ...) -> SafeText: ... @@ -105,7 +106,7 @@ def linebreaksbr(value: str, autoescape: bool = ...) -> SafeText: ... def linenumbers(value: str, autoescape: bool = ...) -> SafeText: ... -def ljust(value: str, arg: Union[int, SafeText]) -> str: ... +def ljust(value: str, arg: Union[SafeText, int]) -> str: ... def lower(value: str) -> str: ... @@ -123,10 +124,10 @@ def pluralize(value: object, arg: str = ...) -> str: ... def pprint(value: object) -> str: ... -def random(value: Union[List[SafeText], List[str]]) -> str: ... +def random(value: Union[List[str], List[SafeText]]) -> str: ... -def rjust(value: str, arg: Union[int, SafeText]) -> str: ... +def rjust(value: str, arg: Union[SafeText, int]) -> str: ... def safe(value: str) -> SafeText: ... @@ -159,13 +160,13 @@ def timeuntil_filter(value: date, arg: Optional[date] = ...) -> str: ... def title(value: str) -> str: ... -def truncatechars(value: str, arg: Union[int, SafeText]) -> str: ... +def truncatechars(value: str, arg: Union[SafeText, int]) -> str: ... def truncatechars_html(value: str, arg: Union[str, int]) -> str: ... -def truncatewords(value: str, arg: Union[int, SafeText]) -> str: ... +def truncatewords(value: str, arg: Union[SafeText, int]) -> str: ... def truncatewords_html(value: str, arg: int) -> str: ... @@ -185,7 +186,7 @@ def urlize(value: str, autoescape: bool = ...) -> SafeText: ... def urlizetrunc( value: str, - limit: Union[int, SafeText], + limit: Union[SafeText, int], autoescape: bool = ... ) -> SafeText: ... @@ -193,7 +194,7 @@ def urlizetrunc( def wordcount(value: str) -> int: ... -def wordwrap(value: str, arg: Union[int, SafeText]) -> str: ... +def wordwrap(value: str, arg: Union[SafeText, int]) -> str: ... def yesno(value: Optional[int], arg: Optional[str] = ...) -> Optional[str]: ... \ No newline at end of file diff --git a/django/template/defaulttags.pyi b/django/template/defaulttags.pyi index 8e3fa6e..501f24f 100644 --- a/django/template/defaulttags.pyi +++ b/django/template/defaulttags.pyi @@ -268,9 +268,9 @@ class RegroupNode: def render(self, context: Context) -> str: ... def resolve_expression( self, - obj: Dict[str, Union[date, str, int, List[str]]], + obj: Dict[str, Union[str, int, date, List[str]]], context: Context - ) -> Union[str, int]: ... + ) -> Union[int, str]: ... class ResetCycleNode: diff --git a/django/template/engine.pyi b/django/template/engine.pyi index 08587f7..3b3278e 100644 --- a/django/template/engine.pyi +++ b/django/template/engine.pyi @@ -24,7 +24,7 @@ class Engine: self, dirs: Optional[List[str]] = ..., app_dirs: bool = ..., - context_processors: Optional[Union[Tuple[str, str], List[str]]] = ..., + context_processors: Optional[Union[List[str], Tuple[str, str]]] = ..., debug: bool = ..., loaders: Any = ..., string_if_invalid: str = ..., @@ -41,7 +41,7 @@ class Engine: ) -> Tuple[Template, Origin]: ... def find_template_loader( self, - loader: Union[str, Tuple[str, List[Tuple[str, Dict[str, str]]]], Tuple[str, Dict[str, str]], Tuple[str, List[str]]] + loader: Union[Tuple[str, List[Tuple[str, Dict[str, str]]]], Tuple[str, List[str]], Tuple[str, Dict[str, str]], str] ) -> Loader: ... def from_string(self, template_code: str) -> Template: ... @staticmethod @@ -55,7 +55,7 @@ class Engine: @cached_property def template_context_processors( self - ) -> Union[Tuple[Callable, Callable, Callable], Tuple[Callable, Callable, Callable, Callable, Callable], Tuple[Callable, Callable], Tuple[Callable]]: ... + ) -> Union[Tuple[Callable, Callable, Callable], Tuple[Callable], Tuple[Callable, Callable, Callable, Callable, Callable], Tuple[Callable, Callable]]: ... @cached_property def template_loaders( self diff --git a/django/template/library.pyi b/django/template/library.pyi index 5a4b595..70e28bb 100644 --- a/django/template/library.pyi +++ b/django/template/library.pyi @@ -30,7 +30,7 @@ def parse_bits( kwonly_defaults: Optional[Dict[str, int]], takes_context: Optional[bool], name: str -) -> Union[Tuple[List[Any], Dict[str, FilterExpression]], Tuple[List[FilterExpression], Dict[str, FilterExpression]], Tuple[List[FilterExpression], Dict[Any, Any]], Tuple[List[Any], Dict[Any, Any]]]: ... +) -> Union[Tuple[List[Any], Dict[Any, Any]], Tuple[List[FilterExpression], Dict[str, FilterExpression]], Tuple[List[Any], Dict[str, FilterExpression]], Tuple[List[FilterExpression], Dict[Any, Any]]]: ... class InclusionNode: diff --git a/django/template/loader.pyi b/django/template/loader.pyi index 4b27cdd..0078604 100644 --- a/django/template/loader.pyi +++ b/django/template/loader.pyi @@ -14,7 +14,7 @@ from typing import ( def _engine_list( using: Optional[str] = ... -) -> Union[List[DjangoTemplates], List[BaseEngine]]: ... +) -> Union[List[BaseEngine], List[DjangoTemplates]]: ... def get_template(template_name: str, using: None = ...) -> Template: ... diff --git a/django/template/loaders/app_directories.pyi b/django/template/loaders/app_directories.pyi index 6a550a9..a530e55 100644 --- a/django/template/loaders/app_directories.pyi +++ b/django/template/loaders/app_directories.pyi @@ -5,4 +5,4 @@ from typing import ( class Loader: - def get_dirs(self) -> Union[Tuple[str, str, str, str], Tuple[str, str, str], Tuple[str], Tuple[str, str]]: ... \ No newline at end of file + def get_dirs(self) -> Union[Tuple[str, str], Tuple[str, str, str], Tuple[str], Tuple[str, str, str, str]]: ... \ No newline at end of file diff --git a/django/template/loaders/filesystem.pyi b/django/template/loaders/filesystem.pyi index 16443c9..11b1f05 100644 --- a/django/template/loaders/filesystem.pyi +++ b/django/template/loaders/filesystem.pyi @@ -11,4 +11,4 @@ class Loader: def __init__(self, engine: Engine, dirs: None = ...) -> None: ... def get_contents(self, origin: Origin): ... def get_dirs(self) -> List[str]: ... - def get_template_sources(self, template_name: Union[str, bytes]) -> Iterator[Origin]: ... \ No newline at end of file + def get_template_sources(self, template_name: Union[bytes, str]) -> Iterator[Origin]: ... \ No newline at end of file diff --git a/django/template/response.pyi b/django/template/response.pyi index e57e0f7..13d8927 100644 --- a/django/template/response.pyi +++ b/django/template/response.pyi @@ -15,7 +15,7 @@ class SimpleTemplateResponse: def __getstate__(self) -> Dict[str, Any]: ... def __init__( self, - template: Union[str, Template, List[str]], + template: Union[str, List[str], Template], context: Any = ..., content_type: Optional[str] = ..., status: Optional[int] = ..., @@ -31,7 +31,7 @@ class SimpleTemplateResponse: def resolve_context(self, context: Any) -> Any: ... def resolve_template( self, - template: Union[str, Template, List[str]] + template: Union[str, List[str], Template] ) -> Template: ... @@ -39,7 +39,7 @@ class TemplateResponse: def __init__( self, request: HttpRequest, - template: Union[str, Template, List[str]], + template: Union[str, List[str], Template], context: Any = ..., content_type: Optional[str] = ..., status: Optional[int] = ..., diff --git a/django/template/smartif.pyi b/django/template/smartif.pyi index 13f5445..d864bda 100644 --- a/django/template/smartif.pyi +++ b/django/template/smartif.pyi @@ -14,11 +14,11 @@ class IfParser: def expression(self, rbp: int = ...) -> Literal: ... def next_token(self) -> Literal: ... def parse(self) -> TemplateLiteral: ... - def translate_token(self, token: Union[List[int], str, int]) -> Literal: ... + def translate_token(self, token: Union[str, List[int], int]) -> Literal: ... class Literal: def __init__(self, value: Optional[int]) -> None: ... def __repr__(self) -> str: ... - def eval(self, context: Dict[Any, Any]) -> Optional[Union[int, List[int]]]: ... + def eval(self, context: Dict[Any, Any]) -> Optional[Union[List[int], int]]: ... def nud(self, parser: IfParser) -> Literal: ... \ No newline at end of file diff --git a/django/template/utils.pyi b/django/template/utils.pyi index 4ac22f2..84fcf68 100644 --- a/django/template/utils.pyi +++ b/django/template/utils.pyi @@ -17,6 +17,6 @@ class EngineHandler: def __iter__(self): ... def all( self - ) -> Union[List[DjangoTemplates], List[TemplateStrings], List[BaseEngine]]: ... + ) -> Union[List[BaseEngine], List[TemplateStrings], List[DjangoTemplates]]: ... @cached_property def templates(self) -> OrderedDict: ... \ No newline at end of file diff --git a/django/templatetags/i18n.pyi b/django/templatetags/i18n.pyi index e47bd95..761f514 100644 --- a/django/templatetags/i18n.pyi +++ b/django/templatetags/i18n.pyi @@ -95,7 +95,7 @@ class BlockTranslateNode: def render_token_list( self, tokens: List[Token] - ) -> Union[Tuple[str, List[Any]], Tuple[str, List[str]]]: ... + ) -> Union[Tuple[str, List[str]], Tuple[str, List[Any]]]: ... class GetAvailableLanguagesNode: diff --git a/django/test/client.pyi b/django/test/client.pyi index a3c244c..0da44bc 100644 --- a/django/test/client.pyi +++ b/django/test/client.pyi @@ -37,7 +37,7 @@ def conditional_content_removal( ) -> HttpResponseBase: ... -def encode_file(boundary: str, key: str, file: Any) -> List[bytes]: ... +def encode_file(boundary: str, key: str, file: object) -> List[bytes]: ... def encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ... diff --git a/django/test/html.pyi b/django/test/html.pyi index e79a4ba..85fdbdc 100644 --- a/django/test/html.pyi +++ b/django/test/html.pyi @@ -20,7 +20,7 @@ class Element: def __init__( self, name: Optional[str], - attributes: Union[Tuple, List[Tuple[str, None]], List[Tuple[str, str]], List[Union[Tuple[str, str], Tuple[str, None]]]] + attributes: Union[Tuple, List[Union[Tuple[str, str], Tuple[str, None]]], List[Tuple[str, None]], List[Tuple[str, str]]] ) -> None: ... def __repr__(self) -> str: ... def __str__(self) -> str: ... diff --git a/django/test/runner.pyi b/django/test/runner.pyi index 6ff6adf..479dabf 100644 --- a/django/test/runner.pyi +++ b/django/test/runner.pyi @@ -78,12 +78,12 @@ class DiscoverRunner: ) -> None: ... def build_suite( self, - test_labels: Union[List[str], Tuple[str], Tuple[str, str]] = ..., + test_labels: Union[Tuple[str, str], List[str], Tuple[str]] = ..., extra_tests: None = ..., **kwargs ) -> TestSuite: ... def get_resultclass(self) -> None: ... - def get_test_runner_kwargs(self) -> Dict[str, Union[None, int]]: ... + def get_test_runner_kwargs(self) -> Dict[str, Optional[int]]: ... def run_checks(self) -> None: ... def run_suite(self, suite: TestSuite, **kwargs) -> TextTestResult: ... def run_tests(self, test_labels: List[str], extra_tests: List[Any] = ..., **kwargs) -> int: ... diff --git a/django/test/selenium.pyi b/django/test/selenium.pyi index 91fc21d..3b7b2a8 100644 --- a/django/test/selenium.pyi +++ b/django/test/selenium.pyi @@ -15,6 +15,6 @@ class SeleniumTestCaseBase: def __new__( cls: Type[SeleniumTestCaseBase], name: str, - bases: Union[Tuple[Type[SeleniumTestCase], Type[StaticLiveServerTestCase]], Tuple[Type[AdminSeleniumTestCase]]], + bases: Union[Tuple[Type[AdminSeleniumTestCase]], Tuple[Type[SeleniumTestCase], Type[StaticLiveServerTestCase]]], attrs: Dict[str, Union[str, List[str], Callable]] ) -> Type[AdminSeleniumTestCase]: ... \ No newline at end of file diff --git a/django/test/testcases.pyi b/django/test/testcases.pyi index 2a97b75..b053438 100644 --- a/django/test/testcases.pyi +++ b/django/test/testcases.pyi @@ -23,7 +23,7 @@ from unittest.runner import TextTestResult class CheckCondition: - def __get__(self, instance: None, cls: Any = ...) -> bool: ... + def __get__(self, instance: None, cls: Type[TestCase] = ...) -> bool: ... def __init__(self, *conditions) -> None: ... @@ -56,7 +56,7 @@ class SimpleTestCase: self, func: Callable, cm_attr: str, - expected_exception: Any, + expected_exception: Type[Exception], expected_message: str, *args, **kwargs @@ -73,7 +73,7 @@ class SimpleTestCase: self, func: Callable, cm_attr: str, - expected_exception: Any, + expected_exception: Type[Exception], expected_message: str ) -> Iterator[Union[_AssertRaisesContext, _AssertWarnsContext]]: ... def _assert_template_used( diff --git a/django/test/utils.pyi b/django/test/utils.pyi index 9b0332d..fe5a303 100644 --- a/django/test/utils.pyi +++ b/django/test/utils.pyi @@ -10,6 +10,7 @@ from django.db.backends.sqlite3.base import DatabaseWrapper from django.template.base import Template from django.template.context import Context from django.test.runner import DiscoverRunner +from django.test.testcases import SimpleTestCase from django.utils.safestring import SafeText from typing import ( Any, @@ -128,7 +129,10 @@ class TestContextDecorator: def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ... def __init__(self, attr_name: Optional[str] = ..., kwarg_name: Optional[str] = ...) -> None: ... def decorate_callable(self, func: Callable) -> Callable: ... - def decorate_class(self, cls: Any) -> Any: ... + def decorate_class( + self, + cls: Type[SimpleTestCase] + ) -> Type[SimpleTestCase]: ... class ignore_warnings: @@ -146,7 +150,7 @@ class isolate_apps: class modify_settings: def __init__(self, *args, **kwargs) -> None: ... def enable(self) -> None: ... - def save_options(self, test_func: Any) -> None: ... + def save_options(self, test_func: Type[SimpleTestCase]) -> None: ... class override_script_prefix: @@ -157,10 +161,16 @@ class override_script_prefix: class override_settings: def __init__(self, **kwargs) -> None: ... - def decorate_class(self, cls: Any) -> Any: ... + def decorate_class( + self, + cls: Type[Union[SimpleTestCase, LoggingCaptureMixin]] + ) -> Type[Union[SimpleTestCase, LoggingCaptureMixin]]: ... def disable(self) -> None: ... def enable(self) -> None: ... - def save_options(self, test_func: Any) -> None: ... + def save_options( + self, + test_func: Type[Union[SimpleTestCase, LoggingCaptureMixin]] + ) -> None: ... class override_system_checks: diff --git a/django/urls/base.pyi b/django/urls/base.pyi index 4074676..32f98c3 100644 --- a/django/urls/base.pyi +++ b/django/urls/base.pyi @@ -35,7 +35,7 @@ def reverse( def set_script_prefix(prefix: str) -> None: ... -def set_urlconf(urlconf_name: Any) -> None: ... +def set_urlconf(urlconf_name: Optional[Union[Type[object], str]]) -> None: ... def translate_url(url: str, lang_code: str) -> str: ... \ No newline at end of file diff --git a/django/urls/converters.pyi b/django/urls/converters.pyi index d3cc714..9e106fa 100644 --- a/django/urls/converters.pyi +++ b/django/urls/converters.pyi @@ -1,17 +1,14 @@ from typing import ( - Any, Dict, Union, ) -from urlpatterns.converters import DynamicConverter from uuid import UUID -def get_converter(raw_converter: str) -> Any: ... +def get_converter(raw_converter: str) -> object: ... -def get_converters( -) -> Dict[str, Union[IntConverter, StringConverter, UUIDConverter, DynamicConverter]]: ... +def get_converters() -> Dict[str, object]: ... class IntConverter: diff --git a/django/urls/resolvers.pyi b/django/urls/resolvers.pyi index 3b450c8..31f39b6 100644 --- a/django/urls/resolvers.pyi +++ b/django/urls/resolvers.pyi @@ -59,8 +59,8 @@ class ResolverMatch: args: Tuple, kwargs: Dict[str, Any], url_name: Optional[str] = ..., - app_names: Optional[Union[List[str], List[Union[None, str]], List[None]]] = ..., - namespaces: Optional[Union[List[str], List[Union[None, str]], List[None]]] = ... + app_names: Optional[Union[List[None], List[str], List[Union[None, str]]]] = ..., + namespaces: Optional[Union[List[None], List[str], List[Union[None, str]]]] = ... ) -> None: ... def __repr__(self) -> str: ... @@ -114,6 +114,6 @@ class URLResolver: @cached_property def url_patterns( self - ) -> Union[List[URLResolver], List[Union[URLPattern, URLResolver]], List[URLPattern], List[Tuple[str, Callable]]]: ... + ) -> Union[List[Union[URLPattern, URLResolver]], List[URLResolver], List[Tuple[str, Callable]], List[URLPattern]]: ... @cached_property def urlconf_module(self) -> Any: ... \ No newline at end of file diff --git a/django/utils/autoreload.pyi b/django/utils/autoreload.pyi index 94041af..98569dc 100644 --- a/django/utils/autoreload.pyi +++ b/django/utils/autoreload.pyi @@ -9,7 +9,7 @@ from typing import ( def check_errors(fn: Callable) -> Callable: ... -def clean_files(filelist: Union[List[Union[None, bool]], List[str], List[Union[None, str]]]) -> List[str]: ... +def clean_files(filelist: Union[List[Union[None, str]], List[str], List[Union[None, bool]]]) -> List[str]: ... def gen_filenames(only_new: bool = ...) -> List[str]: ... diff --git a/django/utils/cache.pyi b/django/utils/cache.pyi index 6c55897..716b288 100644 --- a/django/utils/cache.pyi +++ b/django/utils/cache.pyi @@ -80,7 +80,7 @@ def has_vary_header(response: HttpResponse, header_query: str) -> bool: ... def learn_cache_key( request: WSGIRequest, response: HttpResponse, - cache_timeout: Optional[Union[float, int]] = ..., + cache_timeout: Optional[float] = ..., key_prefix: Optional[str] = ..., cache: Optional[Union[DefaultCacheProxy, backends.locmem.LocMemCache]] = ... ) -> str: ... @@ -94,7 +94,7 @@ def patch_response_headers(response: HttpResponse, cache_timeout: int = ...) -> def patch_vary_headers( response: HttpResponseBase, - newheaders: Union[Tuple[str], Tuple[str, str]] + newheaders: Union[Tuple[str, str], Tuple[str]] ) -> None: ... diff --git a/django/utils/dateformat.pyi b/django/utils/dateformat.pyi index d8459dc..258364b 100644 --- a/django/utils/dateformat.pyi +++ b/django/utils/dateformat.pyi @@ -5,10 +5,10 @@ from datetime import ( from typing import Union -def format(value: Union[time, str, date], format_string: str) -> str: ... +def format(value: Union[time, date, str], format_string: str) -> str: ... -def time_format(value: Union[date, time, str], format_string: str) -> str: ... +def time_format(value: Union[str, time, date], format_string: str) -> str: ... class DateFormat: @@ -41,7 +41,7 @@ class TimeFormat: def P(self) -> str: ... def T(self) -> str: ... def Z(self) -> Union[str, int]: ... - def __init__(self, obj: Union[time, date, str]) -> None: ... + def __init__(self, obj: Union[time, str, date]) -> None: ... def a(self) -> str: ... def e(self) -> str: ... def f(self) -> Union[str, int]: ... diff --git a/django/utils/decorators.pyi b/django/utils/decorators.pyi index d8e238a..bc60e40 100644 --- a/django/utils/decorators.pyi +++ b/django/utils/decorators.pyi @@ -1,8 +1,11 @@ +from django.contrib.auth.mixins import PermissionRequiredMixin from django.middleware.cache import CacheMiddleware from django.middleware.csrf import CsrfViewMiddleware +from django.test.testcases import LiveServerTestCase +from django.views.generic.base import View from typing import ( - Any, Callable, + Optional, Tuple, Type, Union, @@ -21,17 +24,25 @@ def decorator_from_middleware(middleware_class: Type[CsrfViewMiddleware]) -> Cal def decorator_from_middleware_with_args(middleware_class: Type[CacheMiddleware]) -> Callable: ... -def make_middleware_decorator(middleware_class: Any) -> Callable: ... +def make_middleware_decorator(middleware_class: Type[object]) -> Callable: ... def method_decorator(decorator: Callable, name: str = ...) -> Callable: ... class classonlymethod: - def __get__(self, instance: None, cls: Any = ...) -> Callable: ... + def __get__( + self, + instance: None, + cls: Type[Union[View, PermissionRequiredMixin]] = ... + ) -> Callable: ... class classproperty: - def __get__(self, instance: Any, cls: Any = ...) -> str: ... + def __get__( + self, + instance: Optional[LiveServerTestCase], + cls: Type[LiveServerTestCase] = ... + ) -> str: ... def __init__(self, method: Callable = ...) -> None: ... def getter(self, method: Callable) -> classproperty: ... \ No newline at end of file diff --git a/django/utils/encoding.pyi b/django/utils/encoding.pyi index 3496ae2..1275ec7 100644 --- a/django/utils/encoding.pyi +++ b/django/utils/encoding.pyi @@ -1,4 +1,5 @@ from datetime import date +from django.db.models.base import Model from typing import ( Any, Optional, @@ -35,7 +36,12 @@ def is_protected_type(obj: Any) -> bool: ... def repercent_broken_unicode(path: bytes) -> bytes: ... -def smart_text(s: Any, encoding: str = ..., strings_only: bool = ..., errors: str = ...) -> str: ... +def smart_text( + s: Union[Model, int, str], + encoding: str = ..., + strings_only: bool = ..., + errors: str = ... +) -> str: ... def uri_to_iri(uri: Optional[str]) -> Optional[str]: ... diff --git a/django/utils/formats.pyi b/django/utils/formats.pyi index 0b043a2..7804bac 100644 --- a/django/utils/formats.pyi +++ b/django/utils/formats.pyi @@ -32,14 +32,14 @@ def get_format_modules(lang: str = ..., reverse: bool = ...) -> List[Any]: ... def iter_format_modules(lang: str, format_module_path: Optional[str] = ...) -> Iterator[Any]: ... -def localize(value: Any, use_l10n: Optional[bool] = ...) -> Any: ... +def localize(value: object, use_l10n: Optional[bool] = ...) -> object: ... def localize_input(value: Any, default: Optional[str] = ...) -> Optional[str]: ... def number_format( - value: Union[Decimal, float, str, int], + value: Union[float, Decimal, str], decimal_pos: Optional[int] = ..., use_l10n: Optional[bool] = ..., force_grouping: bool = ... @@ -53,7 +53,7 @@ def sanitize_separators(value: Union[str, int]) -> Union[str, int]: ... def time_format( - value: Union[date, time, str], + value: Union[str, time, date], format: Optional[str] = ..., use_l10n: None = ... ) -> str: ... \ No newline at end of file diff --git a/django/utils/functional.pyi b/django/utils/functional.pyi index 55c30f8..9f95d29 100644 --- a/django/utils/functional.pyi +++ b/django/utils/functional.pyi @@ -1,15 +1,22 @@ +from django.contrib.auth.models import User +from django.db.models.base import Model from typing import ( Any, Callable, Dict, List, + Tuple, + Type, + Union, ) class LazyObject: def __delattr__(self, name: str) -> None: ... def __init__(self) -> None: ... - def __reduce__(self) -> Any: ... + def __reduce__( + self + ) -> Union[Tuple[Callable, Tuple[object]], Tuple[Callable, Tuple[User]], Tuple[Callable, Tuple[Model]]]: ... def __setattr__(self, name: str, value: object) -> None: ... @@ -21,4 +28,4 @@ class SimpleLazyObject: class cached_property: - def __get__(self, instance: Any, cls: Any = ...) -> Any: ... \ No newline at end of file + def __get__(self, instance: Any, cls: Type[Any] = ...) -> Any: ... \ No newline at end of file diff --git a/django/utils/html.pyi b/django/utils/html.pyi index c85cb79..52e22e8 100644 --- a/django/utils/html.pyi +++ b/django/utils/html.pyi @@ -1,3 +1,4 @@ +from django.db.models.base import Model from django.utils.safestring import SafeText from typing import ( Any, @@ -18,7 +19,7 @@ def avoid_wrapping(value: str) -> str: ... def conditional_escape(text: Any) -> str: ... -def escape(text: Any) -> SafeText: ... +def escape(text: Optional[Union[Model, int, str]]) -> SafeText: ... def escapejs(value: str) -> SafeText: ... diff --git a/django/utils/http.pyi b/django/utils/http.pyi index 6daa12c..7cbcd15 100644 --- a/django/utils/http.pyi +++ b/django/utils/http.pyi @@ -28,10 +28,10 @@ def base36_to_int(s: str) -> int: ... def cookie_date(epoch_seconds: float = ...) -> str: ... -def http_date(epoch_seconds: Union[float, int] = ...) -> str: ... +def http_date(epoch_seconds: float = ...) -> str: ... -def int_to_base36(i: Union[str, int, Dict[int, int]]) -> str: ... +def int_to_base36(i: Union[str, Dict[int, int], int]) -> str: ... def is_safe_url(url: Optional[str], allowed_hosts: Optional[Set[str]], require_https: bool = ...) -> bool: ... diff --git a/django/utils/log.pyi b/django/utils/log.pyi index ceab0de..6acd269 100644 --- a/django/utils/log.pyi +++ b/django/utils/log.pyi @@ -1,14 +1,17 @@ from django.core.mail.backends.locmem import EmailBackend from logging import LogRecord from typing import ( - Any, Callable, Dict, + List, Union, ) -def configure_logging(logging_config: str, logging_settings: Dict[str, Any]) -> None: ... +def configure_logging( + logging_config: str, + logging_settings: Dict[str, Union[int, Dict[str, Dict[str, str]], Dict[str, Dict[str, Union[str, List[str]]]], Dict[str, Dict[str, Union[List[str], str, bool]]]]] +) -> None: ... def log_response( diff --git a/django/utils/numberformat.pyi b/django/utils/numberformat.pyi index 6f3d884..7d2596c 100644 --- a/django/utils/numberformat.pyi +++ b/django/utils/numberformat.pyi @@ -7,10 +7,10 @@ from typing import ( def format( - number: Union[float, str, int, Decimal], + number: Union[float, Decimal, str], decimal_sep: str, decimal_pos: Optional[int] = ..., - grouping: Union[Tuple[int, int, int], int, Tuple[int, int, int, int, int]] = ..., + grouping: Union[Tuple[int, int, int, int, int], Tuple[int, int, int], int] = ..., thousand_sep: str = ..., force_grouping: bool = ..., use_l10n: Optional[bool] = ... diff --git a/django/utils/regex_helper.pyi b/django/utils/regex_helper.pyi index 02d428b..240f4dc 100644 --- a/django/utils/regex_helper.pyi +++ b/django/utils/regex_helper.pyi @@ -17,12 +17,12 @@ def contains( def flatten_result(source: Any) -> Union[Tuple[List[str], List[List[str]]], Tuple[List[str], List[List[Any]]]]: ... -def get_quantifier(ch: str, input_iter: Iterator[Any]) -> Union[Tuple[int, None], Tuple[int, str]]: ... +def get_quantifier(ch: str, input_iter: Iterator[Any]) -> Union[Tuple[int, str], Tuple[int, None]]: ... def normalize( pattern: str -) -> Union[List[Tuple[str, List[Any]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]], List[Tuple[str, List[str]]]]: ... +) -> Union[List[Tuple[str, List[Any]]], List[Tuple[str, List[str]]], List[Union[Tuple[str, List[Any]], Tuple[str, List[str]]]]]: ... def walk_to_end(ch: str, input_iter: Iterator[Any]) -> None: ... \ No newline at end of file diff --git a/django/utils/safestring.pyi b/django/utils/safestring.pyi index 7c25acc..a3081e2 100644 --- a/django/utils/safestring.pyi +++ b/django/utils/safestring.pyi @@ -9,8 +9,8 @@ def _safety_decorator(safety_marker: Callable, func: Callable) -> Callable: ... def mark_safe( - s: Union[str, Callable, BoundField] -) -> Union[SafeText, Callable, BoundField]: ... + s: Union[str, BoundField, Callable] +) -> Union[SafeText, BoundField, Callable]: ... class SafeData: diff --git a/django/utils/six.pyi b/django/utils/six.pyi index 6785f23..b986ea7 100644 --- a/django/utils/six.pyi +++ b/django/utils/six.pyi @@ -10,5 +10,5 @@ class _SixMetaPathImporter: def find_module( self, fullname: str, - path: Optional[Union[List[str], _NamespacePath]] = ... + path: Optional[Union[_NamespacePath, List[str]]] = ... ) -> None: ... \ No newline at end of file diff --git a/django/utils/termcolors.pyi b/django/utils/termcolors.pyi index 34b08ac..9fc64f1 100644 --- a/django/utils/termcolors.pyi +++ b/django/utils/termcolors.pyi @@ -15,4 +15,4 @@ def make_style(opts: Tuple = ..., **kwargs) -> Callable: ... def parse_color_setting( config_string: str -) -> Optional[Union[Dict[str, Dict[str, str]], Dict[str, Dict[str, Union[str, Tuple[str]]]]]]: ... \ No newline at end of file +) -> Optional[Union[Dict[str, Dict[str, Union[str, Tuple[str]]]], Dict[str, Dict[str, str]]]]: ... \ No newline at end of file diff --git a/django/utils/text.pyi b/django/utils/text.pyi index 30e9147..6f78909 100644 --- a/django/utils/text.pyi +++ b/django/utils/text.pyi @@ -16,7 +16,7 @@ def camel_case_to_spaces(value: str) -> str: ... def capfirst(x: Optional[str]) -> Optional[str]: ... -def compress_sequence(sequence: Union[List[bytes], map]) -> Iterator[bytes]: ... +def compress_sequence(sequence: Union[map, List[bytes]]) -> Iterator[bytes]: ... def compress_string(s: bytes) -> bytes: ... diff --git a/django/utils/timezone.pyi b/django/utils/timezone.pyi index aa22c3f..1ca7ddc 100644 --- a/django/utils/timezone.pyi +++ b/django/utils/timezone.pyi @@ -4,7 +4,6 @@ from datetime import ( timedelta, ) from typing import ( - Any, Optional, Union, ) @@ -13,7 +12,7 @@ from typing import ( def _get_timezone_name(timezone: FixedOffset) -> str: ... -def activate(timezone: Union[str, FixedOffset]) -> None: ... +def activate(timezone: Union[FixedOffset, str]) -> None: ... def deactivate() -> None: ... @@ -53,7 +52,7 @@ def make_naive(value: datetime, timezone: FixedOffset = ...) -> datetime: ... def now() -> datetime: ... -def template_localtime(value: Any, use_tz: Optional[bool] = ...) -> Any: ... +def template_localtime(value: object, use_tz: Optional[bool] = ...) -> object: ... class FixedOffset: diff --git a/django/utils/translation/__init__.pyi b/django/utils/translation/__init__.pyi index 567bf77..be664a4 100644 --- a/django/utils/translation/__init__.pyi +++ b/django/utils/translation/__init__.pyi @@ -1,8 +1,5 @@ from django.core.handlers.wsgi import WSGIRequest -from typing import ( - Optional, - Union, -) +from typing import Optional def activate(language: str) -> None: ... @@ -38,7 +35,7 @@ def gettext(message: str) -> str: ... def gettext_noop(message: str) -> str: ... -def ngettext(singular: str, plural: str, number: Union[float, int]) -> str: ... +def ngettext(singular: str, plural: str, number: float) -> str: ... def npgettext(context: str, singular: str, plural: str, number: int) -> str: ... diff --git a/django/utils/translation/trans_real.pyi b/django/utils/translation/trans_real.pyi index aec796e..523cdd1 100644 --- a/django/utils/translation/trans_real.pyi +++ b/django/utils/translation/trans_real.pyi @@ -5,7 +5,6 @@ from typing import ( List, Optional, Tuple, - Union, ) @@ -24,7 +23,7 @@ def deactivate() -> None: ... def deactivate_all() -> None: ... -def do_ntranslate(singular: str, plural: str, number: Union[float, int], translation_function: str) -> str: ... +def do_ntranslate(singular: str, plural: str, number: float, translation_function: str) -> str: ... def get_language() -> Optional[str]: ... @@ -51,7 +50,7 @@ def gettext(message: str) -> str: ... def gettext_noop(message: str) -> str: ... -def ngettext(singular: str, plural: str, number: Union[float, int]) -> str: ... +def ngettext(singular: str, plural: str, number: float) -> str: ... def npgettext(context: str, singular: str, plural: str, number: int) -> str: ... diff --git a/django/views/debug.pyi b/django/views/debug.pyi index 74d3aa4..8ec80fc 100644 --- a/django/views/debug.pyi +++ b/django/views/debug.pyi @@ -59,7 +59,7 @@ class ExceptionReporter: context_lines: int, loader: Optional[Union[SourceFileLoader, Type[FrozenImporter]]] = ..., module_name: str = ... - ) -> Union[Tuple[int, List[str], str, List[str]], Tuple[None, List[Any], None, List[Any]], Tuple[int, List[str], str, List[Any]]]: ... + ) -> Union[Tuple[int, List[str], str, List[Any]], Tuple[int, List[str], str, List[str]], Tuple[None, List[Any], None, List[Any]]]: ... def get_traceback_data(self) -> Dict[str, Any]: ... def get_traceback_frames(self) -> List[Any]: ... def get_traceback_html(self) -> SafeText: ... diff --git a/django/views/decorators/cache.pyi b/django/views/decorators/cache.pyi index 3ed1010..e425de8 100644 --- a/django/views/decorators/cache.pyi +++ b/django/views/decorators/cache.pyi @@ -1,10 +1,7 @@ -from typing import ( - Callable, - Union, -) +from typing import Callable -def cache_page(timeout: Union[float, int], *, cache = ..., key_prefix = ...) -> Callable: ... +def cache_page(timeout: float, *, cache = ..., key_prefix = ...) -> Callable: ... def never_cache(view_func: Callable) -> Callable: ... \ No newline at end of file diff --git a/django/views/decorators/csrf.pyi b/django/views/decorators/csrf.pyi index c576150..f97e88f 100644 --- a/django/views/decorators/csrf.pyi +++ b/django/views/decorators/csrf.pyi @@ -1,4 +1,3 @@ -from csrf_tests.tests import TestingHttpRequest from django.http.request import HttpRequest from typing import ( Any, @@ -12,10 +11,10 @@ def csrf_exempt(view_func: Callable) -> Callable: ... class _EnsureCsrfCookie: - def _reject(self, request: TestingHttpRequest, reason: str) -> None: ... + def _reject(self, request: HttpRequest, reason: str) -> None: ... def process_view( self, - request: TestingHttpRequest, + request: HttpRequest, callback: Callable, callback_args: Tuple, callback_kwargs: Dict[Any, Any] diff --git a/django/views/generic/base.pyi b/django/views/generic/base.pyi index 60d696f..1feff32 100644 --- a/django/views/generic/base.pyi +++ b/django/views/generic/base.pyi @@ -16,7 +16,7 @@ from typing import ( class ContextMixin: - def get_context_data(self, **kwargs) -> Dict[str, Any]: ... + def get_context_data(self, **kwargs) -> Dict[str, object]: ... class RedirectView: diff --git a/django/views/generic/dates.pyi b/django/views/generic/dates.pyi index cfff596..4d53881 100644 --- a/django/views/generic/dates.pyi +++ b/django/views/generic/dates.pyi @@ -65,10 +65,10 @@ class BaseDayArchiveView: def _get_dated_items( self, date: date - ) -> Union[Tuple[None, QuerySet, Dict[str, Union[date, None]]], Tuple[None, QuerySet, Dict[str, date]]]: ... + ) -> Union[Tuple[None, QuerySet, Dict[str, date]], Tuple[None, QuerySet, Dict[str, Union[date, None]]]]: ... def get_dated_items( self - ) -> Union[Tuple[None, QuerySet, Dict[str, Union[date, None]]], Tuple[None, QuerySet, Dict[str, date]]]: ... + ) -> Union[Tuple[None, QuerySet, Dict[str, date]], Tuple[None, QuerySet, Dict[str, Union[date, None]]]]: ... class BaseMonthArchiveView: diff --git a/django/views/generic/detail.pyi b/django/views/generic/detail.pyi index df94752..9054451 100644 --- a/django/views/generic/detail.pyi +++ b/django/views/generic/detail.pyi @@ -3,7 +3,6 @@ from django.db.models.base import Model from django.db.models.query import QuerySet from django.template.response import TemplateResponse from typing import ( - Any, Dict, List, Optional, @@ -21,8 +20,8 @@ class BaseDetailView: class SingleObjectMixin: - def get_context_data(self, **kwargs) -> Dict[str, Any]: ... - def get_context_object_name(self, obj: Union[Model, Dict[str, str]]) -> Optional[str]: ... + def get_context_data(self, **kwargs) -> Dict[str, object]: ... + def get_context_object_name(self, obj: Union[Dict[str, str], Model]) -> Optional[str]: ... def get_object(self, queryset: Optional[QuerySet] = ...) -> Model: ... def get_queryset(self) -> QuerySet: ... def get_slug_field(self) -> str: ... diff --git a/django/views/generic/edit.pyi b/django/views/generic/edit.pyi index 6f82ed3..7bb09f4 100644 --- a/django/views/generic/edit.pyi +++ b/django/views/generic/edit.pyi @@ -1,9 +1,6 @@ from django.core.handlers.wsgi import WSGIRequest from django.db.models.base import Model -from django.forms.forms import ( - BaseForm, - Form, -) +from django.forms.forms import Form from django.forms.models import ModelForm from django.http.response import HttpResponseRedirect from django.template.response import TemplateResponse @@ -55,9 +52,9 @@ class FormMixin: def form_invalid(self, form: Form) -> TemplateResponse: ... def form_valid(self, form: Form) -> HttpResponseRedirect: ... def get_context_data(self, **kwargs) -> Dict[str, Any]: ... - def get_form(self, form_class: None = ...) -> BaseForm: ... - def get_form_class(self) -> Any: ... - def get_form_kwargs(self) -> Dict[str, Union[None, MultiValueDict]]: ... + def get_form(self, form_class: None = ...) -> Union[Form, ModelForm]: ... + def get_form_class(self) -> Type[Form]: ... + def get_form_kwargs(self) -> Dict[str, Optional[MultiValueDict]]: ... def get_initial(self) -> Dict[Any, Any]: ... def get_prefix(self) -> None: ... def get_success_url(self) -> str: ... @@ -67,7 +64,7 @@ class ModelFormMixin: def get_form_class(self) -> Type[ModelForm]: ... def get_form_kwargs( self - ) -> Dict[str, Union[None, MultiValueDict, Model]]: ... + ) -> Dict[str, Optional[Union[MultiValueDict, Model]]]: ... def get_success_url(self) -> str: ... diff --git a/django/views/generic/list.pyi b/django/views/generic/list.pyi index 7276107..2a3df46 100644 --- a/django/views/generic/list.pyi +++ b/django/views/generic/list.pyi @@ -29,10 +29,10 @@ class MultipleObjectMixin: def get_context_data(self, *, object_list = ..., **kwargs) -> Dict[str, Any]: ... def get_context_object_name( self, - object_list: Optional[Union[QuerySet, List[Dict[str, str]]]] + object_list: Optional[Union[List[Dict[str, str]], QuerySet]] ) -> Optional[str]: ... def get_ordering(self) -> None: ... - def get_paginate_by(self, queryset: Union[QuerySet, List[Dict[str, str]]]) -> Optional[int]: ... + def get_paginate_by(self, queryset: Union[List[Dict[str, str]], QuerySet]) -> Optional[int]: ... def get_paginate_orphans(self) -> int: ... def get_paginator( self, @@ -42,7 +42,7 @@ class MultipleObjectMixin: allow_empty_first_page: bool = ..., **kwargs ) -> Paginator: ... - def get_queryset(self) -> Union[QuerySet, List[Dict[str, str]]]: ... + def get_queryset(self) -> Union[List[Dict[str, str]], QuerySet]: ... def paginate_queryset( self, queryset: QuerySet, diff --git a/django/views/i18n.pyi b/django/views/i18n.pyi index 46a676e..8c2dc50 100644 --- a/django/views/i18n.pyi +++ b/django/views/i18n.pyi @@ -39,6 +39,6 @@ class JavaScriptCatalog: def get_plural(self) -> Optional[str]: ... def render_to_response( self, - context: Dict[str, Union[Dict[str, Union[str, int, List[str]]], None, Dict[str, str], Dict[str, Union[str, List[str]]]]], + context: Dict[str, Optional[Union[Dict[str, str], Dict[str, Union[str, int, List[str]]], Dict[str, Union[str, List[str]]]]]], **response_kwargs ) -> HttpResponse: ... \ No newline at end of file