From 5c6be7ad121abb2bc8020b0a51c5c0a3981f7216 Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Mon, 25 Mar 2019 01:57:34 +0300 Subject: [PATCH] Add test to import all modules to check validity of stubs (#56) * add import_all.test builder * fix errors * fix typechecking errors * fix migrations typechecking --- django-stubs/contrib/admin/apps.pyi | 21 +- django-stubs/contrib/admin/forms.pyi | 26 -- django-stubs/contrib/admin/helpers.pyi | 29 +- .../contrib/admin/views/autocomplete.pyi | 12 +- django-stubs/contrib/admin/widgets.pyi | 150 +------ django-stubs/contrib/auth/admin.pyi | 41 +- django-stubs/contrib/auth/apps.pyi | 17 +- django-stubs/contrib/auth/checks.pyi | 4 +- .../contrib/auth/context_processors.pyi | 18 +- django-stubs/contrib/auth/forms.pyi | 86 +--- django-stubs/contrib/auth/views.pyi | 43 +- django-stubs/contrib/contenttypes/apps.pyi | 15 +- .../commands/remove_stale_contenttypes.pyi | 15 +- django-stubs/contrib/flatpages/forms.pyi | 14 +- django-stubs/contrib/flatpages/models.pyi | 2 +- django-stubs/contrib/flatpages/sitemaps.pyi | 6 +- django-stubs/contrib/messages/constants.pyi | 11 + .../contrib/messages/storage/base.pyi | 2 +- .../contrib/messages/storage/cookie.pyi | 35 +- .../contrib/messages/storage/fallback.pyi | 5 +- .../contrib/messages/storage/session.pyi | 13 +- .../contrib/sessions/backends/cache.pyi | 14 +- .../contrib/sessions/backends/cached_db.pyi | 10 +- django-stubs/contrib/sessions/backends/db.pyi | 13 +- .../contrib/sessions/backends/file.pyi | 12 +- .../sessions/backends/signed_cookies.pyi | 16 +- .../management/commands/clearsessions.pyi | 9 +- django-stubs/contrib/sitemaps/__init__.pyi | 4 +- django-stubs/contrib/sites/apps.pyi | 13 +- django-stubs/contrib/staticfiles/apps.pyi | 11 +- django-stubs/contrib/staticfiles/finders.pyi | 18 +- django-stubs/contrib/staticfiles/handlers.pyi | 5 +- .../management/commands/collectstatic.pyi | 11 +- .../management/commands/findstatic.pyi | 13 +- .../management/commands/runserver.pyi | 14 +- django-stubs/contrib/staticfiles/storage.pyi | 8 +- django-stubs/core/cache/backends/base.pyi | 22 +- django-stubs/core/cache/backends/db.pyi | 23 +- django-stubs/core/cache/backends/dummy.pyi | 15 +- .../core/cache/backends/filebased.pyi | 19 +- django-stubs/core/files/locks.pyi | 14 +- django-stubs/core/mail/__init__.pyi | 11 +- django-stubs/core/mail/message.pyi | 33 +- django-stubs/core/management/templates.pyi | 7 +- django-stubs/db/backends/base/base.pyi | 27 +- django-stubs/db/backends/base/schema.pyi | 21 +- django-stubs/db/backends/dummy/base.pyi | 36 +- django-stubs/db/backends/sqlite3/schema.pyi | 24 +- django-stubs/db/migrations/loader.pyi | 16 +- django-stubs/db/migrations/migration.pyi | 2 +- django-stubs/forms/forms.pyi | 4 +- django-stubs/forms/models.pyi | 10 +- django-stubs/forms/widgets.pyi | 63 +-- django-stubs/template/backends/base.pyi | 17 +- django-stubs/template/backends/django.pyi | 13 +- django-stubs/template/backends/dummy.pyi | 8 +- django-stubs/template/backends/jinja2.pyi | 13 +- django-stubs/template/base.pyi | 20 +- .../template/loaders/app_directories.pyi | 9 +- django-stubs/template/loaders/base.pyi | 4 +- django-stubs/template/loaders/cached.pyi | 15 +- django-stubs/template/loaders/filesystem.pyi | 4 +- django-stubs/template/loaders/locmem.pyi | 4 +- django-stubs/templatetags/cache.pyi | 8 +- django-stubs/templatetags/i18n.pyi | 29 +- django-stubs/templatetags/l10n.pyi | 19 +- django-stubs/templatetags/static.pyi | 9 +- django-stubs/templatetags/tz.pyi | 22 +- django-stubs/test/html.pyi | 9 +- django-stubs/utils/archive.pyi | 16 +- django-stubs/utils/datetime_safe.pyi | 17 +- django-stubs/utils/feedgenerator.pyi | 53 +-- django-stubs/utils/itercompat.pyi | 19 +- django-stubs/utils/log.pyi | 3 +- django-stubs/utils/text.pyi | 4 +- django-stubs/utils/timezone.pyi | 30 +- django-stubs/views/generic/list.pyi | 2 +- scripts/build_import_all_test.py | 29 ++ test-data/typecheck/import_all.test | 402 ++++++++++++++++++ 79 files changed, 706 insertions(+), 1155 deletions(-) create mode 100644 django-stubs/contrib/messages/constants.pyi create mode 100644 scripts/build_import_all_test.py create mode 100644 test-data/typecheck/import_all.test diff --git a/django-stubs/contrib/admin/apps.pyi b/django-stubs/contrib/admin/apps.pyi index 1e372f2..0fa9e21 100644 --- a/django-stubs/contrib/admin/apps.pyi +++ b/django-stubs/contrib/admin/apps.pyi @@ -1,25 +1,6 @@ -from typing import Any - from django.apps import AppConfig class SimpleAdminConfig(AppConfig): - apps: None - label: str - models: None - models_module: None - module: Any - path: str default_site: str = ... - name: str = ... - verbose_name: Any = ... - def ready(self) -> None: ... -class AdminConfig(SimpleAdminConfig): - apps: None - label: str - models: None - models_module: None - module: Any - name: str - path: str - def ready(self) -> None: ... +class AdminConfig(SimpleAdminConfig): ... diff --git a/django-stubs/contrib/admin/forms.pyi b/django-stubs/contrib/admin/forms.pyi index 02de4b7..fdfe7d9 100644 --- a/django-stubs/contrib/admin/forms.pyi +++ b/django-stubs/contrib/admin/forms.pyi @@ -1,33 +1,7 @@ -from typing import Any, Dict - from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm -from django.contrib.auth.models import User class AdminAuthenticationForm(AuthenticationForm): - auto_id: str - data: Dict[str, str] - empty_permitted: bool - error_class: type - fields: Dict[Any, Any] - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str - request: None - user_cache: None - error_messages: Any = ... required_css_class: str = ... - def confirm_login_allowed(self, user: User) -> None: ... class AdminPasswordChangeForm(PasswordChangeForm): - auto_id: str - data: Dict[Any, Any] - empty_permitted: bool - error_class: type - fields: Dict[Any, Any] - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str - user: Any required_css_class: str = ... diff --git a/django-stubs/contrib/admin/helpers.pyi b/django-stubs/contrib/admin/helpers.pyi index 7b5afd8..e3b5d4a 100644 --- a/django-stubs/contrib/admin/helpers.pyi +++ b/django-stubs/contrib/admin/helpers.pyi @@ -1,27 +1,17 @@ -import collections -from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Type +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union -from django import forms from django.contrib.auth.forms import AdminPasswordChangeForm -from django.db.models.fields import AutoField -from django.forms.utils import ErrorDict, ErrorList +from django.forms.boundfield import BoundField +from django.forms.utils import ErrorDict from django.forms.widgets import Media, Widget from django.utils.safestring import SafeText -from django.forms.boundfield import BoundField +from django import forms +from django.db.models.fields import AutoField ACTION_CHECKBOX_NAME: str class ActionForm(forms.Form): - auto_id: None - data: Dict[Any, Any] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str action: Any = ... select_across: Any = ... @@ -36,8 +26,8 @@ class AdminForm: form: AdminPasswordChangeForm, fieldsets: List[Tuple[None, Dict[str, List[str]]]], prepopulated_fields: Dict[Any, Any], - readonly_fields: None = ..., - model_admin: None = ..., + readonly_fields: Any = ..., + model_admin: Any = ..., ) -> None: ... def __iter__(self) -> Iterator[Fieldset]: ... @property @@ -137,7 +127,6 @@ class InlineAdminFormSet: class InlineAdminForm(AdminForm): formset: Any = ... - model_admin: Any = ... original: Any = ... show_url: Any = ... absolute_url: Any = ... @@ -152,7 +141,6 @@ class InlineAdminForm(AdminForm): model_admin: Optional[Any] = ..., view_on_site_url: Optional[Any] = ..., ) -> None: ... - def __iter__(self) -> Iterator[InlineFieldset]: ... def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ... def pk_field(self) -> AdminField: ... def fk_field(self) -> AdminField: ... @@ -162,9 +150,6 @@ class InlineAdminForm(AdminForm): class InlineFieldset(Fieldset): formset: Any = ... def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ... - def __iter__(self) -> Iterator[Fieldline]: ... class AdminErrorList(forms.utils.ErrorList): - data: List[Any] - error_class: str def __init__(self, form: Any, inline_formsets: Any) -> None: ... diff --git a/django-stubs/contrib/admin/views/autocomplete.pyi b/django-stubs/contrib/admin/views/autocomplete.pyi index 6800886..e7f2675 100644 --- a/django-stubs/contrib/admin/views/autocomplete.pyi +++ b/django-stubs/contrib/admin/views/autocomplete.pyi @@ -1,18 +1,10 @@ -from typing import Any, Optional +from typing import Any +from django.contrib.admin.options import ModelAdmin from django.core.handlers.wsgi import WSGIRequest -from django.core.paginator import Paginator -from django.db.models.query import QuerySet -from django.http.response import JsonResponse from django.views.generic.list import BaseListView class AutocompleteJsonView(BaseListView): - paginate_by: int = ... model_admin: ModelAdmin = ... term: Any = ... - paginator_class: Any = ... - object_list: Any = ... - def get(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> JsonResponse: ... - def get_paginator(self, *args: Any, **kwargs: Any) -> Paginator: ... - def get_queryset(self) -> QuerySet: ... def has_perm(self, request: WSGIRequest, obj: None = ...) -> bool: ... diff --git a/django-stubs/contrib/admin/widgets.pyi b/django-stubs/contrib/admin/widgets.pyi index 562a2eb..c39d646 100644 --- a/django-stubs/contrib/admin/widgets.pyi +++ b/django-stubs/contrib/admin/widgets.pyi @@ -1,18 +1,12 @@ -from collections import OrderedDict -from datetime import datetime -from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union +from typing import Any, Dict, List, Optional, Set, Tuple, Union from uuid import UUID +from django.contrib.admin.sites import AdminSite +from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel from django.forms.models import ModelChoiceIterator +from django.forms.widgets import ChoiceWidget, Media from django import forms -from django.contrib.admin.sites import AdminSite -from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, ManyToManyRel -from django.db.models.query_utils import Q -from django.forms.fields import Field -from django.forms.widgets import ChoiceWidget, Media, Widget, DateTimeBaseInput -from django.http.request import QueryDict -from django.utils.datastructures import MultiValueDict class FilteredSelectMultiple(forms.SelectMultiple): @property @@ -20,109 +14,34 @@ class FilteredSelectMultiple(forms.SelectMultiple): verbose_name: Any = ... is_stacked: Any = ... def __init__(self, verbose_name: str, is_stacked: bool, attrs: None = ..., choices: Tuple = ...) -> None: ... - def get_context( - self, name: str, value: Union[List[Any], str], attrs: Optional[Dict[str, str]] - ) -> Dict[ - str, - Union[ - Dict[ - str, - Union[ - Dict[str, Union[int, str]], - List[Tuple[None, List[Dict[str, Union[Dict[Any, Any], int, str]]], int]], - bool, - str, - ], - ], - Dict[str, Union[Dict[str, Union[int, str]], List[str], bool, str]], - ], - ]: ... class AdminDateWidget(forms.DateInput): - attrs: Dict[str, str] - input_type: str @property def media(self) -> Media: ... - def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ... class AdminTimeWidget(forms.TimeInput): - attrs: Dict[str, str] - input_type: str @property def media(self) -> Media: ... - def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ... -class AdminSplitDateTime(forms.SplitDateTimeWidget): - attrs: Dict[Any, Any] - widgets: List[DateTimeBaseInput] - template_name: str = ... - def __init__(self, attrs: None = ...) -> None: ... - def get_context( - self, name: str, value: Optional[Union[List[str], datetime]], attrs: Optional[Dict[str, Union[bool, str]]] - ) -> Dict[ - str, - Union[ - Dict[ - str, - Optional[ - Union[ - Dict[str, Union[bool, str]], - List[Dict[str, Optional[Union[Dict[str, Union[bool, str]], bool, str]]]], - bool, - str, - ] - ], - ], - str, - ], - ]: ... +class AdminSplitDateTime(forms.SplitDateTimeWidget): ... +class AdminRadioSelect(forms.RadioSelect): ... +class AdminFileWidget(forms.ClearableFileInput): ... -class AdminRadioSelect(forms.RadioSelect): - attrs: Dict[str, str] - template_name: str = ... - -class AdminFileWidget(forms.ClearableFileInput): - attrs: Dict[Any, Any] - template_name: str = ... - -def url_params_from_lookup_dict( - lookups: Union[ - Dict[str, Callable], Dict[str, List[str]], Dict[str, Tuple[str, str]], Dict[str, bool], Dict[str, str], Q - ] -) -> Dict[str, str]: ... +def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ... class ForeignKeyRawIdWidget(forms.TextInput): - attrs: Dict[Any, Any] - template_name: str = ... rel: ManyToOneRel = ... admin_site: AdminSite = ... db: None = ... def __init__(self, rel: ForeignObjectRel, admin_site: AdminSite, attrs: None = ..., using: None = ...) -> None: ... - def get_context( - self, name: str, value: Optional[Union[List[int], int, str, UUID]], attrs: Optional[Dict[str, Union[bool, str]]] - ) -> Dict[str, Union[Dict[str, Optional[Union[Dict[str, Union[bool, str]], bool, str]]], str]]: ... def base_url_parameters(self) -> Dict[str, str]: ... def url_parameters(self) -> Dict[str, str]: ... def label_and_url_for_value(self, value: Union[int, str, UUID]) -> Tuple[str, str]: ... -class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): - admin_site: AdminSite - attrs: Dict[Any, Any] - db: None - rel: ManyToManyRel - template_name: str = ... - def get_context( - self, name: str, value: Optional[List[int]], attrs: Optional[Dict[str, str]] - ) -> Dict[str, Union[Dict[str, Union[Dict[str, str], bool, str]], str]]: ... - def url_parameters(self) -> Dict[Any, Any]: ... - def label_and_url_for_value(self, value: List[int]) -> Tuple[str, str]: ... - def value_from_datadict(self, data: QueryDict, files: MultiValueDict, name: str) -> None: ... - def format_value(self, value: Optional[List[int]]) -> str: ... +class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ... class RelatedFieldWidgetWrapper(forms.Widget): template_name: str = ... - needs_multipart_form: bool = ... - attrs: Dict[Any, Any] = ... choices: ModelChoiceIterator = ... widget: AutocompleteSelect = ... rel: ManyToOneRel = ... @@ -141,54 +60,19 @@ class RelatedFieldWidgetWrapper(forms.Widget): can_delete_related: bool = ..., can_view_related: bool = ..., ) -> None: ... - def __deepcopy__( - self, memo: Dict[int, Union[List[Union[Field, Widget]], OrderedDict, Field, Widget]] - ) -> RelatedFieldWidgetWrapper: ... - @property - def is_hidden(self) -> bool: ... @property def media(self) -> Media: ... def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ... - def get_context( - self, name: str, value: Optional[Union[int, str]], attrs: Optional[Dict[str, Union[bool, str]]] - ) -> Dict[str, Union[bool, str]]: ... - def value_from_datadict( - self, data: QueryDict, files: MultiValueDict, name: str - ) -> Optional[Union[List[str], str]]: ... - def value_omitted_from_data(self, data: Dict[Any, Any], files: Dict[Any, Any], name: str) -> bool: ... - def id_for_label(self, id_: str) -> str: ... -class AdminTextareaWidget(forms.Textarea): - attrs: Dict[str, str] - def __init__(self, attrs: None = ...) -> None: ... - -class AdminTextInputWidget(forms.TextInput): - attrs: Dict[str, str] - input_type: str - def __init__(self, attrs: None = ...) -> None: ... - -class AdminEmailInputWidget(forms.EmailInput): - attrs: Dict[str, str] - input_type: str - def __init__(self, attrs: None = ...) -> None: ... - -class AdminURLFieldWidget(forms.URLInput): - attrs: Dict[str, str] - input_type: str - template_name: str = ... - def __init__(self, attrs: None = ...) -> None: ... - def get_context( - self, name: str, value: Optional[str], attrs: Optional[Dict[str, str]] - ) -> Dict[str, Union[Dict[str, Optional[Union[Dict[str, str], bool, str]]], str]]: ... +class AdminTextareaWidget(forms.Textarea): ... +class AdminTextInputWidget(forms.TextInput): ... +class AdminEmailInputWidget(forms.EmailInput): ... +class AdminURLFieldWidget(forms.URLInput): ... class AdminIntegerFieldWidget(forms.NumberInput): - attrs: Dict[str, str] - input_type: str class_name: str = ... - def __init__(self, attrs: None = ...) -> None: ... -class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): - class_name: str = ... +class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ... SELECT2_TRANSLATIONS: Any @@ -208,12 +92,6 @@ class AutocompleteMixin: using: None = ..., ) -> None: ... def get_url(self) -> str: ... - def build_attrs( - self, base_attrs: Dict[str, str], extra_attrs: Optional[Dict[str, Union[bool, str]]] = ... - ) -> Dict[str, Union[bool, str]]: ... - def optgroups( - self, name: str, value: List[str], attr: Dict[str, Union[bool, str]] = ... - ) -> List[Tuple[None, List[Dict[str, Union[Dict[str, bool], Set[str], int, str]]], int]]: ... @property def media(self) -> Media: ... diff --git a/django-stubs/contrib/auth/admin.pyi b/django-stubs/contrib/auth/admin.pyi index 2c541eb..69060d4 100644 --- a/django-stubs/contrib/auth/admin.pyi +++ b/django-stubs/contrib/auth/admin.pyi @@ -1,55 +1,18 @@ -from typing import Any, Dict, List, Optional, Tuple, Type, Union +from typing import Any -from django.contrib.auth.models import User, Group from django.core.handlers.wsgi import WSGIRequest -from django.db.models.fields import Field -from django.db.models.fields.related import ManyToManyField -from django.db.models.options import Options -from django.forms.models import ModelMultipleChoiceField -from django.forms.fields import Field as FormField -from django.forms.widgets import Widget from django.http.response import HttpResponse -from django.urls.resolvers import URLPattern from django.contrib import admin -from django.contrib.admin.sites import AdminSite csrf_protect_m: Any sensitive_post_parameters_m: Any -class GroupAdmin(admin.ModelAdmin): - admin_site: AdminSite - formfield_overrides: Any - model: Type[Group] - opts: Options - search_fields: Any = ... - ordering: Any = ... - filter_horizontal: Any = ... - def formfield_for_manytomany( - self, db_field: ManyToManyField, request: WSGIRequest = ..., **kwargs: Any - ) -> ModelMultipleChoiceField: ... +class GroupAdmin(admin.ModelAdmin): ... class UserAdmin(admin.ModelAdmin): - admin_site: AdminSite - formfield_overrides: Dict[Type[Field], Dict[str, Type[Union[FormField, Widget]]]] - model: Type[User] - opts: Options - add_form_template: str = ... change_user_password_template: Any = ... - fieldsets: Any = ... add_fieldsets: Any = ... - form: Any = ... add_form: Any = ... change_password_form: Any = ... - list_display: Any = ... - list_filter: Any = ... - search_fields: Any = ... - ordering: Any = ... - filter_horizontal: Any = ... - def get_fieldsets(self, request: WSGIRequest, obj: None = ...) -> Tuple[Tuple[None, Dict[str, Tuple[str]]]]: ... - def get_form(self, request: Any, obj: Optional[Any] = ..., **kwargs: Any): ... - def get_urls(self) -> List[URLPattern]: ... - def lookup_allowed(self, lookup: str, value: str) -> bool: ... - def add_view(self, request: WSGIRequest, form_url: str = ..., extra_context: None = ...) -> Any: ... def user_change_password(self, request: WSGIRequest, id: str, form_url: str = ...) -> HttpResponse: ... - def response_add(self, request: WSGIRequest, obj: User, post_url_continue: None = ...) -> HttpResponse: ... diff --git a/django-stubs/contrib/auth/apps.pyi b/django-stubs/contrib/auth/apps.pyi index f11ecbc..7764c9f 100644 --- a/django-stubs/contrib/auth/apps.pyi +++ b/django-stubs/contrib/auth/apps.pyi @@ -1,18 +1,3 @@ -from typing import Any, Optional - from django.apps import AppConfig -from .checks import check_models_permissions, check_user_model -from .management import create_permissions -from .signals import user_logged_in - -class AuthConfig(AppConfig): - apps: None - label: str - models: None - models_module: None - module: Any - path: str - name: str = ... - verbose_name: Any = ... - def ready(self) -> None: ... +class AuthConfig(AppConfig): ... diff --git a/django-stubs/contrib/auth/checks.pyi b/django-stubs/contrib/auth/checks.pyi index 1381994..9aeb20b 100644 --- a/django-stubs/contrib/auth/checks.pyi +++ b/django-stubs/contrib/auth/checks.pyi @@ -1,8 +1,6 @@ -from typing import Any, List, Optional +from typing import Any, List from django.core.checks.messages import CheckMessage -from .management import _get_builtin_permissions - def check_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ... def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ... diff --git a/django-stubs/contrib/auth/context_processors.pyi b/django-stubs/contrib/auth/context_processors.pyi index 0436df1..51a063c 100644 --- a/django-stubs/contrib/auth/context_processors.pyi +++ b/django-stubs/contrib/auth/context_processors.pyi @@ -1,22 +1,20 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict -from django.contrib.auth.models import AnonymousUser, User from django.http.request import HttpRequest -from django.utils.functional import SimpleLazyObject class PermLookupDict: - app_label: django.utils.safestring.SafeText - user: SimpleLazyObject - def __init__(self, user: SimpleLazyObject, app_label: str) -> None: ... + app_label: str + user: Any + def __init__(self, user: Any, app_label: str) -> None: ... def __getitem__(self, perm_name: str) -> bool: ... def __iter__(self) -> Any: ... def __bool__(self) -> bool: ... class PermWrapper: - user: SimpleLazyObject = ... - def __init__(self, user: Union[AnonymousUser, User]) -> None: ... + user: Any = ... + def __init__(self, user: Any) -> None: ... def __getitem__(self, app_label: str) -> PermLookupDict: ... def __iter__(self) -> Any: ... - def __contains__(self, perm_name: Union[bool, str]) -> bool: ... + def __contains__(self, perm_name: Any) -> bool: ... -def auth(request: HttpRequest) -> Dict[str, Union[PermWrapper, AnonymousUser, User]]: ... +def auth(request: HttpRequest) -> Dict[str, Any]: ... diff --git a/django-stubs/contrib/auth/forms.pyi b/django-stubs/contrib/auth/forms.pyi index 041286a..e658429 100644 --- a/django-stubs/contrib/auth/forms.pyi +++ b/django-stubs/contrib/auth/forms.pyi @@ -1,44 +1,24 @@ -import collections -import datetime -from typing import Any, Dict, Iterator, List, Optional, Union, Type +from typing import Any, Dict, Iterator, Optional from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import AbstractUser, User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.core.exceptions import ValidationError from django.core.handlers.wsgi import WSGIRequest -from django.forms.utils import ErrorList -from django.http.request import QueryDict -from django.utils.datastructures import MultiValueDict from django import forms UserModel: Any class ReadOnlyPasswordHashWidget(forms.Widget): - attrs: Dict[Any, Any] template_name: str = ... class ReadOnlyPasswordHashField(forms.Field): - widget: Any = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def bound_data(self, data: None, initial: str) -> str: ... - def has_changed(self, initial: str, data: Optional[str]) -> bool: ... -class UsernameField(forms.CharField): - def to_python(self, value: Optional[str]) -> str: ... +class UsernameField(forms.CharField): ... class UserCreationForm(forms.ModelForm): - auto_id: str - data: Dict[str, str] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[Any, Any] - instance: User - is_bound: bool - label_suffix: str error_messages: Any = ... password1: Any = ... password2: Any = ... @@ -46,30 +26,11 @@ class UserCreationForm(forms.ModelForm): def clean_password2(self) -> str: ... class UserChangeForm(forms.ModelForm): - auto_id: str - data: Dict[Any, Any] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[str, Optional[Union[List[Any], datetime.datetime, int, str]]] - instance: User - is_bound: bool - label_suffix: str password: Any = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... def clean_password(self) -> str: ... class AuthenticationForm(forms.Form): - auto_id: str - data: QueryDict - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: MultiValueDict - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str username: Any = ... password: Any = ... error_messages: Any = ... @@ -82,21 +43,12 @@ class AuthenticationForm(forms.Form): def get_invalid_login_error(self) -> ValidationError: ... class PasswordResetForm(forms.Form): - auto_id: str - data: Dict[Any, Any] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str email: Any = ... def send_mail( self, subject_template_name: str, email_template_name: str, - context: Dict[str, Union[AbstractBaseUser, str]], + context: Dict[str, Any], from_email: Optional[str], to_email: str, html_email_template_name: Optional[str] = ..., @@ -116,15 +68,6 @@ class PasswordResetForm(forms.Form): ) -> None: ... class SetPasswordForm(forms.Form): - auto_id: str - data: Dict[Any, Any] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str error_messages: Any = ... new_password1: Any = ... new_password2: Any = ... @@ -134,31 +77,10 @@ class SetPasswordForm(forms.Form): def save(self, commit: bool = ...) -> AbstractBaseUser: ... class PasswordChangeForm(SetPasswordForm): - auto_id: str - data: Dict[Any, Any] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str - user: User - error_messages: Any = ... old_password: Any = ... - field_order: Any = ... def clean_old_password(self) -> str: ... class AdminPasswordChangeForm(forms.Form): - auto_id: str - data: Dict[Any, Any] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[Any, Any] - is_bound: bool - label_suffix: str error_messages: Any = ... required_css_class: str = ... password1: Any = ... @@ -167,5 +89,3 @@ class AdminPasswordChangeForm(forms.Form): def __init__(self, user: AbstractUser, *args: Any, **kwargs: Any) -> None: ... def clean_password2(self) -> str: ... def save(self, commit: bool = ...) -> AbstractUser: ... - @property - def changed_data(self) -> List[str]: ... diff --git a/django-stubs/contrib/auth/views.pyi b/django-stubs/contrib/auth/views.pyi index e95dcb4..4c741f5 100644 --- a/django-stubs/contrib/auth/views.pyi +++ b/django-stubs/contrib/auth/views.pyi @@ -1,15 +1,10 @@ -from typing import Any, Dict, Optional, Set, Type, Union +from typing import Any, Optional, Set from django.contrib.auth.base_user import AbstractBaseUser -from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm -from django.contrib.auth.models import User -from django.contrib.sites.models import Site -from django.contrib.sites.requests import RequestSite from django.core.handlers.wsgi import WSGIRequest from django.http.request import HttpRequest -from django.http.response import HttpResponse, HttpResponseRedirect +from django.http.response import HttpResponseRedirect from django.template.response import TemplateResponse -from django.utils.datastructures import MultiValueDict from django.views.generic.base import TemplateView from django.views.generic.edit import FormView @@ -20,29 +15,18 @@ class SuccessURLAllowedHostsMixin: def get_success_url_allowed_hosts(self) -> Set[str]: ... class LoginView(SuccessURLAllowedHostsMixin, FormView): - form_class: Any = ... authentication_form: Any = ... redirect_field_name: Any = ... - template_name: str = ... redirect_authenticated_user: bool = ... extra_context: Any = ... - def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... - def get_success_url(self) -> str: ... def get_redirect_url(self) -> str: ... - def get_form_class(self) -> Type[AuthenticationForm]: ... - def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[str, str], HttpRequest, MultiValueDict]]]: ... - def form_valid(self, form: AuthenticationForm) -> HttpResponseRedirect: ... - def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ... class LogoutView(SuccessURLAllowedHostsMixin, TemplateView): next_page: Any = ... redirect_field_name: Any = ... - template_name: str = ... extra_context: Any = ... - def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def post(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> TemplateResponse: ... def get_next_page(self) -> Optional[str]: ... - def get_context_data(self, **kwargs: Any): ... def logout_then_login(request: HttpRequest, login_url: Optional[str] = ...) -> HttpResponseRedirect: ... def redirect_to_login( @@ -56,55 +40,32 @@ class PasswordContextMixin: class PasswordResetView(PasswordContextMixin, FormView): email_template_name: str = ... extra_email_context: Any = ... - form_class: Any = ... from_email: Any = ... html_email_template_name: Any = ... subject_template_name: str = ... - success_url: Any = ... - template_name: str = ... title: Any = ... token_generator: Any = ... - def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ... - def form_valid(self, form: PasswordResetForm) -> HttpResponseRedirect: ... INTERNAL_RESET_URL_TOKEN: str INTERNAL_RESET_SESSION_TOKEN: str class PasswordResetDoneView(PasswordContextMixin, TemplateView): - template_name: str = ... title: Any = ... class PasswordResetConfirmView(PasswordContextMixin, FormView): - form_class: Any = ... post_reset_login: bool = ... post_reset_login_backend: Any = ... - success_url: Any = ... - template_name: str = ... title: Any = ... token_generator: Any = ... validlink: bool = ... user: Any = ... - def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ... def get_user(self, uidb64: str) -> Optional[AbstractBaseUser]: ... - def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[Any, Any], AbstractBaseUser, MultiValueDict]]]: ... - def form_valid(self, form: SetPasswordForm) -> HttpResponseRedirect: ... - def get_context_data(self, **kwargs: Any): ... class PasswordResetCompleteView(PasswordContextMixin, TemplateView): - template_name: str = ... title: Any = ... - def get_context_data(self, **kwargs: Any): ... class PasswordChangeView(PasswordContextMixin, FormView): - form_class: Any = ... - success_url: Any = ... - template_name: str = ... title: Any = ... - def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ... - def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[Any, Any], User, MultiValueDict]]]: ... - def form_valid(self, form: PasswordChangeForm) -> HttpResponseRedirect: ... class PasswordChangeDoneView(PasswordContextMixin, TemplateView): - template_name: str = ... title: Any = ... - def dispatch(self, *args: Any, **kwargs: Any) -> TemplateResponse: ... diff --git a/django-stubs/contrib/contenttypes/apps.pyi b/django-stubs/contrib/contenttypes/apps.pyi index 17ebe27..cff43d9 100644 --- a/django-stubs/contrib/contenttypes/apps.pyi +++ b/django-stubs/contrib/contenttypes/apps.pyi @@ -1,16 +1,3 @@ -from typing import Any, Optional - from django.apps import AppConfig -from .management import create_contenttypes, inject_rename_contenttypes_operations - -class ContentTypesConfig(AppConfig): - apps: None - label: str - models: None - models_module: None - module: Any - path: str - name: str = ... - verbose_name: Any = ... - def ready(self) -> None: ... +class ContentTypesConfig(AppConfig): ... diff --git a/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi b/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi index 3d5c5fe..d432030 100644 --- a/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi +++ b/django-stubs/contrib/contenttypes/management/commands/remove_stale_contenttypes.pyi @@ -1,20 +1,13 @@ -from typing import Any, Optional +from typing import Any, Dict, List -from django.core.management import BaseCommand -from django.core.management.base import CommandParser from django.db.models.deletion import Collector -from ...management import get_contenttypes_and_models +from django.core.management import BaseCommand -class Command(BaseCommand): - stderr: django.core.management.base.OutputWrapper - stdout: django.core.management.base.OutputWrapper - style: django.core.management.color.Style - def add_arguments(self, parser: CommandParser) -> None: ... - def handle(self, **options: Any) -> None: ... +class Command(BaseCommand): ... class NoFastDeleteCollector(Collector): - data: collections.OrderedDict + data: Dict[str, Any] dependencies: Dict[Any, Any] fast_deletes: List[Any] field_updates: Dict[Any, Any] diff --git a/django-stubs/contrib/flatpages/forms.pyi b/django-stubs/contrib/flatpages/forms.pyi index e5c778f..5146154 100644 --- a/django-stubs/contrib/flatpages/forms.pyi +++ b/django-stubs/contrib/flatpages/forms.pyi @@ -1,19 +1,7 @@ -from typing import Any, Dict, Optional, Union +from typing import Any from django import forms -from django.db.models.query import QuerySet class FlatpageForm(forms.ModelForm): - auto_id: str - data: Dict[str, Union[List[int], str]] - empty_permitted: bool - error_class: Type[ErrorList] - fields: collections.OrderedDict - files: Dict[Any, Any] - initial: Dict[str, Union[List[django.contrib.sites.models.Site], int, str]] - instance: django.contrib.flatpages.models.FlatPage - is_bound: bool - label_suffix: str url: Any = ... def clean_url(self) -> str: ... - def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ... diff --git a/django-stubs/contrib/flatpages/models.pyi b/django-stubs/contrib/flatpages/models.pyi index 66b1862..330f3c7 100644 --- a/django-stubs/contrib/flatpages/models.pyi +++ b/django-stubs/contrib/flatpages/models.pyi @@ -9,5 +9,5 @@ class FlatPage(models.Model): enable_comments: models.BooleanField = ... template_name: models.CharField = ... registration_required: models.BooleanField = ... - sites: models.ManyToManyField[Site] = ... + sites: models.ManyToManyField[Site, Site] = ... def get_absolute_url(self) -> str: ... diff --git a/django-stubs/contrib/flatpages/sitemaps.pyi b/django-stubs/contrib/flatpages/sitemaps.pyi index 55b8320..e674083 100644 --- a/django-stubs/contrib/flatpages/sitemaps.pyi +++ b/django-stubs/contrib/flatpages/sitemaps.pyi @@ -1,7 +1,3 @@ -from typing import Optional - from django.contrib.sitemaps import Sitemap -from django.db.models.query import QuerySet -class FlatPageSitemap(Sitemap): - def items(self) -> QuerySet: ... +class FlatPageSitemap(Sitemap): ... diff --git a/django-stubs/contrib/messages/constants.pyi b/django-stubs/contrib/messages/constants.pyi new file mode 100644 index 0000000..c0246de --- /dev/null +++ b/django-stubs/contrib/messages/constants.pyi @@ -0,0 +1,11 @@ +from typing import Dict + +DEBUG: int = ... +INFO: int = ... +SUCCESS: int = ... +WARNING: int = ... +ERROR: int = ... + +DEFAULT_TAGS: Dict[int, str] = ... + +DEFAULT_LEVELS: Dict[str, int] = ... diff --git a/django-stubs/contrib/messages/storage/base.pyi b/django-stubs/contrib/messages/storage/base.pyi index 2bf69b6..3233e16 100644 --- a/django-stubs/contrib/messages/storage/base.pyi +++ b/django-stubs/contrib/messages/storage/base.pyi @@ -16,7 +16,7 @@ class Message: def level_tag(self) -> str: ... class BaseStorage: - request: Any = ... + request: HttpRequest = ... used: bool = ... added_new: bool = ... def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/messages/storage/cookie.pyi b/django-stubs/contrib/messages/storage/cookie.pyi index 77bcfc5..8f26738 100644 --- a/django-stubs/contrib/messages/storage/cookie.pyi +++ b/django-stubs/contrib/messages/storage/cookie.pyi @@ -1,49 +1,20 @@ import json -from typing import Any, Dict, List, Optional, Union +from typing import Any -from django.contrib.messages.storage.base import BaseStorage, Message +from django.contrib.messages.storage.base import BaseStorage class MessageEncoder(json.JSONEncoder): allow_nan: bool check_circular: bool ensure_ascii: bool - indent: None - item_separator: str - key_separator: str skipkeys: bool sort_keys: bool message_key: str = ... - def default(self, obj: Message) -> List[Union[int, str]]: ... class MessageDecoder(json.JSONDecoder): - def process_messages( - self, - obj: Union[ - Dict[ - str, Union[List[Union[Dict[str, List[Union[int, str]]], List[Union[int, str]]]], List[Union[int, str]]] - ], - List[Union[List[Union[int, str]], str]], - str, - ], - ) -> Union[ - Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], - List[Union[Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], Message]], - List[Union[Message, str]], - Message, - str, - ]: ... - def decode( - self, s: str, **kwargs: Any - ) -> Union[ - List[Union[Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], Message]], - List[Union[Message, str]], - Message, - ]: ... + def process_messages(self, obj: Any) -> Any: ... class CookieStorage(BaseStorage): - added_new: bool - request: WSGIRequest - used: bool cookie_name: str = ... max_cookie_size: int = ... not_finished: str = ... diff --git a/django-stubs/contrib/messages/storage/fallback.pyi b/django-stubs/contrib/messages/storage/fallback.pyi index 0c123d9..b6e0d49 100644 --- a/django-stubs/contrib/messages/storage/fallback.pyi +++ b/django-stubs/contrib/messages/storage/fallback.pyi @@ -1,11 +1,8 @@ -from typing import Any, Optional +from typing import Any from django.contrib.messages.storage.base import BaseStorage class FallbackStorage(BaseStorage): - added_new: bool - request: WSGIRequest - used: bool storage_classes: Any = ... storages: Any = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/django-stubs/contrib/messages/storage/session.pyi b/django-stubs/contrib/messages/storage/session.pyi index f631bdd..8ba6281 100644 --- a/django-stubs/contrib/messages/storage/session.pyi +++ b/django-stubs/contrib/messages/storage/session.pyi @@ -1,15 +1,10 @@ -from typing import Any, List, Optional, Union +from typing import Any, List, Optional, Sequence, Union -from django.contrib.messages.storage.base import BaseStorage, Message +from django.contrib.messages.storage.base import BaseStorage from django.http.request import HttpRequest class SessionStorage(BaseStorage): - added_new: bool - request: WSGIRequest - used: bool session_key: str = ... def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... - def serialize_messages(self, messages: Union[List[Message], List[str]]) -> str: ... - def deserialize_messages( - self, data: Optional[Union[List[Any], str]] - ) -> Optional[Union[List[Message], List[str]]]: ... + def serialize_messages(self, messages: Sequence[Any]) -> str: ... + def deserialize_messages(self, data: Optional[Union[List[Any], str]]) -> Optional[List[Any]]: ... diff --git a/django-stubs/contrib/sessions/backends/cache.pyi b/django-stubs/contrib/sessions/backends/cache.pyi index 0db2a6c..865393b 100644 --- a/django-stubs/contrib/sessions/backends/cache.pyi +++ b/django-stubs/contrib/sessions/backends/cache.pyi @@ -1,23 +1,11 @@ -from typing import Any, Dict, Optional +from typing import Any, Optional from django.contrib.sessions.backends.base import SessionBase -from django.contrib.sessions.serializers import JSONSerializer - KEY_PREFIX: str class SessionStore(SessionBase): - accessed: bool - serializer: JSONSerializer cache_key_prefix: Any = ... def __init__(self, session_key: Optional[str] = ...) -> None: ... @property def cache_key(self) -> str: ... - def load(self) -> Dict[str, str]: ... - modified: bool = ... - def create(self) -> None: ... - def save(self, must_create: bool = ...) -> None: ... - def exists(self, session_key: Optional[str]) -> bool: ... - def delete(self, session_key: Optional[str] = ...) -> None: ... - @classmethod - def clear_expired(cls) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/cached_db.pyi b/django-stubs/contrib/sessions/backends/cached_db.pyi index f0d3657..b49ef90 100644 --- a/django-stubs/contrib/sessions/backends/cached_db.pyi +++ b/django-stubs/contrib/sessions/backends/cached_db.pyi @@ -1,19 +1,11 @@ -from typing import Any, Dict, Optional +from typing import Any, Optional from django.contrib.sessions.backends.db import SessionStore as DBStore KEY_PREFIX: str class SessionStore(DBStore): - accessed: bool - modified: bool - serializer: Type[django.core.signing.JSONSerializer] cache_key_prefix: Any = ... def __init__(self, session_key: Optional[str] = ...) -> None: ... @property def cache_key(self) -> str: ... - def load(self) -> Dict[str, str]: ... - def exists(self, session_key: Optional[str]) -> bool: ... - def save(self, must_create: bool = ...) -> None: ... - def delete(self, session_key: Optional[str] = ...) -> None: ... - def flush(self) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/db.pyi b/django-stubs/contrib/sessions/backends/db.pyi index f56e83a..ff53e43 100644 --- a/django-stubs/contrib/sessions/backends/db.pyi +++ b/django-stubs/contrib/sessions/backends/db.pyi @@ -1,24 +1,13 @@ -from typing import Dict, Optional, Type, Union +from typing import Dict, Optional, Type from django.contrib.sessions.backends.base import SessionBase from django.contrib.sessions.base_session import AbstractBaseSession from django.contrib.sessions.models import Session -from django.core.signing import Serializer from django.db.models.base import Model class SessionStore(SessionBase): - accessed: bool - serializer: Type[Serializer] def __init__(self, session_key: Optional[str] = ...) -> None: ... @classmethod def get_model_class(cls) -> Type[Session]: ... def model(self) -> Type[AbstractBaseSession]: ... - def load(self) -> Dict[str, Union[Model, int, str]]: ... - def exists(self, session_key: Optional[str]) -> bool: ... - modified: bool = ... - def create(self) -> None: ... def create_model_instance(self, data: Dict[str, Model]) -> AbstractBaseSession: ... - def save(self, must_create: bool = ...) -> None: ... - def delete(self, session_key: Optional[str] = ...) -> None: ... - @classmethod - def clear_expired(cls) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/file.pyi b/django-stubs/contrib/sessions/backends/file.pyi index 56eb636..96e2046 100644 --- a/django-stubs/contrib/sessions/backends/file.pyi +++ b/django-stubs/contrib/sessions/backends/file.pyi @@ -1,19 +1,9 @@ -from typing import Any, Dict, Optional, Union +from typing import Optional from django.contrib.sessions.backends.base import SessionBase class SessionStore(SessionBase): - accessed: bool - serializer: Type[django.core.signing.JSONSerializer] storage_path: str = ... file_prefix: str = ... def __init__(self, session_key: Optional[str] = ...) -> None: ... - def load(self) -> Dict[str, Union[int, str]]: ... - modified: bool = ... - def create(self) -> None: ... - def save(self, must_create: bool = ...) -> None: ... - def exists(self, session_key: Optional[str]) -> bool: ... - def delete(self, session_key: Optional[str] = ...) -> None: ... def clean(self) -> None: ... - @classmethod - def clear_expired(cls) -> None: ... diff --git a/django-stubs/contrib/sessions/backends/signed_cookies.pyi b/django-stubs/contrib/sessions/backends/signed_cookies.pyi index 7f4dc5d..f82ead5 100644 --- a/django-stubs/contrib/sessions/backends/signed_cookies.pyi +++ b/django-stubs/contrib/sessions/backends/signed_cookies.pyi @@ -1,17 +1,3 @@ -from datetime import datetime -from typing import Any, Dict, Optional, Union - from django.contrib.sessions.backends.base import SessionBase -class SessionStore(SessionBase): - accessed: bool - serializer: Type[django.core.signing.JSONSerializer] - def load(self) -> Dict[str, Union[datetime, str]]: ... - modified: bool = ... - def create(self) -> None: ... - def save(self, must_create: bool = ...) -> None: ... - def exists(self, session_key: Optional[str] = ...) -> bool: ... - def delete(self, session_key: Optional[str] = ...) -> None: ... - def cycle_key(self) -> None: ... - @classmethod - def clear_expired(cls) -> None: ... +class SessionStore(SessionBase): ... diff --git a/django-stubs/contrib/sessions/management/commands/clearsessions.pyi b/django-stubs/contrib/sessions/management/commands/clearsessions.pyi index 963c39b..8d75fb4 100644 --- a/django-stubs/contrib/sessions/management/commands/clearsessions.pyi +++ b/django-stubs/contrib/sessions/management/commands/clearsessions.pyi @@ -1,10 +1,3 @@ -from typing import Any, Optional - from django.core.management.base import BaseCommand -class Command(BaseCommand): - stderr: django.core.management.base.OutputWrapper - stdout: django.core.management.base.OutputWrapper - style: django.core.management.color.Style - help: str = ... - def handle(self, **options: Any) -> None: ... +class Command(BaseCommand): ... diff --git a/django-stubs/contrib/sitemaps/__init__.pyi b/django-stubs/contrib/sitemaps/__init__.pyi index 3917df2..31897e2 100644 --- a/django-stubs/contrib/sitemaps/__init__.pyi +++ b/django-stubs/contrib/sitemaps/__init__.pyi @@ -15,7 +15,7 @@ def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None: class Sitemap: limit: int = ... - protocol: Any = ... + protocol: Optional[str] = ... def items(self) -> List[Any]: ... def location(self, obj: Model) -> str: ... @property @@ -29,7 +29,6 @@ class GenericSitemap(Sitemap): changefreq: Optional[str] = ... queryset: QuerySet = ... date_field: None = ... - protocol: Optional[str] = ... def __init__( self, info_dict: Dict[str, Union[datetime, QuerySet, str]], @@ -37,7 +36,6 @@ class GenericSitemap(Sitemap): changefreq: Optional[str] = ..., protocol: Optional[str] = ..., ) -> None: ... - def items(self) -> QuerySet: ... def lastmod(self, item: Model) -> Optional[datetime]: ... default_app_config: str diff --git a/django-stubs/contrib/sites/apps.pyi b/django-stubs/contrib/sites/apps.pyi index 16b7830..75db9af 100644 --- a/django-stubs/contrib/sites/apps.pyi +++ b/django-stubs/contrib/sites/apps.pyi @@ -1,14 +1,3 @@ -from typing import Any - from django.apps import AppConfig -class SitesConfig(AppConfig): - apps: None - label: str - models: None - models_module: None - module: Any - path: str - name: str = ... - verbose_name: Any = ... - def ready(self) -> None: ... +class SitesConfig(AppConfig): ... diff --git a/django-stubs/contrib/staticfiles/apps.pyi b/django-stubs/contrib/staticfiles/apps.pyi index e709495..e2787b8 100644 --- a/django-stubs/contrib/staticfiles/apps.pyi +++ b/django-stubs/contrib/staticfiles/apps.pyi @@ -1,15 +1,6 @@ -from typing import Any, Optional +from typing import Any from django.apps import AppConfig class StaticFilesConfig(AppConfig): - apps: None - label: str - models: None - models_module: None - module: Any - path: str - name: str = ... - verbose_name: Any = ... ignore_patterns: Any = ... - def ready(self) -> None: ... diff --git a/django-stubs/contrib/staticfiles/finders.pyi b/django-stubs/contrib/staticfiles/finders.pyi index aa5842a..eb6bc13 100644 --- a/django-stubs/contrib/staticfiles/finders.pyi +++ b/django-stubs/contrib/staticfiles/finders.pyi @@ -1,25 +1,21 @@ -from typing import Any, Iterator, List, Optional, Tuple, Union, Mapping, overload +from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload -from django.contrib.staticfiles.storage import StaticFilesStorage from django.core.checks.messages import Error -from django.core.files.storage import DefaultStorage, FileSystemStorage, Storage +from django.core.files.storage import Storage from typing_extensions import Literal searched_locations: Any class BaseFinder: - def check(self, **kwargs: Any) -> Any: ... - def find(self, path: Any, all: bool = ...) -> None: ... - def list(self, ignore_patterns: Any) -> None: ... + def check(self, **kwargs: Any) -> List[Error]: ... + def find(self, path: str, all: bool = ...) -> Optional[Any]: ... + def list(self, ignore_patterns: Any) -> Iterable[Any]: ... class FileSystemFinder(BaseFinder): locations: List[Any] = ... storages: Mapping[str, Any] = ... def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ... - def check(self, **kwargs: Any) -> List[Error]: ... - def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ... def find_location(self, root: str, path: str, prefix: str = ...) -> Optional[str]: ... - def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ... class AppDirectoriesFinder(BaseFinder): storage_class: Any = ... @@ -27,15 +23,11 @@ class AppDirectoriesFinder(BaseFinder): apps: List[str] = ... storages: Mapping[str, Any] = ... def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ... - def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ... - def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ... def find_in_app(self, app: str, path: str) -> Optional[str]: ... class BaseStorageFinder(BaseFinder): storage: Storage = ... def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ... - def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ... - def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, DefaultStorage]]: ... class DefaultStorageFinder(BaseStorageFinder): ... diff --git a/django-stubs/contrib/staticfiles/handlers.pyi b/django-stubs/contrib/staticfiles/handlers.pyi index 941c0ec..11c6b9c 100644 --- a/django-stubs/contrib/staticfiles/handlers.pyi +++ b/django-stubs/contrib/staticfiles/handlers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.core.handlers.wsgi import WSGIHandler, WSGIRequest @@ -7,9 +7,6 @@ class StaticFilesHandler(WSGIHandler): application: WSGIHandler = ... base_url: Any = ... def __init__(self, application: WSGIHandler) -> None: ... - def load_middleware(self) -> None: ... def get_base_url(self) -> str: ... def file_path(self, url: str) -> str: ... def serve(self, request: WSGIRequest) -> Any: ... - def get_response(self, request: WSGIRequest) -> Any: ... - def __call__(self, environ: Any, start_response: Any): ... diff --git a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi index ad9cb10..49ad344 100644 --- a/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/collectstatic.pyi @@ -1,22 +1,16 @@ -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List from django.core.files.storage import FileSystemStorage -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import BaseCommand class Command(BaseCommand): - stderr: django.core.management.base.OutputWrapper - stdout: django.core.management.base.OutputWrapper - help: str = ... - requires_system_checks: bool = ... copied_files: Any = ... symlinked_files: Any = ... unmodified_files: Any = ... post_processed_files: Any = ... storage: Any = ... - style: django.core.management.color.Style = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... def local(self) -> bool: ... - def add_arguments(self, parser: CommandParser) -> None: ... interactive: Any = ... verbosity: Any = ... symlink: Any = ... @@ -26,7 +20,6 @@ class Command(BaseCommand): post_process: Any = ... def set_options(self, **options: Any) -> None: ... def collect(self) -> Dict[str, List[str]]: ... - def handle(self, **options: Any) -> Optional[str]: ... def log(self, msg: str, level: int = ...) -> None: ... def is_local_storage(self) -> bool: ... def clear_dir(self, path: str) -> None: ... diff --git a/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi b/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi index e6d2891..be61bcb 100644 --- a/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/findstatic.pyi @@ -1,12 +1,3 @@ -from typing import Any, Optional +from django.core.management.base import LabelCommand -from django.core.management.base import CommandParser, LabelCommand - -class Command(LabelCommand): - stderr: django.core.management.base.OutputWrapper - stdout: django.core.management.base.OutputWrapper - style: django.core.management.color.Style - help: str = ... - label: str = ... - def add_arguments(self, parser: CommandParser) -> None: ... - def handle_label(self, path: str, **options: Any) -> str: ... +class Command(LabelCommand): ... diff --git a/django-stubs/contrib/staticfiles/management/commands/runserver.pyi b/django-stubs/contrib/staticfiles/management/commands/runserver.pyi index f8e1ee3..20cfd79 100644 --- a/django-stubs/contrib/staticfiles/management/commands/runserver.pyi +++ b/django-stubs/contrib/staticfiles/management/commands/runserver.pyi @@ -1,13 +1,3 @@ -from typing import Any, Optional +from django.core.management.commands.runserver import Command as RunserverCommand # type: ignore -from django.contrib.staticfiles.handlers import StaticFilesHandler -from django.core.management.base import CommandParser -from django.core.management.commands.runserver import Command as RunserverCommand - -class Command(RunserverCommand): - stderr: django.core.management.base.OutputWrapper - stdout: django.core.management.base.OutputWrapper - style: django.core.management.color.Style - help: str = ... - def add_arguments(self, parser: CommandParser) -> None: ... - def get_handler(self, *args: Any, **options: Any) -> StaticFilesHandler: ... +class Command(RunserverCommand): ... diff --git a/django-stubs/contrib/staticfiles/storage.pyi b/django-stubs/contrib/staticfiles/storage.pyi index 7423520..965a29d 100644 --- a/django-stubs/contrib/staticfiles/storage.pyi +++ b/django-stubs/contrib/staticfiles/storage.pyi @@ -20,7 +20,6 @@ class HashedFilesMixin: def __init__(self, *args: Any, **kwargs: Any) -> None: ... def file_hash(self, name: str, content: File = ...) -> str: ... def hashed_name(self, name: str, content: Optional[File] = ..., filename: Optional[str] = ...) -> str: ... - def url(self, name: SafeText, force: bool = ...) -> str: ... def url_converter(self, name: str, hashed_files: OrderedDict, template: str = ...) -> Callable: ... def post_process( self, paths: OrderedDict, dry_run: bool = ..., **options: Any @@ -33,16 +32,13 @@ class ManifestFilesMixin(HashedFilesMixin): manifest_version: str = ... manifest_name: str = ... manifest_strict: bool = ... - hashed_files: Any = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... def read_manifest(self) -> Any: ... def load_manifest(self) -> OrderedDict: ... - def post_process(self, *args: Any, **kwargs: Any) -> None: ... def save_manifest(self) -> None: ... - def stored_name(self, name: str) -> str: ... class _MappingCache: - cache: django.core.cache.DefaultCacheProxy = ... + cache: Any = ... def __init__(self, cache: Any) -> None: ... def __setitem__(self, key: Any, value: Any) -> None: ... def __getitem__(self, key: Any): ... @@ -51,9 +47,7 @@ class _MappingCache: def get(self, key: Any, default: Optional[Any] = ...): ... class CachedFilesMixin(HashedFilesMixin): - hashed_files: Any = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... - def hash_key(self, name: str) -> str: ... class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): ... class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ... diff --git a/django-stubs/core/cache/backends/base.pyi b/django-stubs/core/cache/backends/base.pyi index 52f2910..9f12420 100644 --- a/django-stubs/core/cache/backends/base.pyi +++ b/django-stubs/core/cache/backends/base.pyi @@ -1,5 +1,4 @@ -from collections import OrderedDict -from typing import Any, Callable, Dict, List, Optional, Union +from typing import Any, Callable, Dict, Iterable, List, Optional, Union from django.core.exceptions import ImproperlyConfigured @@ -9,7 +8,7 @@ class CacheKeyWarning(RuntimeWarning): ... DEFAULT_TIMEOUT: Any MEMCACHE_MAX_KEY_LENGTH: int -def default_key_func(key: Union[int, str], key_prefix: str, version: Union[int, str]) -> str: ... +def default_key_func(key: Any, key_prefix: str, version: Any) -> str: ... def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ... class BaseCache: @@ -17,9 +16,9 @@ class BaseCache: key_prefix: str = ... version: int = ... key_func: Callable = ... - def __init__(self, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ... + def __init__(self, params: Dict[str, Any]) -> None: ... def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ... - def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> str: ... + def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ... def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ... def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... @@ -27,19 +26,14 @@ class BaseCache: def delete(self, key: Any, version: Optional[Any] = ...) -> None: ... def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ... def get_or_set( - self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ... - ) -> Optional[Union[int, str]]: ... + self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ... + ) -> Optional[Any]: ... def has_key(self, key: Any, version: Optional[Any] = ...): ... def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... def __contains__(self, key: str) -> bool: ... - def set_many( - self, - data: Union[Dict[str, bytes], Dict[str, int], Dict[str, str], OrderedDict], - timeout: Any = ..., - version: Optional[Union[int, str]] = ..., - ) -> List[Any]: ... - def delete_many(self, keys: Union[Dict[str, str], List[str]], version: None = ...) -> None: ... + def set_many(self, data: Dict[str, Any], timeout: Any = ..., version: Optional[Any] = ...) -> List[Any]: ... + def delete_many(self, keys: Iterable[Any], version: Optional[Any] = ...) -> None: ... def clear(self) -> None: ... def validate_key(self, key: str) -> None: ... def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... diff --git a/django-stubs/core/cache/backends/db.pyi b/django-stubs/core/cache/backends/db.pyi index f20e31a..82fb34a 100644 --- a/django-stubs/core/cache/backends/db.pyi +++ b/django-stubs/core/cache/backends/db.pyi @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Optional, Union +from typing import Any, Dict from django.core.cache.backends.base import BaseCache @@ -16,24 +16,7 @@ class Options: def __init__(self, table: str) -> None: ... class BaseDatabaseCache(BaseCache): - default_timeout: int - key_func: Callable - key_prefix: str - version: int cache_model_class: Any = ... - def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ... + def __init__(self, table: str, params: Dict[str, Any]) -> None: ... -class DatabaseCache(BaseDatabaseCache): - default_timeout: int - key_func: Callable - key_prefix: str - version: int - def get(self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...) -> Any: ... - def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ... - def add( - self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ... - ) -> bool: ... - def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ... - def delete(self, key: str, version: Optional[int] = ...) -> None: ... - def has_key(self, key: str, version: Optional[int] = ...) -> Any: ... - def clear(self) -> None: ... +class DatabaseCache(BaseDatabaseCache): ... diff --git a/django-stubs/core/cache/backends/dummy.pyi b/django-stubs/core/cache/backends/dummy.pyi index 8cab85d..8984faa 100644 --- a/django-stubs/core/cache/backends/dummy.pyi +++ b/django-stubs/core/cache/backends/dummy.pyi @@ -1,19 +1,6 @@ -from typing import Any, Dict, Optional, Union, Callable +from typing import Any from django.core.cache.backends.base import BaseCache class DummyCache(BaseCache): - default_timeout: int - key_func: Callable - key_prefix: str - version: int def __init__(self, host: str, *args: Any, **kwargs: Any) -> None: ... - def add(self, key: str, value: str, timeout: Any = ..., version: None = ...) -> bool: ... - def get(self, key: str, default: Optional[str] = ..., version: Optional[int] = ...) -> Optional[str]: ... - def set( - self, key: str, value: Union[Dict[str, Any], int, str], timeout: Any = ..., version: Optional[str] = ... - ) -> None: ... - def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ... - def delete(self, key: str, version: None = ...) -> None: ... - def has_key(self, key: str, version: None = ...) -> bool: ... - def clear(self) -> None: ... diff --git a/django-stubs/core/cache/backends/filebased.pyi b/django-stubs/core/cache/backends/filebased.pyi index 8a01b34..f8e0e15 100644 --- a/django-stubs/core/cache/backends/filebased.pyi +++ b/django-stubs/core/cache/backends/filebased.pyi @@ -1,22 +1,7 @@ -from typing import Any, Callable, Dict, Optional, Union +from typing import Any, Dict from django.core.cache.backends.base import BaseCache class FileBasedCache(BaseCache): - default_timeout: int - key_func: Callable - key_prefix: str - version: int cache_suffix: str = ... - def __init__(self, dir: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ... - def add( - self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ... - ) -> bool: ... - def get( - self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ... - ) -> Optional[str]: ... - def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ... - def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ... - def delete(self, key: str, version: Optional[int] = ...) -> None: ... - def has_key(self, key: str, version: Optional[int] = ...) -> bool: ... - def clear(self) -> None: ... + def __init__(self, dir: str, params: Dict[str, Any]) -> None: ... diff --git a/django-stubs/core/files/locks.pyi b/django-stubs/core/files/locks.pyi index 56724de..768114f 100644 --- a/django-stubs/core/files/locks.pyi +++ b/django-stubs/core/files/locks.pyi @@ -1,17 +1,15 @@ -from ctypes import Structure, c_int64, c_ulong, c_void_p -from io import BufferedRandom, TextIOWrapper -from typing import Union +from ctypes import Structure, Union +from typing import Any LOCK_SH: int LOCK_NB: int LOCK_EX: int -ULONG_PTR = c_int64 -ULONG_PTR = c_ulong -PVOID = c_void_p +ULONG_PTR: Any = ... +PVOID: Any = ... class _OFFSET(Structure): ... class _OFFSET_UNION(Union): ... class OVERLAPPED(Structure): ... -def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ... -def unlock(f: Union[BufferedRandom, int]) -> bool: ... +def lock(f: Any, flags: int) -> bool: ... +def unlock(f: Any) -> bool: ... diff --git a/django-stubs/core/mail/__init__.pyi b/django-stubs/core/mail/__init__.pyi index 40d7c6a..02e762e 100644 --- a/django-stubs/core/mail/__init__.pyi +++ b/django-stubs/core/mail/__init__.pyi @@ -1,6 +1,5 @@ from typing import Any, List, Optional, Tuple -from .backends.base import BaseEmailBackend from .message import ( BadHeaderError as BadHeaderError, DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE, @@ -12,7 +11,7 @@ from .message import ( ) from .utils import CachedDnsName as CachedDnsName, DNS_NAME as DNS_NAME -def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> BaseEmailBackend: ... +def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> Any: ... def send_mail( subject: str, message: str, @@ -21,7 +20,7 @@ def send_mail( fail_silently: bool = ..., auth_user: Optional[str] = ..., auth_password: Optional[str] = ..., - connection: Optional[BaseEmailBackend] = ..., + connection: Optional[Any] = ..., html_message: Optional[str] = ..., ) -> int: ... def send_mass_mail( @@ -29,20 +28,20 @@ def send_mass_mail( fail_silently: bool = ..., auth_user: Optional[str] = ..., auth_password: Optional[str] = ..., - connection: Optional[BaseEmailBackend] = ..., + connection: Optional[Any] = ..., ) -> int: ... def mail_admins( subject: str, message: str, fail_silently: bool = ..., - connection: Optional[BaseEmailBackend] = ..., + connection: Optional[Any] = ..., html_message: Optional[str] = ..., ) -> None: ... def mail_managers( subject: str, message: str, fail_silently: bool = ..., - connection: Optional[BaseEmailBackend] = ..., + connection: Optional[Any] = ..., html_message: Optional[str] = ..., ) -> None: ... diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index c52e8ec..720ac5f 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -1,11 +1,8 @@ -from email._policybase import Policy +from email._policybase import Policy # type: ignore from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from typing import Any, Dict, List, Optional, Tuple, Union, Sequence - -from django.core.mail.backends.base import BaseEmailBackend -from django.utils.safestring import SafeText +from typing import Any, Dict, List, Optional, Sequence, Tuple, Union utf8_charset: Any utf8_charset_qp: Any @@ -20,16 +17,13 @@ def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str, def split_addr(addr: str, encoding: str) -> Tuple[str, str]: ... def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ... -class MIMEMixin: - def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ... - def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ... +class MIMEMixin: ... class SafeMIMEMessage(MIMEMixin, MIMEMessage): defects: List[Any] epilogue: None policy: Policy preamble: None - def __setitem__(self, name: str, val: str) -> None: ... class SafeMIMEText(MIMEMixin, MIMEText): defects: List[Any] @@ -38,8 +32,6 @@ class SafeMIMEText(MIMEMixin, MIMEText): preamble: None encoding: str = ... def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ... - def __setitem__(self, name: str, val: str) -> None: ... - def set_payload(self, payload: str, charset: str = ...) -> None: ... class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): defects: List[Any] @@ -50,7 +42,6 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): def __init__( self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any ) -> None: ... - def __setitem__(self, name: str, val: str) -> None: ... class EmailMessage: content_subtype: str = ... @@ -65,7 +56,7 @@ class EmailMessage: body: str = ... attachments: List[Any] = ... extra_headers: Dict[Any, Any] = ... - connection: None = ... + connection: Any = ... def __init__( self, subject: str = ..., @@ -73,13 +64,13 @@ class EmailMessage: from_email: Optional[str] = ..., to: Optional[Union[Sequence[str], str]] = ..., bcc: Optional[Union[Sequence[str], str]] = ..., - connection: Optional[BaseEmailBackend] = ..., + connection: Optional[Any] = ..., attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ..., headers: Optional[Dict[str, str]] = ..., cc: Optional[Union[Sequence[str], str]] = ..., reply_to: Optional[Union[List[Optional[str]], str]] = ..., ) -> None: ... - def get_connection(self, fail_silently: bool = ...) -> BaseEmailBackend: ... + def get_connection(self, fail_silently: bool = ...) -> Any: ... def message(self) -> MIMEMixin: ... def recipients(self) -> List[str]: ... def send(self, fail_silently: bool = ...) -> int: ... @@ -92,16 +83,6 @@ class EmailMessage: def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ... class EmailMultiAlternatives(EmailMessage): - attachments: List[Any] - bcc: List[Any] - body: SafeText - cc: List[Any] - connection: None - extra_headers: Dict[Any, Any] - from_email: str - reply_to: List[Any] - subject: str - to: List[str] alternative_subtype: str = ... alternatives: Any = ... def __init__( @@ -111,7 +92,7 @@ class EmailMultiAlternatives(EmailMessage): from_email: Optional[str] = ..., to: Optional[List[str]] = ..., bcc: Optional[List[str]] = ..., - connection: Optional[BaseEmailBackend] = ..., + connection: Optional[Any] = ..., attachments: None = ..., headers: Optional[Dict[str, str]] = ..., alternatives: Optional[List[Tuple[str, str]]] = ..., diff --git a/django-stubs/core/management/templates.pyi b/django-stubs/core/management/templates.pyi index 8147cae..f3df51d 100644 --- a/django-stubs/core/management/templates.pyi +++ b/django-stubs/core/management/templates.pyi @@ -1,16 +1,13 @@ -from typing import Any, Optional +from typing import Any -from django.core.management.base import BaseCommand, CommandParser +from django.core.management.base import BaseCommand class TemplateCommand(BaseCommand): - requires_system_checks: bool = ... url_schemes: Any = ... rewrite_template_suffixes: Any = ... - def add_arguments(self, parser: CommandParser) -> None: ... app_or_project: Any = ... paths_to_remove: Any = ... verbosity: Any = ... - def handle(self, app_or_project: Any, name: Any, target: Optional[Any] = ..., **options: Any): ... def handle_template(self, template: Any, subdir: Any): ... def validate_name(self, name: Any, app_or_project: Any) -> None: ... def download(self, url: Any): ... diff --git a/django-stubs/db/backends/base/base.pyi b/django-stubs/db/backends/base/base.pyi index 5bcc9e0..29a2883 100644 --- a/django-stubs/db/backends/base/base.pyi +++ b/django-stubs/db/backends/base/base.pyi @@ -1,9 +1,16 @@ from typing import Any, Callable, Dict, Iterator, List, Optional +from django.db.backends.base.client import BaseDatabaseClient +from django.db.backends.base.creation import BaseDatabaseCreation +from django.db.backends.base.validation import BaseDatabaseValidation from django.db.backends.utils import CursorDebugWrapper, CursorWrapper from django.db.backends.base.schema import BaseDatabaseSchemaEditor +from django.db.backends.base.features import BaseDatabaseFeatures + +from django.db.backends.base.introspection import BaseDatabaseIntrospection + NO_DB_ALIAS: str class BaseDatabaseWrapper: @@ -23,7 +30,7 @@ class BaseDatabaseWrapper: queries_limit: int = ... connection: Any = ... settings_dict: Any = ... - alias: Any = ... + alias: str = ... queries_log: Any = ... force_debug_cursor: bool = ... autocommit: bool = ... @@ -32,18 +39,18 @@ class BaseDatabaseWrapper: savepoint_ids: Any = ... commit_on_exit: bool = ... needs_rollback: bool = ... - close_at: Any = ... + close_at: Optional[Any] = ... closed_in_transaction: bool = ... errors_occurred: bool = ... - allow_thread_sharing: Any = ... - run_on_commit: Any = ... + allow_thread_sharing: bool = ... + run_on_commit: List[Any] = ... run_commit_hooks_on_set_autocommit_on: bool = ... - execute_wrappers: Any = ... - client: Any = ... - creation: Any = ... - features: Any = ... - introspection: Any = ... - validation: Any = ... + execute_wrappers: List[Any] = ... + client: BaseDatabaseClient = ... + creation: BaseDatabaseCreation = ... + features: BaseDatabaseFeatures = ... + introspection: BaseDatabaseIntrospection = ... + validation: BaseDatabaseValidation = ... def __init__( self, settings_dict: Dict[str, Dict[str, str]], alias: str = ..., allow_thread_sharing: bool = ... ) -> None: ... diff --git a/django-stubs/db/backends/base/schema.pyi b/django-stubs/db/backends/base/schema.pyi index 6acdf05..586a25b 100644 --- a/django-stubs/db/backends/base/schema.pyi +++ b/django-stubs/db/backends/base/schema.pyi @@ -1,13 +1,14 @@ -from typing import Any, List, Optional, Tuple, Type, Union +from typing import Any, ContextManager, List, Optional, Sequence, Tuple, Type, Union from django.db.backends.ddl_references import Statement from django.db.models.base import Model -from django.db.models.fields import Field from django.db.models.indexes import Index +from django.db.models.fields import Field + logger: Any -class BaseDatabaseSchemaEditor: +class BaseDatabaseSchemaEditor(ContextManager[Any]): sql_create_table: str = ... sql_rename_table: str = ... sql_retablespace_table: str = ... @@ -27,7 +28,7 @@ class BaseDatabaseSchemaEditor: sql_create_unique: str = ... sql_delete_unique: str = ... sql_create_fk: str = ... - sql_create_inline_fk: Any = ... + sql_create_inline_fk: str = ... sql_delete_fk: str = ... sql_create_index: str = ... sql_delete_index: str = ... @@ -35,14 +36,14 @@ class BaseDatabaseSchemaEditor: sql_delete_pk: str = ... sql_delete_procedure: str = ... connection: Any = ... - collect_sql: Any = ... + collect_sql: bool = ... collected_sql: Any = ... atomic_migration: Any = ... def __init__(self, connection: Any, collect_sql: bool = ..., atomic: bool = ...) -> None: ... deferred_sql: Any = ... atomic: Any = ... def __enter__(self) -> BaseDatabaseSchemaEditor: ... - def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ... + def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: ... def execute(self, sql: Union[Statement, str], params: Optional[Union[List[int], Tuple]] = ...) -> None: ... def quote_name(self, name: str) -> str: ... def column_sql( @@ -59,14 +60,14 @@ class BaseDatabaseSchemaEditor: def alter_unique_together( self, model: Type[Model], - old_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]], - new_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]], + old_unique_together: Sequence[Sequence[str]], + new_unique_together: Sequence[Sequence[str]], ) -> None: ... def alter_index_together( self, model: Type[Model], - old_index_together: Union[List[List[str]], List[Tuple[str, str]]], - new_index_together: Union[List[List[str]], List[Tuple[str, str]]], + old_index_together: Sequence[Sequence[str]], + new_index_together: Sequence[Sequence[str]], ) -> None: ... def alter_db_table(self, model: Type[Model], old_db_table: str, new_db_table: str) -> None: ... def alter_db_tablespace(self, model: Any, old_db_tablespace: Any, new_db_tablespace: Any) -> None: ... diff --git a/django-stubs/db/backends/dummy/base.pyi b/django-stubs/db/backends/dummy/base.pyi index 9f7e431..93dd162 100644 --- a/django-stubs/db/backends/dummy/base.pyi +++ b/django-stubs/db/backends/dummy/base.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.client import BaseDatabaseClient @@ -10,20 +10,16 @@ def complain(*args: Any, **kwargs: Any) -> Any: ... def ignore(*args: Any, **kwargs: Any) -> None: ... class DatabaseOperations(BaseDatabaseOperations): - connection: django.db.backends.dummy.base.DatabaseWrapper quote_name: Any = ... class DatabaseClient(BaseDatabaseClient): - connection: django.db.backends.dummy.base.DatabaseWrapper runshell: Any = ... class DatabaseCreation(BaseDatabaseCreation): - connection: django.db.backends.dummy.base.DatabaseWrapper create_test_db: Any = ... destroy_test_db: Any = ... class DatabaseIntrospection(BaseDatabaseIntrospection): - connection: django.db.backends.dummy.base.DatabaseWrapper get_table_list: Any = ... get_table_description: Any = ... get_relations: Any = ... @@ -31,35 +27,5 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): get_key_columns: Any = ... class DatabaseWrapper(BaseDatabaseWrapper): - alias: str - allow_thread_sharing: bool - autocommit: bool - client: django.db.backends.dummy.base.DatabaseClient - close_at: None - closed_in_transaction: bool - commit_on_exit: bool - connection: None - creation: django.db.backends.dummy.base.DatabaseCreation - errors_occurred: bool - execute_wrappers: List[Any] - features: django.db.backends.dummy.features.DummyDatabaseFeatures - force_debug_cursor: bool - in_atomic_block: bool - introspection: django.db.backends.dummy.base.DatabaseIntrospection - needs_rollback: bool - ops: django.db.backends.dummy.base.DatabaseOperations - queries_log: collections.deque - run_commit_hooks_on_set_autocommit_on: bool - run_on_commit: List[Any] - savepoint_ids: List[Any] - savepoint_state: int - settings_dict: Dict[str, Optional[Union[Dict[str, None], int, str]]] - validation: django.db.backends.base.validation.BaseDatabaseValidation operators: Any = ... ensure_connection: Any = ... - client_class: Any = ... - creation_class: Any = ... - features_class: Any = ... - introspection_class: Any = ... - ops_class: Any = ... - def is_usable(self): ... diff --git a/django-stubs/db/backends/sqlite3/schema.pyi b/django-stubs/db/backends/sqlite3/schema.pyi index 7b52dad..5c239c0 100644 --- a/django-stubs/db/backends/sqlite3/schema.pyi +++ b/django-stubs/db/backends/sqlite3/schema.pyi @@ -1,25 +1,3 @@ -from typing import Any, Optional, Type, Union - from django.db.backends.base.schema import BaseDatabaseSchemaEditor -from django.db.models.base import Model -from django.db.models.fields import Field -class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): - atomic_migration: bool - collect_sql: bool - connection: Any - sql_delete_table: str = ... - sql_create_fk: Any = ... - sql_create_inline_fk: str = ... - sql_create_unique: str = ... - sql_delete_unique: str = ... - def __enter__(self) -> DatabaseSchemaEditor: ... - def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ... - def quote_value(self, value: Optional[Union[int, str]]) -> str: ... - def alter_db_table( - self, model: Type[Model], old_db_table: str, new_db_table: str, disable_constraints: bool = ... - ) -> None: ... - def alter_field(self, model: Type[Model], old_field: Field, new_field: Field, strict: bool = ...) -> None: ... - def delete_model(self, model: Type[Model], handle_autom2m: bool = ...) -> None: ... - def add_field(self, model: Type[Model], field: Field) -> None: ... - def remove_field(self, model: Type[Model], field: Field) -> None: ... +class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): ... diff --git a/django-stubs/db/migrations/loader.pyi b/django-stubs/db/migrations/loader.pyi index e970d31..b030df5 100644 --- a/django-stubs/db/migrations/loader.pyi +++ b/django-stubs/db/migrations/loader.pyi @@ -1,11 +1,8 @@ from typing import Any, Dict, Optional, Sequence, Set, Tuple, Union -from django.db.backends.base.base import BaseDatabaseWrapper -from django.db.migrations.migration import Migration, SwappableTuple +from django.db.migrations.migration import Migration from django.db.migrations.state import ProjectState -from django.db import DefaultConnectionProxy - MIGRATIONS_MODULE_NAME: str class MigrationLoader: @@ -13,12 +10,7 @@ class MigrationLoader: disk_migrations: Dict[Tuple[str, str], Migration] = ... applied_migrations: None = ... ignore_no_migrations: bool = ... - def __init__( - self, - connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]], - load: bool = ..., - ignore_no_migrations: bool = ..., - ) -> None: ... + def __init__(self, connection: Any, load: bool = ..., ignore_no_migrations: bool = ...) -> None: ... @classmethod def migrations_module(cls, app_label: str) -> Tuple[Optional[str], bool]: ... unmigrated_apps: Set[str] = ... @@ -26,7 +18,7 @@ class MigrationLoader: def load_disk(self) -> None: ... def get_migration(self, app_label: str, name_prefix: str) -> Migration: ... def get_migration_by_prefix(self, app_label: str, name_prefix: str) -> Migration: ... - def check_key(self, key: Union[Tuple[str, str], SwappableTuple], current_app: str) -> Optional[Tuple[str, str]]: ... + def check_key(self, key: Tuple[str, str], current_app: str) -> Optional[Tuple[str, str]]: ... def add_internal_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... graph: Any = ... @@ -35,5 +27,5 @@ class MigrationLoader: def check_consistent_history(self, connection: Any) -> None: ... def detect_conflicts(self) -> Dict[str, Set[str]]: ... def project_state( - self, nodes: Optional[Tuple[str, str], Sequence[Tuple[str, str]]] = ..., at_end: bool = ... + self, nodes: Optional[Union[Tuple[str, str], Sequence[Tuple[str, str]]]] = ..., at_end: bool = ... ) -> ProjectState: ... diff --git a/django-stubs/db/migrations/migration.pyi b/django-stubs/db/migrations/migration.pyi index 05fd0a6..57b20d6 100644 --- a/django-stubs/db/migrations/migration.pyi +++ b/django-stubs/db/migrations/migration.pyi @@ -21,7 +21,7 @@ class Migration: self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ... ) -> ProjectState: ... -class SwappableTuple(tuple): +class SwappableTuple(Tuple[str, str]): setting: str = ... def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ... diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index ede1337..aef3242 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -21,7 +21,7 @@ class BaseForm: is_bound: bool = ... data: Dict[str, Any] = ... files: Optional[Dict[str, Any]] = ... - auto_id: Any = ... + auto_id: str = ... initial: Dict[str, Any] = ... error_class: Type[ErrorList] = ... prefix: str = ... @@ -59,7 +59,7 @@ class BaseForm: def add_error(self, field: Optional[str], error: Union[ValidationError, str]) -> None: ... def has_error(self, field: Any, code: Optional[Any] = ...): ... def full_clean(self) -> None: ... - def clean(self) -> Dict[str, Optional[Union[datetime, SimpleUploadedFile, QuerySet, str]]]: ... + def clean(self) -> Dict[str, Any]: ... def has_changed(self) -> bool: ... def changed_data(self) -> List[str]: ... @property diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index aa46757..2f69bcb 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -1,12 +1,9 @@ -from collections import OrderedDict -from datetime import date, datetime -from typing import Any, Callable, Dict, Iterator, List, MutableMapping, Optional, Sequence, Tuple, Type, Union, Mapping +from datetime import datetime +from typing import Any, Callable, Dict, Iterator, List, Mapping, MutableMapping, Optional, Sequence, Tuple, Type, Union from unittest.mock import MagicMock from uuid import UUID from django.core.files.base import File -from django.db import models -from django.db.models import ForeignKey from django.db.models.base import Model from django.db.models.manager import Manager from django.db.models.query import QuerySet @@ -18,6 +15,9 @@ from django.forms.utils import ErrorList from django.forms.widgets import Input, Widget from typing_extensions import Literal +from django.db import models +from django.db.models import ForeignKey + ALL_FIELDS: str _Fields = Union[List[Union[Callable, str]], Sequence[str], Literal["__all__"]] diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index b929aa3..cf606b5 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -1,15 +1,12 @@ -from datetime import time from decimal import Decimal from itertools import chain -from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Set, Tuple, Type, Union from django.core.files.base import File -from django.db.models.fields.files import FieldFile from django.forms.renderers import EngineMixin -from django.utils.datastructures import MultiValueDict from django.utils.safestring import SafeText -_OptAttrs = Dict[str, str] +_OptAttrs = Dict[str, Any] class MediaOrderConflictWarning(RuntimeWarning): ... @@ -38,31 +35,21 @@ class Widget: is_localized: bool = ... is_required: bool = ... supports_microseconds: bool = ... - attrs: Dict[str, Any] = ... - def __init__(self, attrs: Optional[Dict[str, Any]] = ...) -> None: ... + attrs: _OptAttrs = ... + def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ... @property def is_hidden(self) -> bool: ... - def subwidgets( - self, name: str, value: Optional[List[str]], attrs: Dict[str, bool] = ... - ) -> Iterator[Dict[str, Any]]: ... + def subwidgets(self, name: str, value: Optional[List[str]], attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ... def format_value(self, value: Any) -> Optional[str]: ... - def get_context(self, name: str, value: Any, attrs: Optional[Dict[str, Union[bool, str]]]) -> Dict[str, Any]: ... + def get_context(self, name: str, value: Any, attrs: Optional[_OptAttrs]) -> Dict[str, Any]: ... def render( - self, - name: str, - value: Any, - attrs: Optional[Dict[str, Union[bool, str]]] = ..., - renderer: Optional[EngineMixin] = ..., + self, name: str, value: Any, attrs: Optional[_OptAttrs] = ..., renderer: Optional[EngineMixin] = ... ) -> SafeText: ... def build_attrs( - self, base_attrs: Dict[str, Union[float, str]], extra_attrs: Optional[Dict[str, Union[bool, str]]] = ... + self, base_attrs: _OptAttrs, extra_attrs: Optional[_OptAttrs] = ... ) -> Dict[str, Union[Decimal, float, str]]: ... - def value_from_datadict( - self, data: dict, files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str - ) -> Any: ... - def value_omitted_from_data( - self, data: Dict[str, Any], files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str - ) -> bool: ... + def value_from_datadict(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> Any: ... + def value_omitted_from_data(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> bool: ... def id_for_label(self, id_: str) -> str: ... def use_required_attribute(self, initial: Any) -> bool: ... @@ -94,14 +81,12 @@ class ClearableFileInput(FileInput): def clear_checkbox_name(self, name: str) -> str: ... def clear_checkbox_id(self, name: str) -> str: ... def is_initial(self, value: Optional[Union[File, str]]) -> bool: ... - def use_required_attribute(self, initial: Optional[Union[FieldFile, str]]) -> bool: ... class Textarea(Widget): template_name: str = ... class DateTimeBaseInput(TextInput): format_key: str = ... - supports_microseconds: bool = ... format: Optional[str] = ... def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...): ... @@ -128,7 +113,7 @@ class ChoiceWidget(Widget): def create_option( self, name: str, - value: Union[time, int, str], + value: Any, label: Union[int, str], selected: Union[Set[str], bool], index: int, @@ -137,13 +122,7 @@ class ChoiceWidget(Widget): ) -> Dict[str, Any]: ... def id_for_label(self, id_: str, index: str = ...) -> str: ... -class Select(ChoiceWidget): - option_template_name: str = ... - add_id_index: bool = ... - checked_attribute: Any = ... - option_inherits_attrs: bool = ... - def use_required_attribute(self, initial: Any) -> bool: ... - +class Select(ChoiceWidget): ... class NullBooleanSelect(Select): ... class SelectMultiple(Select): @@ -154,40 +133,26 @@ class RadioSelect(ChoiceWidget): option_template_name: str = ... class CheckboxSelectMultiple(ChoiceWidget): - allow_multiple_selected: bool = ... - option_template_name: str = ... - def use_required_attribute(self, initial: Optional[List[str]]) -> bool: ... def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ... class MultiWidget(Widget): template_name: str = ... widgets: List[Widget] = ... def __init__(self, widgets: Sequence[Union[Widget, Type[Widget]]], attrs: Optional[_OptAttrs] = ...) -> None: ... - @property - def is_hidden(self) -> bool: ... def decompress(self, value: Any) -> Optional[Any]: ... media: Any = ... class SplitDateTimeWidget(MultiWidget): - supports_microseconds: bool = ... def __init__( self, - attrs: Optional[Dict[str, str]] = ..., + attrs: Optional[_OptAttrs] = ..., date_format: Optional[str] = ..., time_format: Optional[str] = ..., date_attrs: Optional[Dict[str, str]] = ..., time_attrs: Optional[Dict[str, str]] = ..., ) -> None: ... -class SplitHiddenDateTimeWidget(SplitDateTimeWidget): - def __init__( - self, - attrs: Optional[Dict[str, str]] = ..., - date_format: None = ..., - time_format: None = ..., - date_attrs: Optional[Dict[str, str]] = ..., - time_attrs: Optional[Dict[str, str]] = ..., - ) -> None: ... +class SplitHiddenDateTimeWidget(SplitDateTimeWidget): ... class SelectDateWidget(Widget): none_value: Any = ... diff --git a/django-stubs/template/backends/base.pyi b/django-stubs/template/backends/base.pyi index bb12a08..5f48ad7 100644 --- a/django-stubs/template/backends/base.pyi +++ b/django-stubs/template/backends/base.pyi @@ -1,15 +1,16 @@ -from typing import Any, Dict, Iterator, List, Tuple, Union +from typing import Any, Iterator, List, Mapping, Optional, Tuple from django.template.base import Template class BaseEngine: - name: Any = ... - dirs: Any = ... - app_dirs: Any = ... - def __init__(self, params: Dict[str, Union[List[str], bool, str]]) -> None: ... + name: str = ... + dirs: List[str] = ... + app_dirs: bool = ... + def __init__(self, params: Mapping[str, Any]) -> None: ... + @property + def app_dirname(self) -> Optional[str]: ... + def from_string(self, template_code: str) -> Template: ... + def get_template(self, template_name: str) -> Optional[Template]: ... @property - def app_dirname(self) -> None: ... - def from_string(self, template_code: Any) -> Template: ... - def get_template(self, template_name: Any) -> None: ... def template_dirs(self) -> Tuple[str]: ... def iter_template_filenames(self, template_name: str) -> Iterator[str]: ... diff --git a/django-stubs/template/backends/django.pyi b/django-stubs/template/backends/django.pyi index c4ed389..fa2c7e1 100644 --- a/django-stubs/template/backends/django.pyi +++ b/django-stubs/template/backends/django.pyi @@ -1,20 +1,13 @@ -from typing import Any, Dict, Iterator, Optional, List - -from django.template.base import Template as Template -from django.template.exceptions import TemplateDoesNotExist +from typing import Any, Dict, Iterator, Optional from django.template.engine import Engine +from django.template.exceptions import TemplateDoesNotExist + from .base import BaseEngine class DjangoTemplates(BaseEngine): - app_dirs: bool - dirs: List[str] - name: str - app_dirname: str = ... engine: Engine = ... def __init__(self, params: Dict[str, Any]) -> None: ... - def from_string(self, template_code: str) -> Template: ... - def get_template(self, template_name: str) -> Template: ... def get_templatetag_libraries(self, custom_libraries: Dict[str, str]) -> Dict[str, str]: ... def copy_exception(exc: TemplateDoesNotExist, backend: Optional[DjangoTemplates] = ...) -> TemplateDoesNotExist: ... diff --git a/django-stubs/template/backends/dummy.pyi b/django-stubs/template/backends/dummy.pyi index 1f94dce..6a8a759 100644 --- a/django-stubs/template/backends/dummy.pyi +++ b/django-stubs/template/backends/dummy.pyi @@ -1,19 +1,13 @@ import string -from typing import Any, Dict, List, Optional, Union, Tuple +from typing import Any, Dict, List, Optional, Tuple, Union from django.http.request import HttpRequest from .base import BaseEngine class TemplateStrings(BaseEngine): - app_dirs: bool - dirs: List[Any] - name: str template_dirs: Tuple[str] - app_dirname: str = ... def __init__(self, params: Dict[str, Union[Dict[Any, Any], List[Any], bool, str]]) -> None: ... - def from_string(self, template_code: str) -> Template: ... - def get_template(self, template_name: str) -> Template: ... class Template(string.Template): template: str diff --git a/django-stubs/template/backends/jinja2.pyi b/django-stubs/template/backends/jinja2.pyi index 122b5b0..623bd40 100644 --- a/django-stubs/template/backends/jinja2.pyi +++ b/django-stubs/template/backends/jinja2.pyi @@ -1,21 +1,14 @@ -from typing import Callable, Dict, List, Optional, Tuple, Any +from typing import Any, Callable, Dict, List, Optional -from django.template.base import Template as Template from django.template.exceptions import TemplateSyntaxError from .base import BaseEngine class Jinja2(BaseEngine): - app_dirs: bool - dirs: List[str] - name: str - template_context_processors: List[Callable] - template_dirs: Tuple[str] - app_dirname: str = ... context_processors: List[str] = ... def __init__(self, params: Dict[str, Any]) -> None: ... - def from_string(self, template_code: str) -> Template: ... - def get_template(self, template_name: str) -> Template: ... + @property + def template_context_processors(self) -> List[Callable]: ... class Origin: name: str = ... diff --git a/django-stubs/template/base.pyi b/django-stubs/template/base.pyi index bc4e5d4..ce05838 100644 --- a/django-stubs/template/base.pyi +++ b/django-stubs/template/base.pyi @@ -1,5 +1,5 @@ from enum import Enum -from typing import Any, Callable, Dict, Iterator, List, Mapping, Optional, Tuple, Type, Union +from typing import Any, Callable, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple, Type, Union from django.http.request import HttpRequest from django.template.context import Context as Context @@ -126,12 +126,12 @@ filter_re: Any class FilterExpression: token: str = ... - filters: List[Tuple[Callable, List[Tuple[bool, Union[Variable, SafeText]]]]] = ... - var: Union[Variable, SafeText] = ... + filters: List[Any] = ... + var: Any = ... def __init__(self, token: str, parser: Parser) -> None: ... - def resolve(self, context: Union[Dict[str, Dict[str, str]], Context], ignore_failures: bool = ...) -> Any: ... + def resolve(self, context: Mapping[str, Any], ignore_failures: bool = ...) -> Any: ... @staticmethod - def args_check(name: str, func: Callable, provided: List[Tuple[bool, Union[Variable, SafeText]]]) -> bool: ... + def args_check(name: str, func: Callable, provided: List[Tuple[bool, Any]]) -> bool: ... class Variable: var: Union[Dict[Any, Any], str] = ... @@ -152,27 +152,21 @@ class Node: def __iter__(self) -> None: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... -class NodeList(list): +class NodeList(List[Node]): contains_nontext: bool = ... def render(self, context: Context) -> SafeText: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... class TextNode(Node): - origin: Origin - token: Token s: str = ... def __init__(self, s: str) -> None: ... - def render(self, context: Context) -> str: ... def render_value_in_context(value: Any, context: Context) -> str: ... class VariableNode(Node): - origin: Origin - token: Token filter_expression: FilterExpression = ... def __init__(self, filter_expression: FilterExpression) -> None: ... - def render(self, context: Context) -> str: ... kwarg_re: Any -def token_kwargs(bits: List[str], parser: Parser, support_legacy: bool = ...) -> Dict[str, FilterExpression]: ... +def token_kwargs(bits: Sequence[str], parser: Parser, support_legacy: bool = ...) -> Dict[str, FilterExpression]: ... diff --git a/django-stubs/template/loaders/app_directories.pyi b/django-stubs/template/loaders/app_directories.pyi index 98a5d5e..a1c59b9 100644 --- a/django-stubs/template/loaders/app_directories.pyi +++ b/django-stubs/template/loaders/app_directories.pyi @@ -1,10 +1,3 @@ -from typing import Optional, Tuple - -from django.template import Engine - from .filesystem import Loader as FilesystemLoader -class Loader(FilesystemLoader): - dirs: None - engine: Engine - def get_dirs(self) -> Tuple: ... +class Loader(FilesystemLoader): ... diff --git a/django-stubs/template/loaders/base.pyi b/django-stubs/template/loaders/base.pyi index 7a407bc..817b456 100644 --- a/django-stubs/template/loaders/base.pyi +++ b/django-stubs/template/loaders/base.pyi @@ -4,9 +4,9 @@ from django.template.base import Origin, Template from django.template.engine import Engine class Loader: - engine: Any = ... + engine: Engine = ... get_template_cache: Dict[str, Any] = ... def __init__(self, engine: Engine) -> None: ... def get_template(self, template_name: str, skip: Optional[List[Origin]] = ...) -> Template: ... - def get_template_sources(self, template_name: Any) -> None: ... + def get_template_sources(self, template_name: str) -> None: ... def reset(self) -> None: ... diff --git a/django-stubs/template/loaders/cached.pyi b/django-stubs/template/loaders/cached.pyi index 278887d..956e9dc 100644 --- a/django-stubs/template/loaders/cached.pyi +++ b/django-stubs/template/loaders/cached.pyi @@ -1,19 +1,14 @@ -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, Optional, Sequence -from django.template.base import Origin, Template +from django.template.base import Origin from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - engine: Engine - template_cache: Dict[Any, Any] = ... - get_template_cache: Dict[str, django.template.exceptions.TemplateDoesNotExist] = ... - loaders: List[django.template.loaders.base.Loader] = ... - def __init__(self, engine: Engine, loaders: Union[List[Tuple[str, Dict[str, str]]], List[str]]) -> None: ... + template_cache: Dict[str, Any] = ... + loaders: List[BaseLoader] = ... + def __init__(self, engine: Engine, loaders: Sequence[Any]) -> None: ... def get_contents(self, origin: Origin) -> str: ... - def get_template(self, template_name: str, skip: Optional[List[Origin]] = ...) -> Template: ... - def get_template_sources(self, template_name: str) -> None: ... def cache_key(self, template_name: str, skip: Optional[List[Origin]] = ...) -> str: ... def generate_hash(self, values: List[str]) -> str: ... - def reset(self) -> None: ... diff --git a/django-stubs/template/loaders/filesystem.pyi b/django-stubs/template/loaders/filesystem.pyi index a3dcadc..4334186 100644 --- a/django-stubs/template/loaders/filesystem.pyi +++ b/django-stubs/template/loaders/filesystem.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, List, Optional, Union +from typing import Any, List, Optional, Union from django.template.base import Origin from django.template.engine import Engine @@ -6,9 +6,7 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - engine: Engine dirs: Optional[List[str]] = ... def __init__(self, engine: Engine, dirs: Optional[List[str]] = ...) -> None: ... def get_dirs(self) -> Union[List[bytes], List[str]]: ... def get_contents(self, origin: Origin) -> Any: ... - def get_template_sources(self, template_name: Union[bytes, str]) -> Iterator[Origin]: ... diff --git a/django-stubs/template/loaders/locmem.pyi b/django-stubs/template/loaders/locmem.pyi index 9c58656..ddeb87a 100644 --- a/django-stubs/template/loaders/locmem.pyi +++ b/django-stubs/template/loaders/locmem.pyi @@ -1,4 +1,4 @@ -from typing import Dict, Iterator +from typing import Dict from django.template.base import Origin from django.template.engine import Engine @@ -6,8 +6,6 @@ from django.template.engine import Engine from .base import Loader as BaseLoader class Loader(BaseLoader): - engine: Engine templates_dict: Dict[str, str] = ... def __init__(self, engine: Engine, templates_dict: Dict[str, str]) -> None: ... def get_contents(self, origin: Origin) -> str: ... - def get_template_sources(self, template_name: str) -> Iterator[Origin]: ... diff --git a/django-stubs/templatetags/cache.pyi b/django-stubs/templatetags/cache.pyi index 4530ae5..2f8d1f6 100644 --- a/django-stubs/templatetags/cache.pyi +++ b/django-stubs/templatetags/cache.pyi @@ -1,15 +1,12 @@ from typing import Any, List, Optional -from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token -from django.template.context import Context -from django.utils.safestring import SafeText + +from django.template import Node register: Any class CacheNode(Node): - origin: Origin - token: Token nodelist: NodeList = ... expire_time_var: FilterExpression = ... fragment_name: str = ... @@ -23,6 +20,5 @@ class CacheNode(Node): vary_on: List[FilterExpression], cache_name: Optional[FilterExpression], ) -> None: ... - def render(self, context: Context) -> SafeText: ... def do_cache(parser: Parser, token: Token) -> CacheNode: ... diff --git a/django-stubs/templatetags/i18n.pyi b/django-stubs/templatetags/i18n.pyi index 62ee360..a32fd8f 100644 --- a/django-stubs/templatetags/i18n.pyi +++ b/django-stubs/templatetags/i18n.pyi @@ -1,53 +1,35 @@ from typing import Any, Dict, List, Optional, Tuple -from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token -from django.template.context import Context, RequestContext -from django.utils.safestring import SafeText + +from django.template import Node register: Any class GetAvailableLanguagesNode(Node): - origin: Origin - token: Token variable: str = ... def __init__(self, variable: str) -> None: ... - def render(self, context: Context) -> str: ... class GetLanguageInfoNode(Node): - origin: Origin - token: Token lang_code: FilterExpression = ... variable: str = ... def __init__(self, lang_code: FilterExpression, variable: str) -> None: ... - def render(self, context: Context) -> str: ... class GetLanguageInfoListNode(Node): - origin: Origin - token: Token languages: FilterExpression = ... variable: str = ... def __init__(self, languages: FilterExpression, variable: str) -> None: ... def get_language_info(self, language: Any): ... - def render(self, context: Context) -> str: ... class GetCurrentLanguageNode(Node): - origin: Origin - token: Token variable: str = ... def __init__(self, variable: str) -> None: ... - def render(self, context: RequestContext) -> str: ... class GetCurrentLanguageBidiNode(Node): - origin: Origin - token: Token variable: str = ... def __init__(self, variable: str) -> None: ... - def render(self, context: RequestContext) -> str: ... class TranslateNode(Node): - origin: Origin - token: Token noop: bool = ... asvar: Optional[str] = ... message_context: Optional[FilterExpression] = ... @@ -59,11 +41,8 @@ class TranslateNode(Node): asvar: Optional[str] = ..., message_context: Optional[FilterExpression] = ..., ) -> None: ... - def render(self, context: Context) -> str: ... class BlockTranslateNode(Node): - origin: Origin - token: Token extra_context: Dict[str, FilterExpression] = ... singular: List[Token] = ... plural: List[Token] = ... @@ -84,15 +63,11 @@ class BlockTranslateNode(Node): asvar: Optional[str] = ..., ) -> None: ... def render_token_list(self, tokens: List[Token]) -> Tuple[str, List[str]]: ... - def render(self, context: Context, nested: bool = ...) -> str: ... class LanguageNode(Node): - origin: Origin - token: Token nodelist: NodeList = ... language: FilterExpression = ... def __init__(self, nodelist: NodeList, language: FilterExpression) -> None: ... - def render(self, context: Context) -> SafeText: ... def do_get_available_languages(parser: Parser, token: Token) -> GetAvailableLanguagesNode: ... def do_get_language_info(parser: Parser, token: Token) -> GetLanguageInfoNode: ... diff --git a/django-stubs/templatetags/l10n.pyi b/django-stubs/templatetags/l10n.pyi index de33958..03c45bb 100644 --- a/django-stubs/templatetags/l10n.pyi +++ b/django-stubs/templatetags/l10n.pyi @@ -1,22 +1,17 @@ -from datetime import date -from typing import Any, List, Optional, Union +from typing import Any, List + +from django.template.base import Parser, Token from django.template import Node -from django.template.base import NodeList, Parser, Token -from django.template.context import Context -from django.utils.safestring import SafeText register: Any -def localize(value: Union[date, float]) -> str: ... -def unlocalize(value: Union[date, float]) -> str: ... +def localize(value: Any) -> str: ... +def unlocalize(value: Any) -> str: ... class LocalizeNode(Node): - origin: Origin - token: Token - nodelist: Union[List[Any], NodeList] = ... + nodelist: List[Node] = ... use_l10n: bool = ... - def __init__(self, nodelist: Union[List[Any], NodeList], use_l10n: bool) -> None: ... - def render(self, context: Context) -> SafeText: ... + def __init__(self, nodelist: List[Node], use_l10n: bool) -> None: ... def localize_tag(parser: Parser, token: Token) -> LocalizeNode: ... diff --git a/django-stubs/templatetags/static.pyi b/django-stubs/templatetags/static.pyi index 66aabad..db254c7 100644 --- a/django-stubs/templatetags/static.pyi +++ b/django-stubs/templatetags/static.pyi @@ -1,14 +1,13 @@ from typing import Any, Optional -from django import template from django.template.base import FilterExpression, Parser, Token from django.template.context import Context +from django import template + register: Any class PrefixNode(template.Node): - origin: Origin - token: Token varname: Optional[str] = ... name: str = ... def __init__(self, varname: Optional[str] = ..., name: str = ...) -> None: ... @@ -16,19 +15,15 @@ class PrefixNode(template.Node): def handle_token(cls, parser: Parser, token: Token, name: str) -> PrefixNode: ... @classmethod def handle_simple(cls, name: str) -> str: ... - def render(self, context: Context) -> str: ... def get_static_prefix(parser: Parser, token: Token) -> PrefixNode: ... def get_media_prefix(parser: Parser, token: Token) -> PrefixNode: ... class StaticNode(template.Node): - origin: Origin - token: Token path: FilterExpression = ... varname: Optional[str] = ... def __init__(self, varname: Optional[str] = ..., path: FilterExpression = ...) -> None: ... def url(self, context: Context) -> str: ... - def render(self, context: Context) -> str: ... @classmethod def handle_simple(cls, path: str) -> str: ... @classmethod diff --git a/django-stubs/templatetags/tz.pyi b/django-stubs/templatetags/tz.pyi index d040d3e..7719adb 100644 --- a/django-stubs/templatetags/tz.pyi +++ b/django-stubs/templatetags/tz.pyi @@ -1,44 +1,32 @@ from datetime import datetime from typing import Any, Optional, Union -from django.template import Node from django.template.base import FilterExpression, NodeList, Parser, Token -from django.template.context import Context -from django.utils.safestring import SafeText from django.utils.timezone import FixedOffset +from django.template import Node + register: Any class datetimeobject(datetime): ... -def localtime(value: Optional[Union[datetime, str]]) -> Union[datetimeobject, str]: ... -def utc(value: Optional[Union[datetime, str]]) -> Union[datetimeobject, str]: ... -def do_timezone( - value: Optional[Union[datetime, str]], arg: Optional[Union[FixedOffset, str]] -) -> Union[datetimeobject, str]: ... +def localtime(value: Optional[Union[datetime, str]]) -> Any: ... +def utc(value: Optional[Union[datetime, str]]) -> Any: ... +def do_timezone(value: Optional[Union[datetime, str]], arg: Optional[Union[FixedOffset, str]]) -> Any: ... class LocalTimeNode(Node): - origin: Origin - token: Token nodelist: NodeList = ... use_tz: bool = ... def __init__(self, nodelist: NodeList, use_tz: bool) -> None: ... - def render(self, context: Context) -> SafeText: ... class TimezoneNode(Node): - origin: Origin - token: Token nodelist: NodeList = ... tz: FilterExpression = ... def __init__(self, nodelist: NodeList, tz: FilterExpression) -> None: ... - def render(self, context: Context) -> SafeText: ... class GetCurrentTimezoneNode(Node): - origin: Origin - token: Token variable: str = ... def __init__(self, variable: str) -> None: ... - def render(self, context: Context) -> str: ... def localtime_tag(parser: Parser, token: Token) -> LocalTimeNode: ... def timezone_tag(parser: Parser, token: Token) -> TimezoneNode: ... diff --git a/django-stubs/test/html.pyi b/django-stubs/test/html.pyi index e9a623c..67d69f8 100644 --- a/django-stubs/test/html.pyi +++ b/django-stubs/test/html.pyi @@ -31,15 +31,8 @@ class Parser(HTMLParser): open_tags: Any = ... element_positions: Any = ... def __init__(self) -> None: ... - def error(self, msg: str) -> Any: ... - def format_position(self, position: None = ..., element: None = ...) -> str: ... + def format_position(self, position: Any = ..., element: Any = ...) -> str: ... @property def current(self) -> Element: ... - def handle_startendtag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: ... - def handle_starttag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: ... - def handle_endtag(self, tag: str) -> None: ... - def handle_data(self, data: str) -> None: ... - def handle_charref(self, name: str) -> None: ... - def handle_entityref(self, name: str) -> None: ... def parse_html(html: str) -> Element: ... diff --git a/django-stubs/utils/archive.pyi b/django-stubs/utils/archive.pyi index 2b73dfd..b9a8015 100644 --- a/django-stubs/utils/archive.pyi +++ b/django-stubs/utils/archive.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, List, Optional, Tuple, Union +from typing import Any, Dict, Iterable, Sequence, Type class ArchiveException(Exception): ... class UnrecognizedArchiveFormat(ArchiveException): ... @@ -14,21 +14,17 @@ class Archive: def close(self) -> None: ... class BaseArchive: - def split_leading_dir(self, path: str) -> Union[List[str], Tuple[str, str]]: ... - def has_leading_dir(self, paths: Union[Iterator[Any], List[str]]) -> bool: ... - def extract(self) -> None: ... - def list(self) -> None: ... + def split_leading_dir(self, path: str) -> Sequence[str]: ... + def has_leading_dir(self, paths: Iterable[str]) -> bool: ... + def extract(self, to_path: str) -> None: ... + def list(self, *args: Any, **kwargs: Any) -> None: ... class TarArchive(BaseArchive): def __init__(self, file: str) -> None: ... - def list(self, *args: Any, **kwargs: Any) -> None: ... - def extract(self, to_path: str) -> None: ... def close(self) -> None: ... class ZipArchive(BaseArchive): def __init__(self, file: str) -> None: ... - def list(self, *args: Any, **kwargs: Any) -> None: ... - def extract(self, to_path: str) -> None: ... def close(self) -> None: ... -extension_map: Any +extension_map: Dict[str, Type[BaseArchive]] diff --git a/django-stubs/utils/datetime_safe.pyi b/django-stubs/utils/datetime_safe.pyi index 328d205..8dbfc71 100644 --- a/django-stubs/utils/datetime_safe.pyi +++ b/django-stubs/utils/datetime_safe.pyi @@ -1,17 +1,8 @@ -from datetime import date as real_date -from datetime import datetime as real_datetime -from datetime import time as real_time -from typing import Any, Optional, Union - -class date(real_date): - def strftime(self, fmt: str) -> str: ... - -class datetime(real_datetime): - def strftime(self, fmt: str) -> str: ... - @classmethod - def combine(cls, date: Any, time: Any): ... - def date(self): ... +from datetime import date as real_date, datetime as real_datetime, time as real_time +from typing import Union +class date(real_date): ... +class datetime(real_datetime): ... class time(real_time): ... def new_date(d: date) -> date: ... diff --git a/django-stubs/utils/feedgenerator.pyi b/django-stubs/utils/feedgenerator.pyi index a182bd8..ce0cb43 100644 --- a/django-stubs/utils/feedgenerator.pyi +++ b/django-stubs/utils/feedgenerator.pyi @@ -1,17 +1,14 @@ from datetime import date, datetime -from io import StringIO from typing import Any, Dict, List, Optional, Tuple, Union - -from django.http.response import HttpResponse -from django.utils.xmlutils import SimplerXMLGenerator +from xml.sax import ContentHandler # type: ignore def rfc2822_date(date: date) -> str: ... def rfc3339_date(date: date) -> str: ... def get_tag_uri(url: str, date: Optional[date]) -> str: ... class SyndicationFeed: - feed: Any = ... - items: Any = ... + feed: Dict[str, Any] = ... + items: List[Dict[str, Any]] = ... def __init__( self, title: str, @@ -50,58 +47,30 @@ class SyndicationFeed: ) -> None: ... def num_items(self): ... def root_attributes(self) -> Dict[Any, Any]: ... - def add_root_elements(self, handler: Any) -> None: ... + def add_root_elements(self, handler: ContentHandler) -> None: ... def item_attributes(self, item: Dict[str, Any]) -> Dict[Any, Any]: ... - def add_item_elements(self, handler: Any, item: Any) -> None: ... + def add_item_elements(self, handler: ContentHandler, item: Dict[str, Any]) -> None: ... def write(self, outfile: Any, encoding: Any) -> None: ... def writeString(self, encoding: str) -> str: ... def latest_post_date(self) -> datetime: ... class Enclosure: - length: Union[int, str] + length: Any mime_type: str url: str = ... def __init__(self, url: str, length: Union[int, str], mime_type: str) -> None: ... class RssFeed(SyndicationFeed): content_type: str = ... - def write(self, outfile: Union[StringIO, HttpResponse], encoding: str) -> None: ... - def rss_attributes(self) -> Dict[str, str]: ... - def write_items(self, handler: SimplerXMLGenerator) -> None: ... - def add_root_elements(self, handler: SimplerXMLGenerator) -> None: ... - def endChannelElement(self, handler: SimplerXMLGenerator) -> None: ... + def write_items(self, handler: ContentHandler) -> None: ... + def endChannelElement(self, handler: ContentHandler) -> None: ... -class RssUserland091Feed(RssFeed): - feed: Dict[str, Optional[Union[List[str], str]]] - items: List[Dict[str, Optional[Union[List[str], Tuple, datetime.datetime, str]]]] - def add_item_elements( - self, handler: SimplerXMLGenerator, item: Dict[str, Optional[Union[List[str], Tuple, datetime, str]]] - ) -> None: ... - -class Rss201rev2Feed(RssFeed): - feed: Dict[str, Optional[Union[List[str], Tuple, str]]] - items: Union[ - List[Dict[str, Any]], - List[Dict[str, Optional[Union[List[django.utils.feedgenerator.Enclosure], List[str], datetime.datetime, str]]]], - ] - def add_item_elements(self, handler: SimplerXMLGenerator, item: Dict[str, Any]) -> None: ... +class RssUserland091Feed(RssFeed): ... +class Rss201rev2Feed(RssFeed): ... class Atom1Feed(SyndicationFeed): - feed: Dict[str, Optional[Union[List[str], Tuple, str]]] - items: Union[ - List[Dict[str, Optional[Union[List[django.utils.feedgenerator.Enclosure], List[str], datetime.datetime, str]]]], - List[Dict[str, Optional[Union[List[str], Tuple, datetime.datetime, str]]]], - ] content_type: str = ... ns: str = ... - def write(self, outfile: Union[StringIO, HttpResponse], encoding: str) -> None: ... - def root_attributes(self) -> Dict[str, str]: ... - def add_root_elements(self, handler: SimplerXMLGenerator) -> None: ... - def write_items(self, handler: SimplerXMLGenerator) -> None: ... - def add_item_elements( - self, - handler: SimplerXMLGenerator, - item: Dict[str, Optional[Union[List[Enclosure], List[str], Tuple, datetime, str]]], - ) -> None: ... + def write_items(self, handler: ContentHandler) -> None: ... DefaultFeed = Rss201rev2Feed diff --git a/django-stubs/utils/itercompat.pyi b/django-stubs/utils/itercompat.pyi index 1c6fe58..5c15fee 100644 --- a/django-stubs/utils/itercompat.pyi +++ b/django-stubs/utils/itercompat.pyi @@ -1,18 +1,3 @@ -from tempfile import _TemporaryFileWrapper -from typing import Any, List, Optional, Tuple, Union +from typing import Any -from django.core.checks.messages import CheckMessage - -def is_iterable( - x: Optional[ - Union[ - List[List[Union[List[List[Union[List[List[str]], str]]], str]]], - List[Tuple[Optional[Union[int, str]], Union[int, str]]], - List[CheckMessage], - List[int], - List[str], - Tuple[Union[Tuple[str, str], _TemporaryFileWrapper]], - int, - ] - ] -) -> bool: ... +def is_iterable(x: Any) -> bool: ... diff --git a/django-stubs/utils/log.pyi b/django-stubs/utils/log.pyi index 867d31f..a9cd127 100644 --- a/django-stubs/utils/log.pyi +++ b/django-stubs/utils/log.pyi @@ -2,7 +2,6 @@ import logging.config from logging import LogRecord from typing import Any, Callable, Dict, Optional, Union -from django.core.mail.backends.locmem import EmailBackend from django.core.management.color import Style request_logger: Any @@ -15,7 +14,7 @@ class AdminEmailHandler(logging.Handler): email_backend: Optional[str] = ... def __init__(self, include_html: bool = ..., email_backend: Optional[str] = ...) -> None: ... def send_mail(self, subject: str, message: str, *args: Any, **kwargs: Any) -> None: ... - def connection(self) -> EmailBackend: ... + def connection(self) -> Any: ... def format_subject(self, subject: str) -> str: ... class CallbackFilter(logging.Filter): diff --git a/django-stubs/utils/text.pyi b/django-stubs/utils/text.pyi index 7fec81f..927e514 100644 --- a/django-stubs/utils/text.pyi +++ b/django-stubs/utils/text.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterator, List, Optional, Union +from typing import Any, Iterable, Iterator, List, Optional, Union from django.db.models.base import Model from django.utils.functional import SimpleLazyObject @@ -34,7 +34,7 @@ class StreamingBuffer: def flush(self): ... def close(self): ... -def compress_sequence(sequence: Union[List[bytes], map]) -> Iterator[bytes]: ... +def compress_sequence(sequence: Iterable[bytes]) -> Iterator[bytes]: ... smart_split_re: Any diff --git a/django-stubs/utils/timezone.pyi b/django-stubs/utils/timezone.pyi index 0753dd7..af5bb42 100644 --- a/django-stubs/utils/timezone.pyi +++ b/django-stubs/utils/timezone.pyi @@ -1,8 +1,8 @@ -# Stubs for django.utils.timezone (Python 3.5) - -from typing import Any, Optional, Union -from datetime import tzinfo as tzinfo, datetime as datetime, timedelta as timedelta from contextlib import ContextDecorator +from datetime import datetime as datetime, time, timedelta as timedelta, tzinfo as tzinfo +from typing import Optional, Union + +_AnyTime = Union[time, datetime] class UTC(tzinfo): def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... @@ -16,9 +16,9 @@ class FixedOffset(tzinfo): def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... class ReferenceLocalTimezone(tzinfo): - STDOFFSET = ... # type: timedelta - DSTOFFSET = ... # type: timedelta - DSTDIFF = ... # type: timedelta + STDOFFSET: timedelta = ... + DSTOFFSET: timedelta = ... + DSTDIFF: timedelta = ... def __init__(self) -> None: ... def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... @@ -27,7 +27,7 @@ class ReferenceLocalTimezone(tzinfo): class LocalTimezone(ReferenceLocalTimezone): def tzname(self, dt: Optional[datetime]) -> str: ... -utc = ... # type: UTC +utc: UTC = ... def get_fixed_timezone(offset: Union[timedelta, int]) -> tzinfo: ... def get_default_timezone() -> tzinfo: ... @@ -38,15 +38,15 @@ def activate(timezone: tzinfo) -> None: ... def deactivate() -> None: ... class override(ContextDecorator): - timezone = ... # type: tzinfo - old_timezone = ... # type: tzinfo + timezone: tzinfo = ... + old_timezone: tzinfo = ... def __init__(self, timezone: tzinfo) -> None: ... def __enter__(self) -> None: ... def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ... -def localtime(value: datetime, timezone: tzinfo = None) -> datetime: ... +def localtime(value: _AnyTime, timezone: Optional[tzinfo] = None) -> datetime: ... def now() -> datetime: ... -def is_aware(value: datetime) -> bool: ... -def is_naive(value: datetime) -> bool: ... -def make_aware(value: datetime, timezone: tzinfo = None, is_dst: bool = None) -> datetime: ... -def make_naive(value: datetime, timezone: tzinfo = None) -> datetime: ... +def is_aware(value: _AnyTime) -> bool: ... +def is_naive(value: _AnyTime) -> bool: ... +def make_aware(value: _AnyTime, timezone: Optional[tzinfo] = None, is_dst: Optional[bool] = None) -> datetime: ... +def make_naive(value: _AnyTime, timezone: Optional[tzinfo] = None) -> datetime: ... diff --git a/django-stubs/views/generic/list.pyi b/django-stubs/views/generic/list.pyi index 73a1111..e0665c7 100644 --- a/django-stubs/views/generic/list.pyi +++ b/django-stubs/views/generic/list.pyi @@ -11,7 +11,7 @@ class MultipleObjectMixin(ContextMixin): allow_empty: bool = ... queryset: Optional[QuerySet] = ... model: Optional[Type[Model]] = ... - paginate_by: Optional[int] = ... + paginate_by: int = ... paginate_orphans: int = ... context_object_name: Optional[str] = ... paginator_class: Type[Paginator] = ... diff --git a/scripts/build_import_all_test.py b/scripts/build_import_all_test.py new file mode 100644 index 0000000..e13ffa2 --- /dev/null +++ b/scripts/build_import_all_test.py @@ -0,0 +1,29 @@ +import os +from pathlib import Path +from typing import List + + +STUBS_ROOT = Path(__file__).parent.parent / 'django-stubs' + + +def build_package_name(path: str) -> str: + return '.'.join(['django'] + list(Path(path).relative_to(STUBS_ROOT).with_suffix('').parts)) + + +packages: List[str] = [] +for dirpath, dirnames, filenames in os.walk(STUBS_ROOT): + if not dirnames: + package = build_package_name(dirpath) + packages.append(package) + + for filename in filenames: + if filename != '__init__.pyi': + package = build_package_name(os.path.join(dirpath, filename)) + packages.append(package) + +test_lines: List[str] = [] +for package in packages: + test_lines.append('import ' + package) + +test_contents = '\n'.join(test_lines) +print(test_contents) diff --git a/test-data/typecheck/import_all.test b/test-data/typecheck/import_all.test new file mode 100644 index 0000000..e81fae8 --- /dev/null +++ b/test-data/typecheck/import_all.test @@ -0,0 +1,402 @@ +[CASE import_all_packages_to_trigger_stubs_check] +import django.apps +import django.apps.config +import django.apps.registry +import django.conf.global_settings +import django.conf.urls +import django.conf.urls.i18n +import django.conf.urls.static +import django.contrib.admin.actions +import django.contrib.admin.apps +import django.contrib.admin.checks +import django.contrib.admin.decorators +import django.contrib.admin.filters +import django.contrib.admin.forms +import django.contrib.admin.helpers +import django.contrib.admin.models +import django.contrib.admin.options +import django.contrib.admin.sites +import django.contrib.admin.templatetags +import django.contrib.admin.templatetags.admin_list +import django.contrib.admin.templatetags.admin_modify +import django.contrib.admin.templatetags.admin_static +import django.contrib.admin.templatetags.admin_urls +import django.contrib.admin.templatetags.base +import django.contrib.admin.templatetags.log +import django.contrib.admin.utils +import django.contrib.admin.views +import django.contrib.admin.views.autocomplete +import django.contrib.admin.views.decorators +import django.contrib.admin.views.main +import django.contrib.admin.widgets +import django.contrib.admindocs +import django.contrib.admindocs.middleware +import django.contrib.admindocs.utils +import django.contrib.admindocs.views +import django.contrib.auth.admin +import django.contrib.auth.apps +import django.contrib.auth.backends +import django.contrib.auth.base_user +import django.contrib.auth.checks +import django.contrib.auth.context_processors +import django.contrib.auth.decorators +import django.contrib.auth.forms +import django.contrib.auth.handlers +import django.contrib.auth.handlers.modwsgi +import django.contrib.auth.hashers +import django.contrib.auth.management.commands +import django.contrib.auth.management.commands.changepassword +import django.contrib.auth.management.commands.createsuperuser +import django.contrib.auth.middleware +import django.contrib.auth.mixins +import django.contrib.auth.models +import django.contrib.auth.password_validation +import django.contrib.auth.signals +import django.contrib.auth.tokens +import django.contrib.auth.validators +import django.contrib.auth.views +import django.contrib.contenttypes.admin +import django.contrib.contenttypes.apps +import django.contrib.contenttypes.checks +import django.contrib.contenttypes.fields +import django.contrib.contenttypes.forms +import django.contrib.contenttypes.management.commands +import django.contrib.contenttypes.management.commands.remove_stale_contenttypes +import django.contrib.contenttypes.models +import django.contrib.contenttypes.views +import django.contrib.flatpages.forms +import django.contrib.flatpages.middleware +import django.contrib.flatpages.models +import django.contrib.flatpages.sitemaps +import django.contrib.flatpages.templatetags +import django.contrib.flatpages.templatetags.flatpages +import django.contrib.flatpages.views +import django.contrib.humanize.templatetags +import django.contrib.humanize.templatetags.humanize +import django.contrib.messages.api +import django.contrib.messages.context_processors +import django.contrib.messages.middleware +import django.contrib.messages.storage +import django.contrib.messages.storage.base +import django.contrib.messages.storage.cookie +import django.contrib.messages.storage.fallback +import django.contrib.messages.storage.session +import django.contrib.messages.utils +import django.contrib.messages.views +import django.contrib.postgres.fields +import django.contrib.postgres.fields.array +import django.contrib.postgres.fields.citext +import django.contrib.postgres.fields.hstore +import django.contrib.postgres.fields.jsonb +import django.contrib.postgres.fields.mixins +import django.contrib.postgres.fields.ranges +import django.contrib.postgres.operations +import django.contrib.redirects +import django.contrib.redirects.middleware +import django.contrib.redirects.models +import django.contrib.sessions.backends +import django.contrib.sessions.backends.base +import django.contrib.sessions.backends.cache +import django.contrib.sessions.backends.cached_db +import django.contrib.sessions.backends.db +import django.contrib.sessions.backends.file +import django.contrib.sessions.backends.signed_cookies +import django.contrib.sessions.base_session +import django.contrib.sessions.management.commands +import django.contrib.sessions.management.commands.clearsessions +import django.contrib.sessions.middleware +import django.contrib.sessions.models +import django.contrib.sessions.serializers +import django.contrib.sitemaps.management.commands +import django.contrib.sitemaps.management.commands.ping_google +import django.contrib.sitemaps.views +import django.contrib.sites +import django.contrib.sites.apps +import django.contrib.sites.management +import django.contrib.sites.managers +import django.contrib.sites.middleware +import django.contrib.sites.models +import django.contrib.sites.requests +import django.contrib.sites.shortcuts +import django.contrib.staticfiles.apps +import django.contrib.staticfiles.checks +import django.contrib.staticfiles.finders +import django.contrib.staticfiles.handlers +import django.contrib.staticfiles.management.commands +import django.contrib.staticfiles.management.commands.collectstatic +import django.contrib.staticfiles.management.commands.findstatic +import django.contrib.staticfiles.management.commands.runserver +import django.contrib.staticfiles.storage +import django.contrib.staticfiles.templatetags +import django.contrib.staticfiles.templatetags.staticfiles +import django.contrib.staticfiles.urls +import django.contrib.staticfiles.utils +import django.contrib.staticfiles.views +import django.contrib.syndication +import django.contrib.syndication.views +import django.core.cache.backends +import django.core.cache.backends.base +import django.core.cache.backends.db +import django.core.cache.backends.dummy +import django.core.cache.backends.filebased +import django.core.cache.backends.locmem +import django.core.cache.utils +import django.core.checks.caches +import django.core.checks.database +import django.core.checks.messages +import django.core.checks.model_checks +import django.core.checks.registry +import django.core.checks.security +import django.core.checks.security.base +import django.core.checks.security.csrf +import django.core.checks.security.sessions +import django.core.checks.templates +import django.core.checks.urls +import django.core.exceptions +import django.core.files +import django.core.files.base +import django.core.files.images +import django.core.files.locks +import django.core.files.move +import django.core.files.storage +import django.core.files.temp +import django.core.files.uploadedfile +import django.core.files.uploadhandler +import django.core.files.utils +import django.core.handlers +import django.core.handlers.base +import django.core.handlers.exception +import django.core.handlers.wsgi +import django.core.mail +import django.core.mail.message +import django.core.mail.utils +import django.core.management +import django.core.management.base +import django.core.management.color +import django.core.management.sql +import django.core.management.templates +import django.core.management.utils +import django.core.paginator +import django.core.serializers +import django.core.serializers.base +import django.core.serializers.json +import django.core.serializers.python +import django.core.servers +import django.core.servers.basehttp +import django.core.signals +import django.core.signing +import django.core.validators +import django.core.wsgi +import django.db.backends.base +import django.db.backends.base.base +import django.db.backends.base.client +import django.db.backends.base.creation +import django.db.backends.base.features +import django.db.backends.base.introspection +import django.db.backends.base.operations +import django.db.backends.base.schema +import django.db.backends.base.validation +import django.db.backends.ddl_references +import django.db.backends.dummy +import django.db.backends.dummy.base +import django.db.backends.mysql +import django.db.backends.mysql.client +import django.db.backends.postgresql +import django.db.backends.postgresql.client +import django.db.backends.sqlite3 +import django.db.backends.sqlite3.base +import django.db.backends.sqlite3.creation +import django.db.backends.sqlite3.features +import django.db.backends.sqlite3.introspection +import django.db.backends.sqlite3.operations +import django.db.backends.sqlite3.schema +import django.db.backends.utils +import django.db.migrations.autodetector +import django.db.migrations.exceptions +import django.db.migrations.executor +import django.db.migrations.graph +import django.db.migrations.loader +import django.db.migrations.migration +import django.db.migrations.operations +import django.db.migrations.operations.base +import django.db.migrations.operations.fields +import django.db.migrations.operations.models +import django.db.migrations.operations.special +import django.db.migrations.operations.utils +import django.db.migrations.optimizer +import django.db.migrations.questioner +import django.db.migrations.recorder +import django.db.migrations.serializer +import django.db.migrations.state +import django.db.migrations.topological_sort +import django.db.migrations.utils +import django.db.migrations.writer +import django.db.models.aggregates +import django.db.models.base +import django.db.models.deletion +import django.db.models.expressions +import django.db.models.fields +import django.db.models.fields.files +import django.db.models.fields.mixins +import django.db.models.fields.proxy +import django.db.models.fields.related +import django.db.models.fields.related_descriptors +import django.db.models.fields.related_lookups +import django.db.models.fields.reverse_related +import django.db.models.functions +import django.db.models.functions.comparison +import django.db.models.functions.datetime +import django.db.models.functions.text +import django.db.models.functions.window +import django.db.models.indexes +import django.db.models.lookups +import django.db.models.manager +import django.db.models.options +import django.db.models.query +import django.db.models.query_utils +import django.db.models.signals +import django.db.models.sql +import django.db.models.sql.compiler +import django.db.models.sql.constants +import django.db.models.sql.datastructures +import django.db.models.sql.query +import django.db.models.sql.subqueries +import django.db.models.sql.where +import django.db.models.utils +import django.db.transaction +import django.db.utils +import django.dispatch +import django.dispatch.dispatcher +import django.forms +import django.forms.boundfield +import django.forms.fields +import django.forms.forms +import django.forms.formsets +import django.forms.models +import django.forms.renderers +import django.forms.utils +import django.forms.widgets +import django.http +import django.http.cookie +import django.http.multipartparser +import django.http.request +import django.http.response +import django.middleware +import django.middleware.cache +import django.middleware.clickjacking +import django.middleware.common +import django.middleware.csrf +import django.middleware.gzip +import django.middleware.http +import django.middleware.locale +import django.middleware.security +import django.shortcuts +import django.template.backends +import django.template.backends.base +import django.template.backends.django +import django.template.backends.dummy +import django.template.backends.jinja2 +import django.template.backends.utils +import django.template.base +import django.template.context +import django.template.context_processors +import django.template.defaultfilters +import django.template.defaulttags +import django.template.engine +import django.template.exceptions +import django.template.library +import django.template.loader +import django.template.loader_tags +import django.template.loaders +import django.template.loaders.app_directories +import django.template.loaders.base +import django.template.loaders.cached +import django.template.loaders.filesystem +import django.template.loaders.locmem +import django.template.response +import django.template.smartif +import django.template.utils +import django.templatetags +import django.templatetags.cache +import django.templatetags.i18n +import django.templatetags.l10n +import django.templatetags.static +import django.templatetags.tz +import django.test +import django.test.client +import django.test.html +import django.test.runner +import django.test.selenium +import django.test.signals +import django.test.testcases +import django.test.utils +import django.urls +import django.urls.base +import django.urls.conf +import django.urls.converters +import django.urls.exceptions +import django.urls.resolvers +import django.urls.utils +import django.utils._os +import django.utils.archive +import django.utils.autoreload +import django.utils.baseconv +import django.utils.cache +import django.utils.crypto +import django.utils.datastructures +import django.utils.dateformat +import django.utils.dateparse +import django.utils.dates +import django.utils.datetime_safe +import django.utils.deconstruct +import django.utils.decorators +import django.utils.deprecation +import django.utils.duration +import django.utils.encoding +import django.utils.feedgenerator +import django.utils.formats +import django.utils.functional +import django.utils.html +import django.utils.http +import django.utils.inspect +import django.utils.ipv6 +import django.utils.itercompat +import django.utils.jslex +import django.utils.log +import django.utils.lorem_ipsum +import django.utils.module_loading +import django.utils.numberformat +import django.utils.regex_helper +import django.utils.safestring +import django.utils.six +import django.utils.termcolors +import django.utils.text +import django.utils.timesince +import django.utils.timezone +import django.utils.translation +import django.utils.translation.template +import django.utils.translation.trans_null +import django.utils.translation.trans_real +import django.utils.tree +import django.utils.version +import django.utils.xmlutils +import django.views.csrf +import django.views.debug +import django.views.decorators +import django.views.decorators.cache +import django.views.decorators.clickjacking +import django.views.decorators.csrf +import django.views.decorators.debug +import django.views.decorators.gzip +import django.views.decorators.http +import django.views.decorators.vary +import django.views.defaults +import django.views.generic +import django.views.generic.base +import django.views.generic.dates +import django.views.generic.detail +import django.views.generic.edit +import django.views.generic.list +import django.views.i18n +import django.views.static +[/CASE] \ No newline at end of file