30 Commits

Author SHA1 Message Date
Maxim Kurnikov
5dd6eccdb5 make ignore_missing_model_attributes behaviour optional (#66)
make "ignore_missing_model_attributes" behaviour opt-in
2019-04-12 17:22:18 +03:00
Maxim Kurnikov
fd06816cbb Work around "no settings module" crash (#65)
Workaround "no settings module" crash
2019-04-12 17:14:23 +03:00
Maxim Kurnikov
aeb435c8b3 Disable monkeypatches, add dependencies via new hook (#60)
* code cleanups, disable monkeypatches, move to add_additional_deps

* disable incremental mode for tests

* add pip-wheel-metadata

* move some code from get_base_hook to get_attribute_hook to reduce dependencies

* simplify values/values_list tests and code

* disable cache for some tests failing with incremental mode

* enable incremental mode for tests typechecking

* pin mypy version

* fix tests

* lint

* fix internal crashes
2019-04-12 14:54:00 +03:00
Maxim Kurnikov
13d19017b7 bump version 2019-04-01 19:40:13 +03:00
Maxim Kurnikov
28a3f126ee make mypy.checker import locally to prevent import cycles 2019-04-01 19:39:50 +03:00
Maxim Kurnikov
304cb19de6 really drop universal 2019-04-01 01:43:14 +03:00
Maxim Kurnikov
c57f4f7152 only python3.6+ are supported 2019-04-01 01:08:46 +03:00
Maxim Kurnikov
8a826fee1e bump version 2019-04-01 00:54:36 +03:00
Maxim Kurnikov
37d85c2ca6 pin mypy version, django-stubs not yet supports mypyc 2019-04-01 00:54:15 +03:00
Seth Yastrov
71fb0432f3 52/model subtypes dont typecheck (#55)
* Fix problem where Model instancess are not considered subtypes of each other due to fallback_to_any = True. Fixes #52.

- Added a stub for __getstate__ to Model.
- Added a stub for clean() to Model.
- Correct arg type for sort_dependencies so they are covariant (Iterable rather than List).

Test ignores:
- Added some test ignores in cases where a model inherits from 2 different base models.
- Added some test ignores for cases that MyPy flags as errors due to variable redefinitions or imports that are incompatible types.

* Address review comment.
2019-03-28 23:13:02 +03:00
Maxim Kurnikov
9288c34648 fix @classproperty return type (#58) 2019-03-27 23:13:10 +03:00
Maxim Kurnikov
70050f28b9 drop --universal 2019-03-26 03:23:25 +03:00
Maxim Kurnikov
4338c17970 bump version 2019-03-25 14:22:17 +03:00
Maxim Kurnikov
91f789c38c fix SessionBase.exists() return type (#57) 2019-03-25 14:21:12 +03:00
Maxim Kurnikov
0f5b45fba1 bump version 2019-03-25 13:31:41 +03:00
Seth Yastrov
5b455b729a Specific return types for values and values list (#53)
* Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43.

- Add a couple of extra type checks that Django makes:
  1) 'flat' and 'named' can't be used together.
  2) 'flat' is not valid when values_list is called with more than one field.

* Determine better row types for values_list/values based on fields specified.

- In the case of values_list, we use a Row type with either a single primitive, Tuple, or NamedTuple.
- In the case of values, we use a TypedDict.
- In both cases, Any is used as a fallback for individual fields if those fields cannot be resolved.

A couple other fixes I made along the way:
- Don't create reverse relation for ForeignKeys with related_name='+'
- Don't skip creating other related managers in AddRelatedManagers if a dynamic value is encountered
  for related_name parameter, or if the type cannot be determined.

* Fix for TypedDict so that they are considered anonymous.

* Clean up some comments.

* Implement making TypedDict anonymous in a way that doesn't crash sometimes.

* Fix flake8 errors.

* Remove even uglier hack about making TypedDict anonymous.

* Address review comments. Write a few better comments inside tests.

* Fix crash when running with mypyc ("interpreted classes cannot inherit from compiled") due to the way I extended TypedDictType.

- Implemented the hack in another way that works on mypyc.
- Added a couple extra tests of accessing 'id' / 'pk' via values_list.

* Fix flake8 errors.

* Support annotation expressions (use type Any) for TypedDicts row types returned by values_list.

- Bonus points: handle values_list gracefully (use type Any) where Tuples are returned
  where some of the fields arguments are not string literals.
2019-03-25 12:53:09 +03:00
Maxim Kurnikov
5c6be7ad12 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
2019-03-25 01:57:34 +03:00
Maxim Kurnikov
5d0ee40ada Fix errors in db.models.expressions and db.models.functions.* (#54)
* fix errors at db.models.expressions and db.models.functions.*

* catch KeyError if QuerySet has not been loaded
2019-03-24 02:54:10 +03:00
Konstantin Alekseev
77f15d7478 Configure black using pyproject.toml (#50) 2019-03-18 16:53:12 +03:00
Konstantin Alekseev
4f83d8d1bb Use less specific types in validators args (#49) 2019-03-18 13:31:35 +03:00
Seth Yastrov
b1a04d2f7d Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43. (#44)
- Add a couple of extra type checks that Django makes:
  1) 'flat' and 'named' can't be used together.
  2) 'flat' is not valid when values_list is called with more than one field.
2019-03-13 22:10:37 +03:00
Maxim Kurnikov
7c57143310 forms/__init__ reimports 2019-03-10 21:14:15 +03:00
Maxim Kurnikov
c3d76f9a1e bump version 2019-03-10 20:03:00 +03:00
Maxim Kurnikov
fde071b883 fix classonlymethod, replace with six from typeshed 2019-03-10 19:56:54 +03:00
Seth Yastrov
324b961d74 Support returning the correct values for the different QuerySet methods when using .values() and .values_list(). (#33)
* Support returning the correct values for the different QuerySet methods when using .values() and .values_list().

* Fix slicing on QuerySet. Fix django queries test, and remove some ignored errors that are no longer needed.

* Remove accidental change in RawQuerySet.

* Readded some still-necessary ignores to aggregation django test.

* Add more tests of first/last/earliest/last/__getitem__, per mkurnikov's comments.

- Fix .iterator()

* Re-add Iterator as base-class of QuerySet.

* Make QuerySet a Collection.

* - Fix return type for QuerySet.select_for_update().
- Use correct return type for QuerySet.dates() / QuerySet.datetimes().
- Use correct type params in return type for QuerySet.__and__ / QuerySet.__or__
- Re-add Sized as base class for QuerySet.
- Add test of .all() for all _Row types.
- Add test of .get() for all _Row types.
- Remove some redundant QuerySet method tests.

* Automatically fill in second type parameter for QuerySet.

... if second parameter is omitted.
2019-03-10 12:13:50 +03:00
Seth Yastrov
86c63d790b Fix type errors on other models' managers when using objects = models.Manager() in Model. (#34)
* Fix bug where models with a class variable using a manager defined would interfere with other managers.

- Fill in the type argument for that particular instance of the manager, rather than modifying the bases of the Manager type.
- Instantiate a new Instance from determine_proper_manager_type so The code doesn't crash under mypy-mypyc.

* Use helpers.reparametrize_instance per review comment.

* Updated ignored errors in Django test for get_objects_or_404.

- For some reason, `Manager[nothing]` is now removed from expected types.
  However, I think this makes sense anyway, as Manager is a subclass of QuerySet.
2019-03-08 12:30:38 +03:00
Matt Basta
050c1b8887 Add gzip_page decorator (#41)
* Add gzip_page decorator

* Update to preserve Callable
2019-03-06 21:16:24 +03:00
Maxim Kurnikov
8978ad471f bump version 2019-03-06 12:05:24 +03:00
Richard Eames
f7dfbefbd6 Make CharField(blank=True) not be considered nullable (#39)
* Make CharField(blank=True) not be considered nullable

The documentation on [blank](https://docs.djangoproject.com/en/2.1/ref/models/fields/#blank) says that it "will allow the entry of an empty value", which for a string is just a 0-length string. This patch allows `CharField(blank=True,...)` to no longer be considered `Optional`.

closes #38

* fixed tests for `CharField(blank=True)`

* allow blank CharField to be nullable in the constructor, but the underlying type
is str (unless `null=True`)
2019-03-06 01:37:44 +03:00
Maxim Kurnikov
627daa55f5 fix extension of django.views __init__ file 2019-03-06 01:28:42 +03:00
127 changed files with 2554 additions and 2071 deletions

1
.gitignore vendored
View File

@@ -8,3 +8,4 @@ out/
django-sources django-sources
build/ build/
dist/ dist/
pip-wheel-metadata/

View File

@@ -44,6 +44,9 @@ django_settings = mysettings.local
# if True, all unknown settings in django.conf.settings will fallback to Any, # if True, all unknown settings in django.conf.settings will fallback to Any,
# specify it if your settings are loaded dynamically to avoid false positives # specify it if your settings are loaded dynamically to avoid false positives
ignore_missing_settings = True ignore_missing_settings = True
# if True, unknown attributes on Model instances won't produce errors
ignore_missing_model_attributes = True
``` ```
## To get help ## To get help

View File

@@ -1,7 +1,12 @@
from typing import Any from typing import Any, NamedTuple
from .utils.version import get_version as get_version from .utils.version import get_version as get_version
VERSION: Any VERSION: Any
__version__: str __version__: str
def setup(set_prefix: bool = ...) -> None: ... def setup(set_prefix: bool = ...) -> None: ...
# Used by mypy_django_plugin when returning a QuerySet row that is a NamedTuple where the field names are unknown
class _NamedTupleAnyAttr(NamedTuple):
def __getattr__(self, item: str) -> Any: ...
def __setattr__(self, item: str, value: Any) -> None: ...

View File

@@ -2,10 +2,14 @@ from typing import Any
from django.utils.functional import LazyObject from django.utils.functional import LazyObject
# explicit dependency on standard settings to make it loaded
from . import global_settings
ENVIRONMENT_VARIABLE: str = ... ENVIRONMENT_VARIABLE: str = ...
# required for plugin to be able to distinguish this specific instance of LazySettings from others # required for plugin to be able to distinguish this specific instance of LazySettings from others
class _DjangoConfLazyObject(LazyObject): ... class _DjangoConfLazyObject(LazyObject):
def __getattr__(self, item: Any) -> Any: ...
class LazySettings(_DjangoConfLazyObject): class LazySettings(_DjangoConfLazyObject):
configured: bool configured: bool

View File

@@ -5,14 +5,11 @@ by the DJANGO_SETTINGS_MODULE environment variable.
# This is defined here as a do-nothing function because we can't import # This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings. # django.utils.translation -- that module depends on the settings.
from typing import Any, Dict, List, Optional, Pattern, Tuple, Protocol, Union, Callable, TYPE_CHECKING, Sequence from typing import Any, Dict, List, Optional, Pattern, Protocol, Sequence, Tuple, Union
#################### ####################
# CORE # # CORE #
#################### ####################
if TYPE_CHECKING:
from django.db.models.base import Model
DEBUG: bool = ... DEBUG: bool = ...
# Whether the framework should propagate raw exceptions rather than catching # Whether the framework should propagate raw exceptions rather than catching
@@ -153,7 +150,7 @@ FORCE_SCRIPT_NAME = None
# ] # ]
DISALLOWED_USER_AGENTS: List[Pattern] = ... DISALLOWED_USER_AGENTS: List[Pattern] = ...
ABSOLUTE_URL_OVERRIDES: Dict[str, Callable[[Model], str]] = ... ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ...
# List of compiled regular expression objects representing URLs that need not # List of compiled regular expression objects representing URLs that need not
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples: # be reported by BrokenLinkEmailsMiddleware. Here are a few examples:

View File

@@ -1,25 +1,6 @@
from typing import Any
from django.apps import AppConfig from django.apps import AppConfig
class SimpleAdminConfig(AppConfig): class SimpleAdminConfig(AppConfig):
apps: None
label: str
models: None
models_module: None
module: Any
path: str
default_site: str = ... default_site: str = ...
name: str = ...
verbose_name: Any = ...
def ready(self) -> None: ...
class AdminConfig(SimpleAdminConfig): class AdminConfig(SimpleAdminConfig): ...
apps: None
label: str
models: None
models_module: None
module: Any
name: str
path: str
def ready(self) -> None: ...

View File

@@ -1,33 +1,7 @@
from typing import Any, Dict
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
from django.contrib.auth.models import User
class AdminAuthenticationForm(AuthenticationForm): 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 = ... required_css_class: str = ...
def confirm_login_allowed(self, user: User) -> None: ...
class AdminPasswordChangeForm(PasswordChangeForm): 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 = ... required_css_class: str = ...

View File

@@ -1,27 +1,17 @@
import collections from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Type
from django import forms
from django.contrib.auth.forms import AdminPasswordChangeForm from django.contrib.auth.forms import AdminPasswordChangeForm
from django.db.models.fields import AutoField from django.forms.boundfield import BoundField
from django.forms.utils import ErrorDict, ErrorList from django.forms.utils import ErrorDict
from django.forms.widgets import Media, Widget from django.forms.widgets import Media, Widget
from django.utils.safestring import SafeText 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 ACTION_CHECKBOX_NAME: str
class ActionForm(forms.Form): 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 = ... action: Any = ...
select_across: Any = ... select_across: Any = ...
@@ -36,8 +26,8 @@ class AdminForm:
form: AdminPasswordChangeForm, form: AdminPasswordChangeForm,
fieldsets: List[Tuple[None, Dict[str, List[str]]]], fieldsets: List[Tuple[None, Dict[str, List[str]]]],
prepopulated_fields: Dict[Any, Any], prepopulated_fields: Dict[Any, Any],
readonly_fields: None = ..., readonly_fields: Any = ...,
model_admin: None = ..., model_admin: Any = ...,
) -> None: ... ) -> None: ...
def __iter__(self) -> Iterator[Fieldset]: ... def __iter__(self) -> Iterator[Fieldset]: ...
@property @property
@@ -137,7 +127,6 @@ class InlineAdminFormSet:
class InlineAdminForm(AdminForm): class InlineAdminForm(AdminForm):
formset: Any = ... formset: Any = ...
model_admin: Any = ...
original: Any = ... original: Any = ...
show_url: Any = ... show_url: Any = ...
absolute_url: Any = ... absolute_url: Any = ...
@@ -152,7 +141,6 @@ class InlineAdminForm(AdminForm):
model_admin: Optional[Any] = ..., model_admin: Optional[Any] = ...,
view_on_site_url: Optional[Any] = ..., view_on_site_url: Optional[Any] = ...,
) -> None: ... ) -> None: ...
def __iter__(self) -> Iterator[InlineFieldset]: ...
def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ... def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ...
def pk_field(self) -> AdminField: ... def pk_field(self) -> AdminField: ...
def fk_field(self) -> AdminField: ... def fk_field(self) -> AdminField: ...
@@ -162,9 +150,6 @@ class InlineAdminForm(AdminForm):
class InlineFieldset(Fieldset): class InlineFieldset(Fieldset):
formset: Any = ... formset: Any = ...
def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ... def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ...
def __iter__(self) -> Iterator[Fieldline]: ...
class AdminErrorList(forms.utils.ErrorList): class AdminErrorList(forms.utils.ErrorList):
data: List[Any]
error_class: str
def __init__(self, form: Any, inline_formsets: Any) -> None: ... def __init__(self, form: Any, inline_formsets: Any) -> None: ...

View File

@@ -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.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 from django.views.generic.list import BaseListView
class AutocompleteJsonView(BaseListView): class AutocompleteJsonView(BaseListView):
paginate_by: int = ...
model_admin: ModelAdmin = ... model_admin: ModelAdmin = ...
term: Any = ... 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: ... def has_perm(self, request: WSGIRequest, obj: None = ...) -> bool: ...

View File

@@ -1,18 +1,12 @@
from collections import OrderedDict from typing import Any, Dict, List, Optional, Set, Tuple, Union
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
from uuid import UUID 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.models import ModelChoiceIterator
from django.forms.widgets import ChoiceWidget, Media
from django import forms 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): class FilteredSelectMultiple(forms.SelectMultiple):
@property @property
@@ -20,109 +14,34 @@ class FilteredSelectMultiple(forms.SelectMultiple):
verbose_name: Any = ... verbose_name: Any = ...
is_stacked: Any = ... is_stacked: Any = ...
def __init__(self, verbose_name: str, is_stacked: bool, attrs: None = ..., choices: Tuple = ...) -> None: ... 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): class AdminDateWidget(forms.DateInput):
attrs: Dict[str, str]
input_type: str
@property @property
def media(self) -> Media: ... def media(self) -> Media: ...
def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ...
class AdminTimeWidget(forms.TimeInput): class AdminTimeWidget(forms.TimeInput):
attrs: Dict[str, str]
input_type: str
@property @property
def media(self) -> Media: ... def media(self) -> Media: ...
def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ...
class AdminSplitDateTime(forms.SplitDateTimeWidget): class AdminSplitDateTime(forms.SplitDateTimeWidget): ...
attrs: Dict[Any, Any] class AdminRadioSelect(forms.RadioSelect): ...
widgets: List[DateTimeBaseInput] class AdminFileWidget(forms.ClearableFileInput): ...
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 AdminRadioSelect(forms.RadioSelect): def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ...
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]: ...
class ForeignKeyRawIdWidget(forms.TextInput): class ForeignKeyRawIdWidget(forms.TextInput):
attrs: Dict[Any, Any]
template_name: str = ...
rel: ManyToOneRel = ... rel: ManyToOneRel = ...
admin_site: AdminSite = ... admin_site: AdminSite = ...
db: None = ... db: None = ...
def __init__(self, rel: ForeignObjectRel, admin_site: AdminSite, attrs: None = ..., using: None = ...) -> 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 base_url_parameters(self) -> Dict[str, str]: ...
def 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]: ... def label_and_url_for_value(self, value: Union[int, str, UUID]) -> Tuple[str, str]: ...
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): 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 RelatedFieldWidgetWrapper(forms.Widget): class RelatedFieldWidgetWrapper(forms.Widget):
template_name: str = ... template_name: str = ...
needs_multipart_form: bool = ...
attrs: Dict[Any, Any] = ...
choices: ModelChoiceIterator = ... choices: ModelChoiceIterator = ...
widget: AutocompleteSelect = ... widget: AutocompleteSelect = ...
rel: ManyToOneRel = ... rel: ManyToOneRel = ...
@@ -141,54 +60,19 @@ class RelatedFieldWidgetWrapper(forms.Widget):
can_delete_related: bool = ..., can_delete_related: bool = ...,
can_view_related: bool = ..., can_view_related: bool = ...,
) -> None: ... ) -> None: ...
def __deepcopy__(
self, memo: Dict[int, Union[List[Union[Field, Widget]], OrderedDict, Field, Widget]]
) -> RelatedFieldWidgetWrapper: ...
@property
def is_hidden(self) -> bool: ...
@property @property
def media(self) -> Media: ... def media(self) -> Media: ...
def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ... 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): class AdminTextareaWidget(forms.Textarea): ...
attrs: Dict[str, str] class AdminTextInputWidget(forms.TextInput): ...
def __init__(self, attrs: None = ...) -> None: ... class AdminEmailInputWidget(forms.EmailInput): ...
class AdminURLFieldWidget(forms.URLInput): ...
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 AdminIntegerFieldWidget(forms.NumberInput): class AdminIntegerFieldWidget(forms.NumberInput):
attrs: Dict[str, str]
input_type: str
class_name: str = ... class_name: str = ...
def __init__(self, attrs: None = ...) -> None: ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
class_name: str = ...
SELECT2_TRANSLATIONS: Any SELECT2_TRANSLATIONS: Any
@@ -208,12 +92,6 @@ class AutocompleteMixin:
using: None = ..., using: None = ...,
) -> None: ... ) -> None: ...
def get_url(self) -> str: ... 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 @property
def media(self) -> Media: ... def media(self) -> Media: ...

View File

@@ -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.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.http.response import HttpResponse
from django.urls.resolvers import URLPattern
from django.contrib import admin from django.contrib import admin
from django.contrib.admin.sites import AdminSite
csrf_protect_m: Any csrf_protect_m: Any
sensitive_post_parameters_m: Any sensitive_post_parameters_m: Any
class GroupAdmin(admin.ModelAdmin): 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 UserAdmin(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 = ... change_user_password_template: Any = ...
fieldsets: Any = ...
add_fieldsets: Any = ... add_fieldsets: Any = ...
form: Any = ...
add_form: Any = ... add_form: Any = ...
change_password_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 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: ...

View File

@@ -1,18 +1,3 @@
from typing import Any, Optional
from django.apps import AppConfig from django.apps import AppConfig
from .checks import check_models_permissions, check_user_model class AuthConfig(AppConfig): ...
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: ...

View File

@@ -1,8 +1,6 @@
from typing import Any, List, Optional from typing import Any, List
from django.core.checks.messages import CheckMessage 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_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ... def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...

View File

@@ -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.http.request import HttpRequest
from django.utils.functional import SimpleLazyObject
class PermLookupDict: class PermLookupDict:
app_label: django.utils.safestring.SafeText app_label: str
user: SimpleLazyObject user: Any
def __init__(self, user: SimpleLazyObject, app_label: str) -> None: ... def __init__(self, user: Any, app_label: str) -> None: ...
def __getitem__(self, perm_name: str) -> bool: ... def __getitem__(self, perm_name: str) -> bool: ...
def __iter__(self) -> Any: ... def __iter__(self) -> Any: ...
def __bool__(self) -> bool: ... def __bool__(self) -> bool: ...
class PermWrapper: class PermWrapper:
user: SimpleLazyObject = ... user: Any = ...
def __init__(self, user: Union[AnonymousUser, User]) -> None: ... def __init__(self, user: Any) -> None: ...
def __getitem__(self, app_label: str) -> PermLookupDict: ... def __getitem__(self, app_label: str) -> PermLookupDict: ...
def __iter__(self) -> Any: ... 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]: ...

View File

@@ -1,44 +1,24 @@
import collections from typing import Any, Dict, Iterator, Optional
import datetime
from typing import Any, Dict, Iterator, List, Optional, Union, Type
from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AbstractUser, User from django.contrib.auth.models import AbstractUser, User
from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.handlers.wsgi import WSGIRequest 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 from django import forms
UserModel: Any UserModel: Any
class ReadOnlyPasswordHashWidget(forms.Widget): class ReadOnlyPasswordHashWidget(forms.Widget):
attrs: Dict[Any, Any]
template_name: str = ... template_name: str = ...
class ReadOnlyPasswordHashField(forms.Field): class ReadOnlyPasswordHashField(forms.Field):
widget: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... 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): class UsernameField(forms.CharField): ...
def to_python(self, value: Optional[str]) -> str: ...
class UserCreationForm(forms.ModelForm): 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 = ... error_messages: Any = ...
password1: Any = ... password1: Any = ...
password2: Any = ... password2: Any = ...
@@ -46,30 +26,11 @@ class UserCreationForm(forms.ModelForm):
def clean_password2(self) -> str: ... def clean_password2(self) -> str: ...
class UserChangeForm(forms.ModelForm): 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 = ... password: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password(self) -> str: ... def clean_password(self) -> str: ...
class AuthenticationForm(forms.Form): 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 = ... username: Any = ...
password: Any = ... password: Any = ...
error_messages: Any = ... error_messages: Any = ...
@@ -82,21 +43,12 @@ class AuthenticationForm(forms.Form):
def get_invalid_login_error(self) -> ValidationError: ... def get_invalid_login_error(self) -> ValidationError: ...
class PasswordResetForm(forms.Form): 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 = ... email: Any = ...
def send_mail( def send_mail(
self, self,
subject_template_name: str, subject_template_name: str,
email_template_name: str, email_template_name: str,
context: Dict[str, Union[AbstractBaseUser, str]], context: Dict[str, Any],
from_email: Optional[str], from_email: Optional[str],
to_email: str, to_email: str,
html_email_template_name: Optional[str] = ..., html_email_template_name: Optional[str] = ...,
@@ -116,15 +68,6 @@ class PasswordResetForm(forms.Form):
) -> None: ... ) -> None: ...
class SetPasswordForm(forms.Form): 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 = ... error_messages: Any = ...
new_password1: Any = ... new_password1: Any = ...
new_password2: Any = ... new_password2: Any = ...
@@ -134,31 +77,10 @@ class SetPasswordForm(forms.Form):
def save(self, commit: bool = ...) -> AbstractBaseUser: ... def save(self, commit: bool = ...) -> AbstractBaseUser: ...
class PasswordChangeForm(SetPasswordForm): 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 = ... old_password: Any = ...
field_order: Any = ...
def clean_old_password(self) -> str: ... def clean_old_password(self) -> str: ...
class AdminPasswordChangeForm(forms.Form): 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 = ... error_messages: Any = ...
required_css_class: str = ... required_css_class: str = ...
password1: Any = ... password1: Any = ...
@@ -167,5 +89,3 @@ class AdminPasswordChangeForm(forms.Form):
def __init__(self, user: AbstractUser, *args: Any, **kwargs: Any) -> None: ... def __init__(self, user: AbstractUser, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ... def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> AbstractUser: ... def save(self, commit: bool = ...) -> AbstractUser: ...
@property
def changed_data(self) -> List[str]: ...

View File

@@ -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.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.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest 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.template.response import TemplateResponse
from django.utils.datastructures import MultiValueDict
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
@@ -20,29 +15,18 @@ class SuccessURLAllowedHostsMixin:
def get_success_url_allowed_hosts(self) -> Set[str]: ... def get_success_url_allowed_hosts(self) -> Set[str]: ...
class LoginView(SuccessURLAllowedHostsMixin, FormView): class LoginView(SuccessURLAllowedHostsMixin, FormView):
form_class: Any = ...
authentication_form: Any = ... authentication_form: Any = ...
redirect_field_name: Any = ... redirect_field_name: Any = ...
template_name: str = ...
redirect_authenticated_user: bool = ... redirect_authenticated_user: bool = ...
extra_context: Any = ... 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_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): class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
next_page: Any = ... next_page: Any = ...
redirect_field_name: Any = ... redirect_field_name: Any = ...
template_name: str = ...
extra_context: Any = ... extra_context: Any = ...
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def post(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> TemplateResponse: ... def post(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> TemplateResponse: ...
def get_next_page(self) -> Optional[str]: ... 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 logout_then_login(request: HttpRequest, login_url: Optional[str] = ...) -> HttpResponseRedirect: ...
def redirect_to_login( def redirect_to_login(
@@ -56,55 +40,32 @@ class PasswordContextMixin:
class PasswordResetView(PasswordContextMixin, FormView): class PasswordResetView(PasswordContextMixin, FormView):
email_template_name: str = ... email_template_name: str = ...
extra_email_context: Any = ... extra_email_context: Any = ...
form_class: Any = ...
from_email: Any = ... from_email: Any = ...
html_email_template_name: Any = ... html_email_template_name: Any = ...
subject_template_name: str = ... subject_template_name: str = ...
success_url: Any = ...
template_name: str = ...
title: Any = ... title: Any = ...
token_generator: 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_URL_TOKEN: str
INTERNAL_RESET_SESSION_TOKEN: str INTERNAL_RESET_SESSION_TOKEN: str
class PasswordResetDoneView(PasswordContextMixin, TemplateView): class PasswordResetDoneView(PasswordContextMixin, TemplateView):
template_name: str = ...
title: Any = ... title: Any = ...
class PasswordResetConfirmView(PasswordContextMixin, FormView): class PasswordResetConfirmView(PasswordContextMixin, FormView):
form_class: Any = ...
post_reset_login: bool = ... post_reset_login: bool = ...
post_reset_login_backend: Any = ... post_reset_login_backend: Any = ...
success_url: Any = ...
template_name: str = ...
title: Any = ... title: Any = ...
token_generator: Any = ... token_generator: Any = ...
validlink: bool = ... validlink: bool = ...
user: Any = ... user: Any = ...
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_user(self, uidb64: str) -> Optional[AbstractBaseUser]: ... 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): class PasswordResetCompleteView(PasswordContextMixin, TemplateView):
template_name: str = ...
title: Any = ... title: Any = ...
def get_context_data(self, **kwargs: Any): ...
class PasswordChangeView(PasswordContextMixin, FormView): class PasswordChangeView(PasswordContextMixin, FormView):
form_class: Any = ...
success_url: Any = ...
template_name: str = ...
title: Any = ... 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): class PasswordChangeDoneView(PasswordContextMixin, TemplateView):
template_name: str = ...
title: Any = ... title: Any = ...
def dispatch(self, *args: Any, **kwargs: Any) -> TemplateResponse: ...

View File

@@ -1,16 +1,3 @@
from typing import Any, Optional
from django.apps import AppConfig from django.apps import AppConfig
from .management import create_contenttypes, inject_rename_contenttypes_operations class ContentTypesConfig(AppConfig): ...
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: ...

View File

@@ -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 django.db.models.deletion import Collector
from ...management import get_contenttypes_and_models from django.core.management import BaseCommand
class Command(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 NoFastDeleteCollector(Collector): class NoFastDeleteCollector(Collector):
data: collections.OrderedDict data: Dict[str, Any]
dependencies: Dict[Any, Any] dependencies: Dict[Any, Any]
fast_deletes: List[Any] fast_deletes: List[Any]
field_updates: Dict[Any, Any] field_updates: Dict[Any, Any]

View File

@@ -1,19 +1,7 @@
from typing import Any, Dict, Optional, Union from typing import Any
from django import forms from django import forms
from django.db.models.query import QuerySet
class FlatpageForm(forms.ModelForm): 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 = ... url: Any = ...
def clean_url(self) -> str: ... def clean_url(self) -> str: ...
def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ...

View File

@@ -9,5 +9,5 @@ class FlatPage(models.Model):
enable_comments: models.BooleanField = ... enable_comments: models.BooleanField = ...
template_name: models.CharField = ... template_name: models.CharField = ...
registration_required: models.BooleanField = ... registration_required: models.BooleanField = ...
sites: models.ManyToManyField[Site] = ... sites: models.ManyToManyField[Site, Site] = ...
def get_absolute_url(self) -> str: ... def get_absolute_url(self) -> str: ...

View File

@@ -1,7 +1,3 @@
from typing import Optional
from django.contrib.sitemaps import Sitemap from django.contrib.sitemaps import Sitemap
from django.db.models.query import QuerySet
class FlatPageSitemap(Sitemap): class FlatPageSitemap(Sitemap): ...
def items(self) -> QuerySet: ...

View File

@@ -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] = ...

View File

@@ -16,7 +16,7 @@ class Message:
def level_tag(self) -> str: ... def level_tag(self) -> str: ...
class BaseStorage: class BaseStorage:
request: Any = ... request: HttpRequest = ...
used: bool = ... used: bool = ...
added_new: bool = ... added_new: bool = ...
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...

View File

@@ -1,49 +1,20 @@
import json 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): class MessageEncoder(json.JSONEncoder):
allow_nan: bool allow_nan: bool
check_circular: bool check_circular: bool
ensure_ascii: bool ensure_ascii: bool
indent: None
item_separator: str
key_separator: str
skipkeys: bool skipkeys: bool
sort_keys: bool sort_keys: bool
message_key: str = ... message_key: str = ...
def default(self, obj: Message) -> List[Union[int, str]]: ...
class MessageDecoder(json.JSONDecoder): class MessageDecoder(json.JSONDecoder):
def process_messages( def process_messages(self, obj: Any) -> Any: ...
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,
]: ...
class CookieStorage(BaseStorage): class CookieStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
cookie_name: str = ... cookie_name: str = ...
max_cookie_size: int = ... max_cookie_size: int = ...
not_finished: str = ... not_finished: str = ...

View File

@@ -1,11 +1,8 @@
from typing import Any, Optional from typing import Any
from django.contrib.messages.storage.base import BaseStorage from django.contrib.messages.storage.base import BaseStorage
class FallbackStorage(BaseStorage): class FallbackStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
storage_classes: Any = ... storage_classes: Any = ...
storages: Any = ... storages: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...

View File

@@ -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 from django.http.request import HttpRequest
class SessionStorage(BaseStorage): class SessionStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
session_key: str = ... session_key: str = ...
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ... def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
def serialize_messages(self, messages: Union[List[Message], List[str]]) -> str: ... def serialize_messages(self, messages: Sequence[Any]) -> str: ...
def deserialize_messages( def deserialize_messages(self, data: Optional[Union[List[Any], str]]) -> Optional[List[Any]]: ...
self, data: Optional[Union[List[Any], str]]
) -> Optional[Union[List[Message], List[str]]]: ...

View File

@@ -1,8 +1,6 @@
from datetime import datetime from datetime import datetime
from typing import Any, Dict, Optional, Union from typing import Any, Dict, Optional, Union
from django.db.models.base import Model
VALID_KEY_CHARS: Any VALID_KEY_CHARS: Any
class CreateError(Exception): ... class CreateError(Exception): ...
@@ -18,8 +16,8 @@ class SessionBase(Dict[str, Any]):
def set_test_cookie(self) -> None: ... def set_test_cookie(self) -> None: ...
def test_cookie_worked(self) -> bool: ... def test_cookie_worked(self) -> bool: ...
def delete_test_cookie(self) -> None: ... def delete_test_cookie(self) -> None: ...
def encode(self, session_dict: Dict[str, Model]) -> str: ... def encode(self, session_dict: Dict[str, Any]) -> str: ...
def decode(self, session_data: Union[bytes, str]) -> Dict[str, Model]: ... def decode(self, session_data: Union[bytes, str]) -> Dict[str, Any]: ...
def has_key(self, key: Any): ... def has_key(self, key: Any): ...
def keys(self): ... def keys(self): ...
def values(self): ... def values(self): ...
@@ -33,7 +31,7 @@ class SessionBase(Dict[str, Any]):
def get_expire_at_browser_close(self) -> bool: ... def get_expire_at_browser_close(self) -> bool: ...
def flush(self) -> None: ... def flush(self) -> None: ...
def cycle_key(self) -> None: ... def cycle_key(self) -> None: ...
def exists(self, session_key: str) -> None: ... def exists(self, session_key: str) -> bool: ...
def create(self) -> None: ... def create(self) -> None: ...
def save(self, must_create: bool = ...) -> None: ... def save(self, must_create: bool = ...) -> None: ...
def delete(self, session_key: Optional[Any] = ...) -> None: ... def delete(self, session_key: Optional[Any] = ...) -> None: ...

View File

@@ -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.backends.base import SessionBase
from django.contrib.sessions.serializers import JSONSerializer
KEY_PREFIX: str KEY_PREFIX: str
class SessionStore(SessionBase): class SessionStore(SessionBase):
accessed: bool
serializer: JSONSerializer
cache_key_prefix: Any = ... cache_key_prefix: Any = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ... def __init__(self, session_key: Optional[str] = ...) -> None: ...
@property @property
def cache_key(self) -> str: ... 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: ...

View File

@@ -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 from django.contrib.sessions.backends.db import SessionStore as DBStore
KEY_PREFIX: str KEY_PREFIX: str
class SessionStore(DBStore): class SessionStore(DBStore):
accessed: bool
modified: bool
serializer: Type[django.core.signing.JSONSerializer]
cache_key_prefix: Any = ... cache_key_prefix: Any = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ... def __init__(self, session_key: Optional[str] = ...) -> None: ...
@property @property
def cache_key(self) -> str: ... 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: ...

View File

@@ -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.backends.base import SessionBase
from django.contrib.sessions.base_session import AbstractBaseSession from django.contrib.sessions.base_session import AbstractBaseSession
from django.contrib.sessions.models import Session from django.contrib.sessions.models import Session
from django.core.signing import Serializer
from django.db.models.base import Model from django.db.models.base import Model
class SessionStore(SessionBase): class SessionStore(SessionBase):
accessed: bool
serializer: Type[Serializer]
def __init__(self, session_key: Optional[str] = ...) -> None: ... def __init__(self, session_key: Optional[str] = ...) -> None: ...
@classmethod @classmethod
def get_model_class(cls) -> Type[Session]: ... def get_model_class(cls) -> Type[Session]: ...
def model(self) -> Type[AbstractBaseSession]: ... 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 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: ...

View File

@@ -1,19 +1,9 @@
from typing import Any, Dict, Optional, Union from typing import Optional
from django.contrib.sessions.backends.base import SessionBase from django.contrib.sessions.backends.base import SessionBase
class SessionStore(SessionBase): class SessionStore(SessionBase):
accessed: bool
serializer: Type[django.core.signing.JSONSerializer]
storage_path: str = ... storage_path: str = ...
file_prefix: str = ... file_prefix: str = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ... 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: ... def clean(self) -> None: ...
@classmethod
def clear_expired(cls) -> None: ...

View File

@@ -1,17 +1,3 @@
from datetime import datetime
from typing import Any, Dict, Optional, Union
from django.contrib.sessions.backends.base import SessionBase from django.contrib.sessions.backends.base import SessionBase
class SessionStore(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: ...

View File

@@ -1,10 +1,3 @@
from typing import Any, Optional
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
class Command(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: ...

View File

@@ -15,7 +15,7 @@ def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None:
class Sitemap: class Sitemap:
limit: int = ... limit: int = ...
protocol: Any = ... protocol: Optional[str] = ...
def items(self) -> List[Any]: ... def items(self) -> List[Any]: ...
def location(self, obj: Model) -> str: ... def location(self, obj: Model) -> str: ...
@property @property
@@ -29,7 +29,6 @@ class GenericSitemap(Sitemap):
changefreq: Optional[str] = ... changefreq: Optional[str] = ...
queryset: QuerySet = ... queryset: QuerySet = ...
date_field: None = ... date_field: None = ...
protocol: Optional[str] = ...
def __init__( def __init__(
self, self,
info_dict: Dict[str, Union[datetime, QuerySet, str]], info_dict: Dict[str, Union[datetime, QuerySet, str]],
@@ -37,7 +36,6 @@ class GenericSitemap(Sitemap):
changefreq: Optional[str] = ..., changefreq: Optional[str] = ...,
protocol: Optional[str] = ..., protocol: Optional[str] = ...,
) -> None: ... ) -> None: ...
def items(self) -> QuerySet: ...
def lastmod(self, item: Model) -> Optional[datetime]: ... def lastmod(self, item: Model) -> Optional[datetime]: ...
default_app_config: str default_app_config: str

View File

@@ -1,14 +1,3 @@
from typing import Any
from django.apps import AppConfig from django.apps import AppConfig
class SitesConfig(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: ...

View File

@@ -1,15 +1,6 @@
from typing import Any, Optional from typing import Any
from django.apps import AppConfig from django.apps import AppConfig
class StaticFilesConfig(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 = ... ignore_patterns: Any = ...
def ready(self) -> None: ...

View File

@@ -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.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 from typing_extensions import Literal
searched_locations: Any searched_locations: Any
class BaseFinder: class BaseFinder:
def check(self, **kwargs: Any) -> Any: ... def check(self, **kwargs: Any) -> List[Error]: ...
def find(self, path: Any, all: bool = ...) -> None: ... def find(self, path: str, all: bool = ...) -> Optional[Any]: ...
def list(self, ignore_patterns: Any) -> None: ... def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
class FileSystemFinder(BaseFinder): class FileSystemFinder(BaseFinder):
locations: List[Any] = ... locations: List[Any] = ...
storages: Mapping[str, Any] = ... storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ... 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 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): class AppDirectoriesFinder(BaseFinder):
storage_class: Any = ... storage_class: Any = ...
@@ -27,15 +23,11 @@ class AppDirectoriesFinder(BaseFinder):
apps: List[str] = ... apps: List[str] = ...
storages: Mapping[str, Any] = ... storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ... 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]: ... def find_in_app(self, app: str, path: str) -> Optional[str]: ...
class BaseStorageFinder(BaseFinder): class BaseStorageFinder(BaseFinder):
storage: Storage = ... storage: Storage = ...
def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ... 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): ... class DefaultStorageFinder(BaseStorageFinder): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional from typing import Any
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
@@ -7,9 +7,6 @@ class StaticFilesHandler(WSGIHandler):
application: WSGIHandler = ... application: WSGIHandler = ...
base_url: Any = ... base_url: Any = ...
def __init__(self, application: WSGIHandler) -> None: ... def __init__(self, application: WSGIHandler) -> None: ...
def load_middleware(self) -> None: ...
def get_base_url(self) -> str: ... def get_base_url(self) -> str: ...
def file_path(self, url: str) -> str: ... def file_path(self, url: str) -> str: ...
def serve(self, request: WSGIRequest) -> Any: ... def serve(self, request: WSGIRequest) -> Any: ...
def get_response(self, request: WSGIRequest) -> Any: ...
def __call__(self, environ: Any, start_response: Any): ...

View File

@@ -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.files.storage import FileSystemStorage
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand
class Command(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 = ... copied_files: Any = ...
symlinked_files: Any = ... symlinked_files: Any = ...
unmodified_files: Any = ... unmodified_files: Any = ...
post_processed_files: Any = ... post_processed_files: Any = ...
storage: Any = ... storage: Any = ...
style: django.core.management.color.Style = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def local(self) -> bool: ... def local(self) -> bool: ...
def add_arguments(self, parser: CommandParser) -> None: ...
interactive: Any = ... interactive: Any = ...
verbosity: Any = ... verbosity: Any = ...
symlink: Any = ... symlink: Any = ...
@@ -26,7 +20,6 @@ class Command(BaseCommand):
post_process: Any = ... post_process: Any = ...
def set_options(self, **options: Any) -> None: ... def set_options(self, **options: Any) -> None: ...
def collect(self) -> Dict[str, List[str]]: ... def collect(self) -> Dict[str, List[str]]: ...
def handle(self, **options: Any) -> Optional[str]: ...
def log(self, msg: str, level: int = ...) -> None: ... def log(self, msg: str, level: int = ...) -> None: ...
def is_local_storage(self) -> bool: ... def is_local_storage(self) -> bool: ...
def clear_dir(self, path: str) -> None: ... def clear_dir(self, path: str) -> None: ...

View File

@@ -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): ...
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: ...

View File

@@ -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 class Command(RunserverCommand): ...
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: ...

View File

@@ -20,7 +20,6 @@ class HashedFilesMixin:
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def file_hash(self, name: str, content: File = ...) -> str: ... def file_hash(self, name: str, content: File = ...) -> str: ...
def hashed_name(self, name: str, content: Optional[File] = ..., filename: Optional[str] = ...) -> 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 url_converter(self, name: str, hashed_files: OrderedDict, template: str = ...) -> Callable: ...
def post_process( def post_process(
self, paths: OrderedDict, dry_run: bool = ..., **options: Any self, paths: OrderedDict, dry_run: bool = ..., **options: Any
@@ -33,16 +32,13 @@ class ManifestFilesMixin(HashedFilesMixin):
manifest_version: str = ... manifest_version: str = ...
manifest_name: str = ... manifest_name: str = ...
manifest_strict: bool = ... manifest_strict: bool = ...
hashed_files: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def read_manifest(self) -> Any: ... def read_manifest(self) -> Any: ...
def load_manifest(self) -> OrderedDict: ... def load_manifest(self) -> OrderedDict: ...
def post_process(self, *args: Any, **kwargs: Any) -> None: ...
def save_manifest(self) -> None: ... def save_manifest(self) -> None: ...
def stored_name(self, name: str) -> str: ...
class _MappingCache: class _MappingCache:
cache: django.core.cache.DefaultCacheProxy = ... cache: Any = ...
def __init__(self, cache: Any) -> None: ... def __init__(self, cache: Any) -> None: ...
def __setitem__(self, key: Any, value: Any) -> None: ... def __setitem__(self, key: Any, value: Any) -> None: ...
def __getitem__(self, key: Any): ... def __getitem__(self, key: Any): ...
@@ -51,9 +47,7 @@ class _MappingCache:
def get(self, key: Any, default: Optional[Any] = ...): ... def get(self, key: Any, default: Optional[Any] = ...): ...
class CachedFilesMixin(HashedFilesMixin): class CachedFilesMixin(HashedFilesMixin):
hashed_files: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def hash_key(self, name: str) -> str: ...
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): ... class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): ...
class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ... class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ...

View File

@@ -1,5 +1,4 @@
from collections import OrderedDict from typing import Any, Callable, Dict, Iterable, List, Optional, Union
from typing import Any, Callable, Dict, List, Optional, Union
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
@@ -9,7 +8,7 @@ class CacheKeyWarning(RuntimeWarning): ...
DEFAULT_TIMEOUT: Any DEFAULT_TIMEOUT: Any
MEMCACHE_MAX_KEY_LENGTH: int 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: ... def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ...
class BaseCache: class BaseCache:
@@ -17,9 +16,9 @@ class BaseCache:
key_prefix: str = ... key_prefix: str = ...
version: int = ... version: int = ...
key_func: Callable = ... 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 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 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 get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... 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 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_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ...
def get_or_set( def get_or_set(
self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ... self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
) -> Optional[Union[int, str]]: ... ) -> Optional[Any]: ...
def has_key(self, key: Any, version: Optional[Any] = ...): ... def has_key(self, key: Any, version: Optional[Any] = ...): ...
def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
def decr(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 __contains__(self, key: str) -> bool: ...
def set_many( def set_many(self, data: Dict[str, Any], timeout: Any = ..., version: Optional[Any] = ...) -> List[Any]: ...
self, def delete_many(self, keys: Iterable[Any], version: Optional[Any] = ...) -> None: ...
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 clear(self) -> None: ... def clear(self) -> None: ...
def validate_key(self, key: str) -> None: ... def validate_key(self, key: str) -> None: ...
def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...

View File

@@ -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 from django.core.cache.backends.base import BaseCache
@@ -16,24 +16,7 @@ class Options:
def __init__(self, table: str) -> None: ... def __init__(self, table: str) -> None: ...
class BaseDatabaseCache(BaseCache): class BaseDatabaseCache(BaseCache):
default_timeout: int
key_func: Callable
key_prefix: str
version: int
cache_model_class: Any = ... 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): 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: ...

View File

@@ -1,19 +1,6 @@
from typing import Any, Dict, Optional, Union, Callable from typing import Any
from django.core.cache.backends.base import BaseCache from django.core.cache.backends.base import BaseCache
class DummyCache(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 __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: ...

View File

@@ -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 from django.core.cache.backends.base import BaseCache
class FileBasedCache(BaseCache): class FileBasedCache(BaseCache):
default_timeout: int
key_func: Callable
key_prefix: str
version: int
cache_suffix: str = ... cache_suffix: str = ...
def __init__(self, dir: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ... def __init__(self, dir: str, params: Dict[str, Any]) -> 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: ...

View File

@@ -1,17 +1,15 @@
from ctypes import Structure, c_int64, c_ulong, c_void_p from ctypes import Structure, Union
from io import BufferedRandom, TextIOWrapper from typing import Any
from typing import Union
LOCK_SH: int LOCK_SH: int
LOCK_NB: int LOCK_NB: int
LOCK_EX: int LOCK_EX: int
ULONG_PTR = c_int64 ULONG_PTR: Any = ...
ULONG_PTR = c_ulong PVOID: Any = ...
PVOID = c_void_p
class _OFFSET(Structure): ... class _OFFSET(Structure): ...
class _OFFSET_UNION(Union): ... class _OFFSET_UNION(Union): ...
class OVERLAPPED(Structure): ... class OVERLAPPED(Structure): ...
def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ... def lock(f: Any, flags: int) -> bool: ...
def unlock(f: Union[BufferedRandom, int]) -> bool: ... def unlock(f: Any) -> bool: ...

View File

@@ -1,6 +1,5 @@
from typing import Any, List, Optional, Tuple from typing import Any, List, Optional, Tuple
from .backends.base import BaseEmailBackend
from .message import ( from .message import (
BadHeaderError as BadHeaderError, BadHeaderError as BadHeaderError,
DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE, 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 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( def send_mail(
subject: str, subject: str,
message: str, message: str,
@@ -21,7 +20,7 @@ def send_mail(
fail_silently: bool = ..., fail_silently: bool = ...,
auth_user: Optional[str] = ..., auth_user: Optional[str] = ...,
auth_password: Optional[str] = ..., auth_password: Optional[str] = ...,
connection: Optional[BaseEmailBackend] = ..., connection: Optional[Any] = ...,
html_message: Optional[str] = ..., html_message: Optional[str] = ...,
) -> int: ... ) -> int: ...
def send_mass_mail( def send_mass_mail(
@@ -29,20 +28,20 @@ def send_mass_mail(
fail_silently: bool = ..., fail_silently: bool = ...,
auth_user: Optional[str] = ..., auth_user: Optional[str] = ...,
auth_password: Optional[str] = ..., auth_password: Optional[str] = ...,
connection: Optional[BaseEmailBackend] = ..., connection: Optional[Any] = ...,
) -> int: ... ) -> int: ...
def mail_admins( def mail_admins(
subject: str, subject: str,
message: str, message: str,
fail_silently: bool = ..., fail_silently: bool = ...,
connection: Optional[BaseEmailBackend] = ..., connection: Optional[Any] = ...,
html_message: Optional[str] = ..., html_message: Optional[str] = ...,
) -> None: ... ) -> None: ...
def mail_managers( def mail_managers(
subject: str, subject: str,
message: str, message: str,
fail_silently: bool = ..., fail_silently: bool = ...,
connection: Optional[BaseEmailBackend] = ..., connection: Optional[Any] = ...,
html_message: Optional[str] = ..., html_message: Optional[str] = ...,
) -> None: ... ) -> None: ...

View File

@@ -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.message import MIMEMessage
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText from email.mime.text import MIMEText
from typing import Any, Dict, List, Optional, Tuple, Union, Sequence from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
from django.core.mail.backends.base import BaseEmailBackend
from django.utils.safestring import SafeText
utf8_charset: Any utf8_charset: Any
utf8_charset_qp: 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 split_addr(addr: str, encoding: str) -> Tuple[str, str]: ...
def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ... def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ...
class MIMEMixin: class MIMEMixin: ...
def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ...
def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ...
class SafeMIMEMessage(MIMEMixin, MIMEMessage): class SafeMIMEMessage(MIMEMixin, MIMEMessage):
defects: List[Any] defects: List[Any]
epilogue: None epilogue: None
policy: Policy policy: Policy
preamble: None preamble: None
def __setitem__(self, name: str, val: str) -> None: ...
class SafeMIMEText(MIMEMixin, MIMEText): class SafeMIMEText(MIMEMixin, MIMEText):
defects: List[Any] defects: List[Any]
@@ -38,8 +32,6 @@ class SafeMIMEText(MIMEMixin, MIMEText):
preamble: None preamble: None
encoding: str = ... encoding: str = ...
def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ... 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): class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
defects: List[Any] defects: List[Any]
@@ -50,7 +42,6 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
def __init__( def __init__(
self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any
) -> None: ... ) -> None: ...
def __setitem__(self, name: str, val: str) -> None: ...
class EmailMessage: class EmailMessage:
content_subtype: str = ... content_subtype: str = ...
@@ -65,7 +56,7 @@ class EmailMessage:
body: str = ... body: str = ...
attachments: List[Any] = ... attachments: List[Any] = ...
extra_headers: Dict[Any, Any] = ... extra_headers: Dict[Any, Any] = ...
connection: None = ... connection: Any = ...
def __init__( def __init__(
self, self,
subject: str = ..., subject: str = ...,
@@ -73,13 +64,13 @@ class EmailMessage:
from_email: Optional[str] = ..., from_email: Optional[str] = ...,
to: Optional[Union[Sequence[str], str]] = ..., to: Optional[Union[Sequence[str], str]] = ...,
bcc: 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]]] = ..., attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ...,
headers: Optional[Dict[str, str]] = ..., headers: Optional[Dict[str, str]] = ...,
cc: Optional[Union[Sequence[str], str]] = ..., cc: Optional[Union[Sequence[str], str]] = ...,
reply_to: Optional[Union[List[Optional[str]], str]] = ..., reply_to: Optional[Union[List[Optional[str]], str]] = ...,
) -> None: ... ) -> None: ...
def get_connection(self, fail_silently: bool = ...) -> BaseEmailBackend: ... def get_connection(self, fail_silently: bool = ...) -> Any: ...
def message(self) -> MIMEMixin: ... def message(self) -> MIMEMixin: ...
def recipients(self) -> List[str]: ... def recipients(self) -> List[str]: ...
def send(self, fail_silently: bool = ...) -> int: ... def send(self, fail_silently: bool = ...) -> int: ...
@@ -92,16 +83,6 @@ class EmailMessage:
def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ... def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ...
class EmailMultiAlternatives(EmailMessage): 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 = ... alternative_subtype: str = ...
alternatives: Any = ... alternatives: Any = ...
def __init__( def __init__(
@@ -111,7 +92,7 @@ class EmailMultiAlternatives(EmailMessage):
from_email: Optional[str] = ..., from_email: Optional[str] = ...,
to: Optional[List[str]] = ..., to: Optional[List[str]] = ...,
bcc: Optional[List[str]] = ..., bcc: Optional[List[str]] = ...,
connection: Optional[BaseEmailBackend] = ..., connection: Optional[Any] = ...,
attachments: None = ..., attachments: None = ...,
headers: Optional[Dict[str, str]] = ..., headers: Optional[Dict[str, str]] = ...,
alternatives: Optional[List[Tuple[str, str]]] = ..., alternatives: Optional[List[Tuple[str, str]]] = ...,

View File

@@ -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): class TemplateCommand(BaseCommand):
requires_system_checks: bool = ...
url_schemes: Any = ... url_schemes: Any = ...
rewrite_template_suffixes: Any = ... rewrite_template_suffixes: Any = ...
def add_arguments(self, parser: CommandParser) -> None: ...
app_or_project: Any = ... app_or_project: Any = ...
paths_to_remove: Any = ... paths_to_remove: Any = ...
verbosity: 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 handle_template(self, template: Any, subdir: Any): ...
def validate_name(self, name: Any, app_or_project: Any) -> None: ... def validate_name(self, name: Any, app_or_project: Any) -> None: ...
def download(self, url: Any): ... def download(self, url: Any): ...

View File

@@ -1,5 +1,4 @@
from collections import OrderedDict from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, Iterable
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
from django.apps.config import AppConfig from django.apps.config import AppConfig
from django.db.models.base import Model from django.db.models.base import Model
@@ -33,5 +32,5 @@ def serialize(
) -> Optional[Union[bytes, str]]: ... ) -> Optional[Union[bytes, str]]: ...
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ... def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
def sort_dependencies( def sort_dependencies(
app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]] app_list: Union[Iterable[Tuple[AppConfig, None]], Iterable[Tuple[str, Iterable[Type[Model]]]]]
) -> List[Type[Model]]: ... ) -> List[Type[Model]]: ...

View File

@@ -1,7 +1,7 @@
from datetime import datetime from datetime import datetime
from decimal import Decimal from decimal import Decimal
from re import RegexFlag from re import RegexFlag
from typing import Any, Dict, List, Optional, Union, Pattern from typing import Any, Dict, List, Optional, Union, Pattern, Collection
from uuid import UUID from uuid import UUID
from django.core.files.base import File from django.core.files.base import File
@@ -38,7 +38,7 @@ class URLValidator(RegexValidator):
tld_re: Any = ... tld_re: Any = ...
host_re: Any = ... host_re: Any = ...
schemes: Any = ... schemes: Any = ...
def __init__(self, schemes: Optional[List[str]] = ..., **kwargs: Any) -> None: ... def __init__(self, schemes: Optional[Collection[str]] = ..., **kwargs: Any) -> None: ...
integer_validator: Any integer_validator: Any
@@ -52,7 +52,7 @@ class EmailValidator:
literal_regex: Any = ... literal_regex: Any = ...
domain_whitelist: Any = ... domain_whitelist: Any = ...
def __init__( def __init__(
self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[List[str]] = ... self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[Collection[str]] = ...
) -> None: ... ) -> None: ...
def __call__(self, value: Optional[str]) -> None: ... def __call__(self, value: Optional[str]) -> None: ...
def validate_domain_part(self, domain_part: str) -> bool: ... def validate_domain_part(self, domain_part: str) -> bool: ...
@@ -119,7 +119,10 @@ class FileExtensionValidator:
code: str = ... code: str = ...
allowed_extensions: List[str] = ... allowed_extensions: List[str] = ...
def __init__( def __init__(
self, allowed_extensions: Optional[List[str]] = ..., message: Optional[str] = ..., code: Optional[str] = ... self,
allowed_extensions: Optional[Collection[str]] = ...,
message: Optional[str] = ...,
code: Optional[str] = ...,
) -> None: ... ) -> None: ...
def __call__(self, value: File) -> None: ... def __call__(self, value: File) -> None: ...

View File

@@ -1,9 +1,16 @@
from typing import Any, Callable, Dict, Iterator, List, Optional 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.utils import CursorDebugWrapper, CursorWrapper
from django.db.backends.base.schema import BaseDatabaseSchemaEditor 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 NO_DB_ALIAS: str
class BaseDatabaseWrapper: class BaseDatabaseWrapper:
@@ -23,7 +30,7 @@ class BaseDatabaseWrapper:
queries_limit: int = ... queries_limit: int = ...
connection: Any = ... connection: Any = ...
settings_dict: Any = ... settings_dict: Any = ...
alias: Any = ... alias: str = ...
queries_log: Any = ... queries_log: Any = ...
force_debug_cursor: bool = ... force_debug_cursor: bool = ...
autocommit: bool = ... autocommit: bool = ...
@@ -32,18 +39,18 @@ class BaseDatabaseWrapper:
savepoint_ids: Any = ... savepoint_ids: Any = ...
commit_on_exit: bool = ... commit_on_exit: bool = ...
needs_rollback: bool = ... needs_rollback: bool = ...
close_at: Any = ... close_at: Optional[Any] = ...
closed_in_transaction: bool = ... closed_in_transaction: bool = ...
errors_occurred: bool = ... errors_occurred: bool = ...
allow_thread_sharing: Any = ... allow_thread_sharing: bool = ...
run_on_commit: Any = ... run_on_commit: List[Any] = ...
run_commit_hooks_on_set_autocommit_on: bool = ... run_commit_hooks_on_set_autocommit_on: bool = ...
execute_wrappers: Any = ... execute_wrappers: List[Any] = ...
client: Any = ... client: BaseDatabaseClient = ...
creation: Any = ... creation: BaseDatabaseCreation = ...
features: Any = ... features: BaseDatabaseFeatures = ...
introspection: Any = ... introspection: BaseDatabaseIntrospection = ...
validation: Any = ... validation: BaseDatabaseValidation = ...
def __init__( def __init__(
self, settings_dict: Dict[str, Dict[str, str]], alias: str = ..., allow_thread_sharing: bool = ... self, settings_dict: Dict[str, Dict[str, str]], alias: str = ..., allow_thread_sharing: bool = ...
) -> None: ... ) -> None: ...

View File

@@ -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.backends.ddl_references import Statement
from django.db.models.base import Model 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.indexes import Index
from django.db.models.fields import Field
logger: Any logger: Any
class BaseDatabaseSchemaEditor: class BaseDatabaseSchemaEditor(ContextManager[Any]):
sql_create_table: str = ... sql_create_table: str = ...
sql_rename_table: str = ... sql_rename_table: str = ...
sql_retablespace_table: str = ... sql_retablespace_table: str = ...
@@ -27,7 +28,7 @@ class BaseDatabaseSchemaEditor:
sql_create_unique: str = ... sql_create_unique: str = ...
sql_delete_unique: str = ... sql_delete_unique: str = ...
sql_create_fk: str = ... sql_create_fk: str = ...
sql_create_inline_fk: Any = ... sql_create_inline_fk: str = ...
sql_delete_fk: str = ... sql_delete_fk: str = ...
sql_create_index: str = ... sql_create_index: str = ...
sql_delete_index: str = ... sql_delete_index: str = ...
@@ -35,14 +36,14 @@ class BaseDatabaseSchemaEditor:
sql_delete_pk: str = ... sql_delete_pk: str = ...
sql_delete_procedure: str = ... sql_delete_procedure: str = ...
connection: Any = ... connection: Any = ...
collect_sql: Any = ... collect_sql: bool = ...
collected_sql: Any = ... collected_sql: Any = ...
atomic_migration: Any = ... atomic_migration: Any = ...
def __init__(self, connection: Any, collect_sql: bool = ..., atomic: bool = ...) -> None: ... def __init__(self, connection: Any, collect_sql: bool = ..., atomic: bool = ...) -> None: ...
deferred_sql: Any = ... deferred_sql: Any = ...
atomic: Any = ... atomic: Any = ...
def __enter__(self) -> BaseDatabaseSchemaEditor: ... 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 execute(self, sql: Union[Statement, str], params: Optional[Union[List[int], Tuple]] = ...) -> None: ...
def quote_name(self, name: str) -> str: ... def quote_name(self, name: str) -> str: ...
def column_sql( def column_sql(
@@ -59,14 +60,14 @@ class BaseDatabaseSchemaEditor:
def alter_unique_together( def alter_unique_together(
self, self,
model: Type[Model], model: Type[Model],
old_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]], old_unique_together: Sequence[Sequence[str]],
new_unique_together: Union[List[List[str]], Tuple[Tuple[str, str]]], new_unique_together: Sequence[Sequence[str]],
) -> None: ... ) -> None: ...
def alter_index_together( def alter_index_together(
self, self,
model: Type[Model], model: Type[Model],
old_index_together: Union[List[List[str]], List[Tuple[str, str]]], old_index_together: Sequence[Sequence[str]],
new_index_together: Union[List[List[str]], List[Tuple[str, str]]], new_index_together: Sequence[Sequence[str]],
) -> None: ... ) -> None: ...
def alter_db_table(self, model: Type[Model], old_db_table: str, new_db_table: 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: ... def alter_db_tablespace(self, model: Any, old_db_tablespace: Any, new_db_tablespace: Any) -> None: ...

View File

@@ -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.base import BaseDatabaseWrapper
from django.db.backends.base.client import BaseDatabaseClient 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: ... def ignore(*args: Any, **kwargs: Any) -> None: ...
class DatabaseOperations(BaseDatabaseOperations): class DatabaseOperations(BaseDatabaseOperations):
connection: django.db.backends.dummy.base.DatabaseWrapper
quote_name: Any = ... quote_name: Any = ...
class DatabaseClient(BaseDatabaseClient): class DatabaseClient(BaseDatabaseClient):
connection: django.db.backends.dummy.base.DatabaseWrapper
runshell: Any = ... runshell: Any = ...
class DatabaseCreation(BaseDatabaseCreation): class DatabaseCreation(BaseDatabaseCreation):
connection: django.db.backends.dummy.base.DatabaseWrapper
create_test_db: Any = ... create_test_db: Any = ...
destroy_test_db: Any = ... destroy_test_db: Any = ...
class DatabaseIntrospection(BaseDatabaseIntrospection): class DatabaseIntrospection(BaseDatabaseIntrospection):
connection: django.db.backends.dummy.base.DatabaseWrapper
get_table_list: Any = ... get_table_list: Any = ...
get_table_description: Any = ... get_table_description: Any = ...
get_relations: Any = ... get_relations: Any = ...
@@ -31,35 +27,5 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
get_key_columns: Any = ... get_key_columns: Any = ...
class DatabaseWrapper(BaseDatabaseWrapper): 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 = ... operators: Any = ...
ensure_connection: Any = ... ensure_connection: Any = ...
client_class: Any = ...
creation_class: Any = ...
features_class: Any = ...
introspection_class: Any = ...
ops_class: Any = ...
def is_usable(self): ...

View File

@@ -1,25 +1,3 @@
from typing import Any, Optional, Type, Union
from django.db.backends.base.schema import BaseDatabaseSchemaEditor 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): 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: ...

View File

@@ -1,11 +1,8 @@
from typing import Any, Dict, Optional, Sequence, Set, Tuple, Union 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
from django.db.migrations.migration import Migration, SwappableTuple
from django.db.migrations.state import ProjectState from django.db.migrations.state import ProjectState
from django.db import DefaultConnectionProxy
MIGRATIONS_MODULE_NAME: str MIGRATIONS_MODULE_NAME: str
class MigrationLoader: class MigrationLoader:
@@ -13,12 +10,7 @@ class MigrationLoader:
disk_migrations: Dict[Tuple[str, str], Migration] = ... disk_migrations: Dict[Tuple[str, str], Migration] = ...
applied_migrations: None = ... applied_migrations: None = ...
ignore_no_migrations: bool = ... ignore_no_migrations: bool = ...
def __init__( def __init__(self, connection: Any, load: bool = ..., ignore_no_migrations: bool = ...) -> None: ...
self,
connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]],
load: bool = ...,
ignore_no_migrations: bool = ...,
) -> None: ...
@classmethod @classmethod
def migrations_module(cls, app_label: str) -> Tuple[Optional[str], bool]: ... def migrations_module(cls, app_label: str) -> Tuple[Optional[str], bool]: ...
unmigrated_apps: Set[str] = ... unmigrated_apps: Set[str] = ...
@@ -26,7 +18,7 @@ class MigrationLoader:
def load_disk(self) -> None: ... def load_disk(self) -> None: ...
def get_migration(self, app_label: str, name_prefix: str) -> Migration: ... 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 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_internal_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ...
def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ... def add_external_dependencies(self, key: Tuple[str, str], migration: Migration) -> None: ...
graph: Any = ... graph: Any = ...
@@ -35,5 +27,5 @@ class MigrationLoader:
def check_consistent_history(self, connection: Any) -> None: ... def check_consistent_history(self, connection: Any) -> None: ...
def detect_conflicts(self) -> Dict[str, Set[str]]: ... def detect_conflicts(self) -> Dict[str, Set[str]]: ...
def project_state( 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: ... ) -> ProjectState: ...

View File

@@ -21,7 +21,7 @@ class Migration:
self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ... self, project_state: ProjectState, schema_editor: BaseDatabaseSchemaEditor, collect_sql: bool = ...
) -> ProjectState: ... ) -> ProjectState: ...
class SwappableTuple(tuple): class SwappableTuple(Tuple[str, str]):
setting: str = ... setting: str = ...
def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ... def __new__(cls, value: Tuple[str, str], setting: str) -> SwappableTuple: ...

View File

@@ -8,6 +8,7 @@ _Self = TypeVar("_Self", bound="Model")
class Model(metaclass=ModelBase): class Model(metaclass=ModelBase):
class DoesNotExist(Exception): ... class DoesNotExist(Exception): ...
class MultipleObjectsReturned(Exception): ...
class Meta: ... class Meta: ...
_meta: Any _meta: Any
_default_manager: Manager[Model] _default_manager: Manager[Model]
@@ -15,6 +16,7 @@ class Model(metaclass=ModelBase):
def __init__(self: _Self, *args, **kwargs) -> None: ... def __init__(self: _Self, *args, **kwargs) -> None: ...
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ... def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
def full_clean(self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...) -> None: ... def full_clean(self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...) -> None: ...
def clean(self) -> None: ...
def clean_fields(self, exclude: List[str] = ...) -> None: ... def clean_fields(self, exclude: List[str] = ...) -> None: ...
def validate_unique(self, exclude: List[str] = ...) -> None: ... def validate_unique(self, exclude: List[str] = ...) -> None: ...
def save( def save(
@@ -34,6 +36,7 @@ class Model(metaclass=ModelBase):
): ... ): ...
def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> _Self: ... def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> _Self: ...
def get_deferred_fields(self) -> Set[str]: ... def get_deferred_fields(self) -> Set[str]: ...
def __getstate__(self) -> dict: ...
class ModelStateFieldsCacheDescriptor: ... class ModelStateFieldsCacheDescriptor: ...

View File

@@ -1,20 +1,18 @@
from collections import OrderedDict
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union, TypeVar from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
from django.db.models.lookups import Lookup from django.db.models.lookups import Lookup
from django.db.models.sql.compiler import SQLCompiler from django.db.models.sql.compiler import SQLCompiler
from django.db.models import Q, QuerySet from django.db.models import Q, QuerySet
from django.db.models.fields import Field, FloatField from django.db.models.fields import Field
from django.db.models.sql import Query
_OutputField = Union[Field, str] _OutputField = Union[Field, str]
class SQLiteNumericMixin: class SQLiteNumericMixin:
def as_sqlite(self, compiler: SQLCompiler, connection: Any, **extra_context: Any) -> Tuple[str, List[float]]: ... def as_sqlite(self, compiler: SQLCompiler, connection: Any, **extra_context: Any) -> Tuple[str, List[float]]: ...
_SelfCombinable = TypeVar("_SelfCombinable", bound="Combinable") _Self = TypeVar("_Self")
class Combinable: class Combinable:
ADD: str = ... ADD: str = ...
@@ -27,22 +25,20 @@ class Combinable:
BITOR: str = ... BITOR: str = ...
BITLEFTSHIFT: str = ... BITLEFTSHIFT: str = ...
BITRIGHTSHIFT: str = ... BITRIGHTSHIFT: str = ...
def __neg__(self: _SelfCombinable) -> _SelfCombinable: ... def __neg__(self: _Self) -> _Self: ...
def __add__( def __add__(self: _Self, other: Optional[Union[timedelta, Combinable, float, str]]) -> _Self: ...
self: _SelfCombinable, other: Optional[Union[timedelta, Combinable, float, str]] def __sub__(self: _Self, other: Union[timedelta, Combinable, float]) -> _Self: ...
) -> _SelfCombinable: ... def __mul__(self: _Self, other: Union[timedelta, Combinable, float]) -> _Self: ...
def __sub__(self: _SelfCombinable, other: Union[timedelta, Combinable, float]) -> _SelfCombinable: ... def __truediv__(self: _Self, other: Union[Combinable, float]) -> _Self: ...
def __mul__(self: _SelfCombinable, other: Union[timedelta, Combinable, float]) -> _SelfCombinable: ... def __itruediv__(self: _Self, other: Union[Combinable, float]) -> _Self: ...
def __truediv__(self: _SelfCombinable, other: Union[Combinable, float]) -> _SelfCombinable: ... def __mod__(self: _Self, other: Union[int, Combinable]) -> _Self: ...
def __itruediv__(self: _SelfCombinable, other: Union[Combinable, float]) -> _SelfCombinable: ... def __pow__(self: _Self, other: Union[float, Combinable]) -> _Self: ...
def __mod__(self: _SelfCombinable, other: Union[int, Combinable]) -> _SelfCombinable: ... def __and__(self: _Self, other: Combinable) -> _Self: ...
def __pow__(self: _SelfCombinable, other: Union[float, Combinable]) -> _SelfCombinable: ... def bitand(self: _Self, other: int) -> _Self: ...
def __and__(self: _SelfCombinable, other: Combinable) -> _SelfCombinable: ... def bitleftshift(self: _Self, other: int) -> _Self: ...
def bitand(self: _SelfCombinable, other: int) -> _SelfCombinable: ... def bitrightshift(self: _Self, other: int) -> _Self: ...
def bitleftshift(self: _SelfCombinable, other: int) -> _SelfCombinable: ... def __or__(self: _Self, other: Combinable) -> _Self: ...
def bitrightshift(self: _SelfCombinable, other: int) -> _SelfCombinable: ... def bitor(self: _Self, other: int) -> _Self: ...
def __or__(self: _SelfCombinable, other: Combinable) -> _SelfCombinable: ...
def bitor(self: _SelfCombinable, other: int) -> _SelfCombinable: ...
def __radd__(self, other: Optional[Union[datetime, float, Combinable]]) -> Combinable: ... def __radd__(self, other: Optional[Union[datetime, float, Combinable]]) -> Combinable: ...
def __rsub__(self, other: Union[float, Combinable]) -> Combinable: ... def __rsub__(self, other: Union[float, Combinable]) -> Combinable: ...
def __rmul__(self, other: Union[float, Combinable]) -> Combinable: ... def __rmul__(self, other: Union[float, Combinable]) -> Combinable: ...
@@ -52,43 +48,45 @@ class Combinable:
def __rand__(self, other: Any) -> Combinable: ... def __rand__(self, other: Any) -> Combinable: ...
def __ror__(self, other: Any) -> Combinable: ... def __ror__(self, other: Any) -> Combinable: ...
_SelfBaseExpression = TypeVar("_SelfBaseExpression", bound="BaseExpression")
class BaseExpression: class BaseExpression:
is_summary: bool = ... is_summary: bool = ...
filterable: bool = ... filterable: bool = ...
window_compatible: bool = ... window_compatible: bool = ...
output_field: Any
def __init__(self, output_field: Optional[_OutputField] = ...) -> None: ... def __init__(self, output_field: Optional[_OutputField] = ...) -> None: ...
def get_db_converters(self, connection: Any) -> List[Callable]: ... def get_db_converters(self, connection: Any) -> List[Callable]: ...
def get_source_expressions(self) -> List[Any]: ... def get_source_expressions(self) -> List[Any]: ...
def set_source_expressions(self, exprs: List[Any]) -> None: ... def set_source_expressions(self, exprs: Sequence[Combinable]) -> None: ...
@property
def contains_aggregate(self) -> bool: ... def contains_aggregate(self) -> bool: ...
@property
def contains_over_clause(self) -> bool: ... def contains_over_clause(self) -> bool: ...
@property
def contains_column_references(self) -> bool: ... def contains_column_references(self) -> bool: ...
def resolve_expression( def resolve_expression(
self, self: _Self,
query: Any = ..., query: Any = ...,
allow_joins: bool = ..., allow_joins: bool = ...,
reuse: Optional[Set[str]] = ..., reuse: Optional[Set[str]] = ...,
summarize: bool = ..., summarize: bool = ...,
for_save: bool = ..., for_save: bool = ...,
) -> BaseExpression: ... ) -> _Self: ...
@property @property
def field(self) -> Field: ... def field(self) -> Field: ...
@property @property
def output_field(self) -> Field: ... def output_field(self) -> Field: ...
@property
def convert_value(self) -> Callable: ... def convert_value(self) -> Callable: ...
def get_lookup(self, lookup: str) -> Optional[Type[Lookup]]: ... def get_lookup(self, lookup: str) -> Optional[Type[Lookup]]: ...
def get_transform(self, name: str) -> Optional[Type[Expression]]: ... def get_transform(self, name: str) -> Optional[Type[Expression]]: ...
def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> Expression: ... def relabeled_clone(self, change_map: Dict[Optional[str], str]) -> Expression: ...
def copy(self) -> BaseExpression: ... def copy(self) -> BaseExpression: ...
def get_group_by_cols(self: _SelfBaseExpression) -> List[_SelfBaseExpression]: ... def get_group_by_cols(self: _Self) -> List[_Self]: ...
def get_source_fields(self) -> List[Optional[Field]]: ... def get_source_fields(self) -> List[Optional[Field]]: ...
def asc(self, **kwargs: Any) -> Expression: ... def asc(self, **kwargs: Any) -> Expression: ...
def desc(self, **kwargs: Any) -> Expression: ... def desc(self, **kwargs: Any) -> Expression: ...
def reverse_ordering(self): ... def reverse_ordering(self): ...
def flatten(self) -> Iterator[Expression]: ... def flatten(self) -> Iterator[Expression]: ...
def __hash__(self) -> int: ...
def deconstruct(self) -> Any: ... def deconstruct(self) -> Any: ...
def as_sqlite(self, compiler: SQLCompiler, connection: Any) -> Any: ... def as_sqlite(self, compiler: SQLCompiler, connection: Any) -> Any: ...
def as_sql(self, compiler: SQLCompiler, connection: Any, **extra_context: Any) -> Any: ... def as_sql(self, compiler: SQLCompiler, connection: Any, **extra_context: Any) -> Any: ...
@@ -105,28 +103,18 @@ class CombinedExpression(SQLiteNumericMixin, Expression):
def __init__( def __init__(
self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Optional[_OutputField] = ... self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Optional[_OutputField] = ...
) -> None: ... ) -> None: ...
def get_source_expressions(self) -> Union[List[Combinable], List[SQLiteNumericMixin]]: ...
def set_source_expressions(self, exprs: List[Combinable]) -> None: ...
def resolve_expression(
self,
query: Any = ...,
allow_joins: bool = ...,
reuse: Optional[Set[str]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> CombinedExpression: ...
class F(Combinable): class F(Combinable):
name: str name: str
def __init__(self, name: str): ... def __init__(self, name: str): ...
def resolve_expression( def resolve_expression(
self, self: _Self,
query: Any = ..., query: Any = ...,
allow_joins: bool = ..., allow_joins: bool = ...,
reuse: Optional[Set[str]] = ..., reuse: Optional[Set[str]] = ...,
summarize: bool = ..., summarize: bool = ...,
for_save: bool = ..., for_save: bool = ...,
) -> Expression: ... ) -> _Self: ...
def asc(self, **kwargs) -> OrderBy: ... def asc(self, **kwargs) -> OrderBy: ...
def desc(self, **kwargs) -> OrderBy: ... def desc(self, **kwargs) -> OrderBy: ...
def deconstruct(self) -> Any: ... def deconstruct(self) -> Any: ...
@@ -141,8 +129,6 @@ class Subquery(Expression):
def __init__(self, queryset: QuerySet, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ... def __init__(self, queryset: QuerySet, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ...
class Exists(Subquery): class Exists(Subquery):
extra: Dict[Any, Any]
template: str = ...
negated: bool = ... negated: bool = ...
def __init__(self, *args: Any, negated: bool = ..., **kwargs: Any) -> None: ... def __init__(self, *args: Any, negated: bool = ..., **kwargs: Any) -> None: ...
def __invert__(self) -> Exists: ... def __invert__(self) -> Exists: ...
@@ -162,30 +148,19 @@ class Value(Expression):
def __init__(self, value: Any, output_field: Optional[_OutputField] = ...) -> None: ... def __init__(self, value: Any, output_field: Optional[_OutputField] = ...) -> None: ...
class RawSQL(Expression): class RawSQL(Expression):
output_field: Field
params: List[Any] params: List[Any]
sql: str sql: str
def __init__(self, sql: str, params: Sequence[Any], output_field: Optional[_OutputField] = ...) -> None: ... def __init__(self, sql: str, params: Sequence[Any], output_field: Optional[_OutputField] = ...) -> None: ...
class Func(SQLiteNumericMixin, Expression): class Func(SQLiteNumericMixin, Expression):
function: str = ... function: str = ...
name: str = ...
template: str = ... template: str = ...
arg_joiner: str = ... arg_joiner: str = ...
arity: int = ... arity: int = ...
source_expressions: List[Expression] = ... source_expressions: List[Combinable] = ...
extra: Dict[Any, Any] = ... extra: Dict[Any, Any] = ...
def __init__(self, *expressions: Any, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ... def __init__(self, *expressions: Any, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ...
def get_source_expressions(self) -> List[Combinable]: ...
def set_source_expressions(self, exprs: List[Expression]) -> None: ...
def resolve_expression(
self,
query: Query = ...,
allow_joins: bool = ...,
reuse: Optional[Set[Any]] = ...,
summarize: bool = ...,
for_save: bool = ...,
) -> Func: ...
def copy(self) -> Func: ...
class When(Expression): class When(Expression):
template: str = ... template: str = ...
@@ -205,8 +180,6 @@ class Case(Expression):
class ExpressionWrapper(Expression): class ExpressionWrapper(Expression):
def __init__(self, expression: Union[Q, Combinable], output_field: _OutputField): ... def __init__(self, expression: Union[Q, Combinable], output_field: _OutputField): ...
def set_source_expressions(self, exprs: Sequence[Expression]) -> None: ...
def get_source_expressions(self) -> List[Expression]: ...
class Col(Expression): class Col(Expression):
def __init__(self, alias: str, target: str, output_field: Optional[_OutputField] = ...): ... def __init__(self, alias: str, target: str, output_field: Optional[_OutputField] = ...): ...
@@ -214,8 +187,7 @@ class Col(Expression):
class ExpressionList(Func): class ExpressionList(Func):
def __init__(self, *expressions: Union[BaseExpression, Combinable], **extra: Any) -> None: ... def __init__(self, *expressions: Union[BaseExpression, Combinable], **extra: Any) -> None: ...
class Random(Expression): class Random(Expression): ...
output_field: FloatField
class Ref(Expression): class Ref(Expression):
def __init__(self, refs: str, source: Expression): ... def __init__(self, refs: str, source: Expression): ...

View File

@@ -1,51 +1,11 @@
from datetime import date from typing import Any, Union
from decimal import Decimal
from typing import Any, Callable, Dict, List, Union
from django.db.models.expressions import Combinable, Expression
from django.db.models import Func from django.db.models import Func
from django.db.models.fields import Field from django.db.models.fields import Field
class Cast(Func): class Cast(Func):
contains_aggregate: bool def __init__(self, expression: Any, output_field: Union[str, Field]) -> None: ...
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: Field
source_expressions: List[Combinable]
function: str = ...
template: str = ...
def __init__(self, expression: Union[date, Decimal, Expression, str], output_field: Union[str, Field]) -> None: ...
class Coalesce(Func): class Coalesce(Func): ...
contains_aggregate: bool class Greatest(Func): ...
convert_value: Callable class Least(Func): ...
extra: Dict[Any, Any]
is_summary: bool
output_field: Field
source_expressions: List[Combinable]
function: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
class Greatest(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: Field
source_expressions: List[Combinable]
function: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
class Least(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
extra: Dict[Any, Any]
is_summary: bool
output_field: Field
source_expressions: List[Combinable]
function: str = ...
def __init__(self, *expressions: Any, **extra: Any) -> None: ...

View File

@@ -1,105 +1,47 @@
from typing import Any, List, Optional, Tuple, Union, Callable from typing import Any, List, Optional, Tuple, Union
from django.db.backends.sqlite3.base import DatabaseWrapper from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.expressions import Combinable, Expression, Value from django.db.models.expressions import Combinable, Expression, Value
from django.db.models.sql.compiler import SQLCompiler from django.db.models.sql.compiler import SQLCompiler
from django.db.models import Func, Transform from django.db.models import Func, Transform
from django.db.models.fields import Field
class BytesToCharFieldConversionMixin: class BytesToCharFieldConversionMixin: ...
def convert_value( class Chr(Transform): ...
self, value: str, expression: BytesToCharFieldConversionMixin, connection: DatabaseWrapper
) -> str: ...
class Chr(Transform):
contains_aggregate: bool
lookup_name: str = ...
class ConcatPair(Func): class ConcatPair(Func):
contains_aggregate: bool
def coalesce(self) -> ConcatPair: ... def coalesce(self) -> ConcatPair: ...
class Concat(Func): class Concat(Func): ...
contains_aggregate: bool
convert_value: Callable
class Left(Func): class Left(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
output_field: Field
def __init__(self, expression: str, length: Union[Value, int], **extra: Any) -> None: ... def __init__(self, expression: str, length: Union[Value, int], **extra: Any) -> None: ...
def get_substr(self) -> Substr: ... def get_substr(self) -> Substr: ...
def use_substr( def use_substr(
self, compiler: SQLCompiler, connection: DatabaseWrapper, **extra_context: Any self, compiler: SQLCompiler, connection: DatabaseWrapper, **extra_context: Any
) -> Tuple[str, List[int]]: ... ) -> Tuple[str, List[int]]: ...
as_oracle: Any = ...
as_sqlite: Any = ...
class Length(Transform): class Length(Transform): ...
contains_aggregate: bool class Lower(Transform): ...
convert_value: Callable
lookup_name: str = ...
class Lower(Transform):
contains_aggregate: bool
contains_column_references: bool
contains_over_clause: bool
convert_value: Callable
lookup_name: str = ...
class LPad(BytesToCharFieldConversionMixin, Func): class LPad(BytesToCharFieldConversionMixin, Func):
contains_aggregate: bool
convert_value: Callable
def __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ... def __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ...
class LTrim(Transform): class LTrim(Transform): ...
contains_aggregate: bool class Ord(Transform): ...
convert_value: Callable
lookup_name: str = ...
class Ord(Transform):
contains_aggregate: bool
convert_value: Callable
lookup_name: str = ...
def as_mysql(self, compiler: Any, connection: Any, **extra_context: Any): ...
class Repeat(BytesToCharFieldConversionMixin, Func): class Repeat(BytesToCharFieldConversionMixin, Func):
contains_aggregate: bool
convert_value: Callable
output_field: django.db.models.fields.CharField
def __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ... def __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ...
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
class Replace(Func): class Replace(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
output_field: Field
def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ... def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ...
class Right(Left): ... class Right(Left): ...
class RPad(LPad): ...
class RPad(LPad): class RTrim(Transform): ...
output_field: Field class StrIndex(Func): ...
class RTrim(Transform):
contains_aggregate: bool
convert_value: Callable
lookup_name: str = ...
class StrIndex(Func):
contains_aggregate: bool
convert_value: Callable
output_field: Any = ...
def as_postgresql(self, compiler: Any, connection: Any): ...
class Substr(Func): class Substr(Func):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
output_field: Field
def __init__( def __init__(
self, self,
expression: Union[Expression, str], expression: Union[Expression, str],
@@ -108,13 +50,5 @@ class Substr(Func):
**extra: Any **extra: Any
) -> None: ... ) -> None: ...
class Trim(Transform): class Trim(Transform): ...
contains_aggregate: bool class Upper(Transform): ...
convert_value: Callable
lookup_name: str = ...
class Upper(Transform):
contains_aggregate: bool
contains_over_clause: bool
convert_value: Callable
lookup_name: str = ...

View File

@@ -1,69 +1,26 @@
from typing import Any, Optional, Dict, List from typing import Any, Optional
from django.db.models import Func from django.db.models import Func
class CumeDist(Func): class CumeDist(Func): ...
function: str = ... class DenseRank(Func): ...
name: str = ... class FirstValue(Func): ...
output_field: Any = ...
window_compatible: bool = ...
class DenseRank(Func):
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class FirstValue(Func):
name: str = ...
window_compatible: bool = ...
class LagLeadFunction(Func): class LagLeadFunction(Func):
window_compatible: bool = ...
def __init__( def __init__(
self, expression: Optional[str], offset: int = ..., default: Optional[int] = ..., **extra: Any self, expression: Optional[str], offset: int = ..., default: Optional[int] = ..., **extra: Any
) -> None: ... ) -> None: ...
class Lag(LagLeadFunction): class Lag(LagLeadFunction): ...
function: str = ... class LastValue(Func): ...
name: str = ... class Lead(LagLeadFunction): ...
class LastValue(Func):
arity: int = ...
function: str = ...
name: str = ...
window_compatible: bool = ...
class Lead(LagLeadFunction):
function: str = ...
name: str = ...
class NthValue(Func): class NthValue(Func):
function: str = ... def __init__(self, expression: Optional[str], nth: int = ..., **extra: Any) -> None: ...
name: str = ...
window_compatible: bool = ...
def __init__(self, expression: Optional[str], nth: int = ..., **extra: Any) -> Any: ...
class Ntile(Func): class Ntile(Func):
function: str = ... def __init__(self, num_buckets: int = ..., **extra: Any) -> None: ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
def __init__(self, num_buckets: int = ..., **extra: Any) -> Any: ...
class PercentRank(Func): class PercentRank(Func): ...
function: str = ... class Rank(Func): ...
name: str = ... class RowNumber(Func): ...
output_field: Any = ...
window_compatible: bool = ...
class Rank(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class RowNumber(Func):
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...

View File

@@ -5,7 +5,7 @@ from django.db.models.query import QuerySet
_T = TypeVar("_T", bound=Model, covariant=True) _T = TypeVar("_T", bound=Model, covariant=True)
class BaseManager(QuerySet[_T]): class BaseManager(QuerySet[_T, _T]):
creation_counter: int = ... creation_counter: int = ...
auto_created: bool = ... auto_created: bool = ...
use_in_migrations: bool = ... use_in_migrations: bool = ...
@@ -21,7 +21,7 @@ class BaseManager(QuerySet[_T]):
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ... def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
def contribute_to_class(self, model: Type[Model], name: str) -> None: ... def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ... def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ...
def get_queryset(self) -> QuerySet[_T]: ... def get_queryset(self) -> QuerySet[_T, _T]: ...
class Manager(BaseManager[_T]): ... class Manager(BaseManager[_T]): ...

View File

@@ -1,3 +1,4 @@
import datetime
from typing import ( from typing import (
Any, Any,
Dict, Dict,
@@ -13,12 +14,14 @@ from typing import (
TypeVar, TypeVar,
Union, Union,
overload, overload,
Generic,
NamedTuple,
Collection,
) )
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.expressions import Combinable as Combinable, F as F from django.db.models.expressions import Combinable as Combinable, F as F
from django.db.models.sql.query import Query, RawQuery from django.db.models.sql.query import Query, RawQuery
from typing_extensions import Literal
from django.db import models from django.db import models
from django.db.models import Manager from django.db.models import Manager
@@ -46,7 +49,7 @@ class FlatValuesListIterable(BaseIterable):
_T = TypeVar("_T", bound=models.Model, covariant=True) _T = TypeVar("_T", bound=models.Model, covariant=True)
class QuerySet(Iterable[_T], Sized): class QuerySet(Generic[_T, _Row], Collection[_Row], Sized):
query: Query query: Query
def __init__( def __init__(
self, self,
@@ -58,32 +61,33 @@ class QuerySet(Iterable[_T], Sized):
@classmethod @classmethod
def as_manager(cls) -> Manager[Any]: ... def as_manager(cls) -> Manager[Any]: ...
def __len__(self) -> int: ... def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ... def __iter__(self) -> Iterator[_Row]: ...
def __contains__(self, x: object) -> bool: ...
@overload
def __getitem__(self, i: int) -> _Row: ...
@overload
def __getitem__(self, s: slice) -> QuerySet[_T, _Row]: ...
def __bool__(self) -> bool: ... def __bool__(self) -> bool: ...
def __class_getitem__(cls, item: Type[_T]): def __class_getitem__(cls, item: Type[_T]):
pass pass
def __getstate__(self) -> Dict[str, Any]: ... def __getstate__(self) -> Dict[str, Any]: ...
@overload # __and__ and __or__ ignore the other QuerySet's _Row type parameter because they use the same row type as the self QuerySet.
def __getitem__(self, k: int) -> _T: ... # Technically, the other QuerySet must be of the same type _T, but _T is covariant
@overload def __and__(self, other: QuerySet[_T, Any]) -> QuerySet[_T, _Row]: ...
def __getitem__(self, k: str) -> Any: ... def __or__(self, other: QuerySet[_T, Any]) -> QuerySet[_T, _Row]: ...
@overload def iterator(self, chunk_size: int = ...) -> Iterator[_Row]: ...
def __getitem__(self, k: slice) -> QuerySet[_T]: ...
def __and__(self, other: QuerySet) -> QuerySet: ...
def __or__(self, other: QuerySet) -> QuerySet: ...
def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ... def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
def get(self, *args: Any, **kwargs: Any) -> _T: ... def get(self, *args: Any, **kwargs: Any) -> _Row: ...
def create(self, **kwargs: Any) -> _T: ... def create(self, **kwargs: Any) -> _T: ...
def bulk_create(self, objs: Iterable[Model], batch_size: Optional[int] = ...) -> List[_T]: ... def bulk_create(self, objs: Iterable[Model], batch_size: Optional[int] = ...) -> List[_T]: ...
def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ... def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ...
def update_or_create( def update_or_create(
self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any
) -> Tuple[_T, bool]: ... ) -> Tuple[_T, bool]: ...
def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ...
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ... def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ...
def first(self) -> Optional[_T]: ... def first(self) -> Optional[_Row]: ...
def last(self) -> Optional[_T]: ... def last(self) -> Optional[_Row]: ...
def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ... def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ...
def delete(self) -> Tuple[int, Dict[str, int]]: ... def delete(self) -> Tuple[int, Dict[str, int]]: ...
def update(self, **kwargs: Any) -> int: ... def update(self, **kwargs: Any) -> int: ...
@@ -93,31 +97,31 @@ class QuerySet(Iterable[_T], Sized):
def raw( def raw(
self, raw_query: str, params: Any = ..., translations: Optional[Dict[str, str]] = ..., using: None = ... self, raw_query: str, params: Any = ..., translations: Optional[Dict[str, str]] = ..., using: None = ...
) -> RawQuerySet: ... ) -> RawQuerySet: ...
def values(self, *fields: Union[str, Combinable], **expressions: Any) -> QuerySet: ... # The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param
def values_list(self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ...) -> QuerySet: ... def values(self, *fields: Union[str, Combinable], **expressions: Any) -> QuerySet[_T, Dict[str, Any]]: ...
# @overload # The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param
# def values_list(self, *fields: Union[str, Combinable], named: Literal[True]) -> NamedValuesListIterable: ... def values_list(
# @overload self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ...
# def values_list(self, *fields: Union[str, Combinable], flat: Literal[True]) -> FlatValuesListIterable: ... ) -> QuerySet[_T, Any]: ...
# @overload def dates(self, field_name: str, kind: str, order: str = ...) -> QuerySet[_T, datetime.date]: ...
# def values_list(self, *fields: Union[str, Combinable]) -> ValuesListIterable: ... def datetimes(
def dates(self, field_name: str, kind: str, order: str = ...) -> QuerySet: ... self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...
def datetimes(self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...) -> QuerySet: ... ) -> QuerySet[_T, datetime.datetime]: ...
def none(self) -> QuerySet[_T]: ... def none(self) -> QuerySet[_T, _Row]: ...
def all(self) -> QuerySet[_T]: ... def all(self) -> QuerySet[_T, _Row]: ...
def filter(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ... def filter(self, *args: Any, **kwargs: Any) -> QuerySet[_T, _Row]: ...
def exclude(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ... def exclude(self, *args: Any, **kwargs: Any) -> QuerySet[_T, _Row]: ...
def complex_filter(self, filter_obj: Any) -> QuerySet[_T]: ... def complex_filter(self, filter_obj: Any) -> QuerySet[_T, _Row]: ...
def count(self) -> int: ... def count(self) -> int: ...
def union(self, *other_qs: Any, all: bool = ...) -> QuerySet[_T]: ... def union(self, *other_qs: Any, all: bool = ...) -> QuerySet[_T, _Row]: ...
def intersection(self, *other_qs: Any) -> QuerySet[_T]: ... def intersection(self, *other_qs: Any) -> QuerySet[_T, _Row]: ...
def difference(self, *other_qs: Any) -> QuerySet[_T]: ... def difference(self, *other_qs: Any) -> QuerySet[_T, _Row]: ...
def select_for_update(self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...) -> QuerySet: ... def select_for_update(self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...) -> QuerySet[_T, _Row]: ...
def select_related(self, *fields: Any) -> QuerySet[_T]: ... def select_related(self, *fields: Any) -> QuerySet[_T, _Row]: ...
def prefetch_related(self, *lookups: Any) -> QuerySet[_T]: ... def prefetch_related(self, *lookups: Any) -> QuerySet[_T, _Row]: ...
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[_T]: ... def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[_T, _Row]: ...
def order_by(self, *field_names: Any) -> QuerySet[_T]: ... def order_by(self, *field_names: Any) -> QuerySet[_T, _Row]: ...
def distinct(self, *field_names: Any) -> QuerySet[_T]: ... def distinct(self, *field_names: Any) -> QuerySet[_T, _Row]: ...
def extra( def extra(
self, self,
select: Optional[Dict[str, Any]] = ..., select: Optional[Dict[str, Any]] = ...,
@@ -126,11 +130,11 @@ class QuerySet(Iterable[_T], Sized):
tables: Optional[List[str]] = ..., tables: Optional[List[str]] = ...,
order_by: Optional[Sequence[str]] = ..., order_by: Optional[Sequence[str]] = ...,
select_params: Optional[Sequence[Any]] = ..., select_params: Optional[Sequence[Any]] = ...,
) -> QuerySet[_T]: ... ) -> QuerySet[_T, _Row]: ...
def reverse(self) -> QuerySet[_T]: ... def reverse(self) -> QuerySet[_T, _Row]: ...
def defer(self, *fields: Any) -> QuerySet[_T]: ... def defer(self, *fields: Any) -> QuerySet[_T, _Row]: ...
def only(self, *fields: Any) -> QuerySet[_T]: ... def only(self, *fields: Any) -> QuerySet[_T, _Row]: ...
def using(self, alias: Optional[str]) -> QuerySet[_T]: ... def using(self, alias: Optional[str]) -> QuerySet[_T, _Row]: ...
@property @property
def ordered(self) -> bool: ... def ordered(self) -> bool: ...
@property @property
@@ -159,7 +163,7 @@ class RawQuerySet(Iterable[_T], Sized):
@overload @overload
def __getitem__(self, k: str) -> Any: ... def __getitem__(self, k: str) -> Any: ...
@overload @overload
def __getitem__(self, k: slice) -> QuerySet[_T]: ... def __getitem__(self, k: slice) -> RawQuerySet[_T]: ...
@property @property
def columns(self) -> List[str]: ... def columns(self) -> List[str]: ...
@property @property

View File

@@ -6,6 +6,18 @@ from .models import (
ModelForm as ModelForm, ModelForm as ModelForm,
ModelChoiceField as ModelChoiceField, ModelChoiceField as ModelChoiceField,
ModelMultipleChoiceField as ModelMultipleChoiceField, ModelMultipleChoiceField as ModelMultipleChoiceField,
model_to_dict as model_to_dict,
BaseModelForm as BaseModelForm,
BaseInlineFormSet as BaseInlineFormSet,
BaseModelFormSet as BaseModelFormSet,
fields_for_model as fields_for_model,
inlineformset_factory as inlineformset_factory,
modelform_factory as modelform_factory,
InlineForeignKeyField as InlineForeignKeyField,
ModelChoiceIterator as ModelChoiceIterator,
ModelFormMetaclass as ModelFormMetaclass,
ModelFormOptions as ModelFormOptions,
modelformset_factory as modelformset_factory,
) )
from .widgets import ( from .widgets import (
@@ -68,3 +80,5 @@ from .fields import (
TypedChoiceField as TypedChoiceField, TypedChoiceField as TypedChoiceField,
TypedMultipleChoiceField as TypedMultipleChoiceField, TypedMultipleChoiceField as TypedMultipleChoiceField,
) )
from .boundfield import BoundField as BoundField, BoundWidget as BoundWidget

View File

@@ -21,7 +21,7 @@ class BaseForm:
is_bound: bool = ... is_bound: bool = ...
data: Dict[str, Any] = ... data: Dict[str, Any] = ...
files: Optional[Dict[str, Any]] = ... files: Optional[Dict[str, Any]] = ...
auto_id: Any = ... auto_id: str = ...
initial: Dict[str, Any] = ... initial: Dict[str, Any] = ...
error_class: Type[ErrorList] = ... error_class: Type[ErrorList] = ...
prefix: str = ... prefix: str = ...
@@ -59,7 +59,7 @@ class BaseForm:
def add_error(self, field: Optional[str], error: Union[ValidationError, str]) -> None: ... def add_error(self, field: Optional[str], error: Union[ValidationError, str]) -> None: ...
def has_error(self, field: Any, code: Optional[Any] = ...): ... def has_error(self, field: Any, code: Optional[Any] = ...): ...
def full_clean(self) -> None: ... 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 has_changed(self) -> bool: ...
def changed_data(self) -> List[str]: ... def changed_data(self) -> List[str]: ...
@property @property

View File

@@ -1,12 +1,9 @@
from collections import OrderedDict from datetime import datetime
from datetime import date, datetime from typing import Any, Callable, Dict, Iterator, List, Mapping, MutableMapping, Optional, Sequence, Tuple, Type, Union
from typing import Any, Callable, Dict, Iterator, List, MutableMapping, Optional, Sequence, Tuple, Type, Union, Mapping
from unittest.mock import MagicMock from unittest.mock import MagicMock
from uuid import UUID from uuid import UUID
from django.core.files.base import File 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.base import Model
from django.db.models.manager import Manager from django.db.models.manager import Manager
from django.db.models.query import QuerySet 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 django.forms.widgets import Input, Widget
from typing_extensions import Literal from typing_extensions import Literal
from django.db import models
from django.db.models import ForeignKey
ALL_FIELDS: str ALL_FIELDS: str
_Fields = Union[List[Union[Callable, str]], Sequence[str], Literal["__all__"]] _Fields = Union[List[Union[Callable, str]], Sequence[str], Literal["__all__"]]

View File

@@ -1,15 +1,12 @@
from datetime import time
from decimal import Decimal from decimal import Decimal
from itertools import chain 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.core.files.base import File
from django.db.models.fields.files import FieldFile
from django.forms.renderers import EngineMixin from django.forms.renderers import EngineMixin
from django.utils.datastructures import MultiValueDict
from django.utils.safestring import SafeText from django.utils.safestring import SafeText
_OptAttrs = Dict[str, str] _OptAttrs = Dict[str, Any]
class MediaOrderConflictWarning(RuntimeWarning): ... class MediaOrderConflictWarning(RuntimeWarning): ...
@@ -38,31 +35,21 @@ class Widget:
is_localized: bool = ... is_localized: bool = ...
is_required: bool = ... is_required: bool = ...
supports_microseconds: bool = ... supports_microseconds: bool = ...
attrs: Dict[str, Any] = ... attrs: _OptAttrs = ...
def __init__(self, attrs: Optional[Dict[str, Any]] = ...) -> None: ... def __init__(self, attrs: Optional[_OptAttrs] = ...) -> None: ...
@property @property
def is_hidden(self) -> bool: ... def is_hidden(self) -> bool: ...
def subwidgets( def subwidgets(self, name: str, value: Optional[List[str]], attrs: _OptAttrs = ...) -> Iterator[Dict[str, Any]]: ...
self, name: str, value: Optional[List[str]], attrs: Dict[str, bool] = ...
) -> Iterator[Dict[str, Any]]: ...
def format_value(self, value: Any) -> Optional[str]: ... 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( def render(
self, self, name: str, value: Any, attrs: Optional[_OptAttrs] = ..., renderer: Optional[EngineMixin] = ...
name: str,
value: Any,
attrs: Optional[Dict[str, Union[bool, str]]] = ...,
renderer: Optional[EngineMixin] = ...,
) -> SafeText: ... ) -> SafeText: ...
def build_attrs( 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]]: ... ) -> Dict[str, Union[Decimal, float, str]]: ...
def value_from_datadict( def value_from_datadict(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> Any: ...
self, data: dict, files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str def value_omitted_from_data(self, data: Dict[str, Any], files: Mapping[str, Iterable[Any]], name: str) -> bool: ...
) -> Any: ...
def value_omitted_from_data(
self, data: Dict[str, Any], files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str
) -> bool: ...
def id_for_label(self, id_: str) -> str: ... def id_for_label(self, id_: str) -> str: ...
def use_required_attribute(self, initial: Any) -> bool: ... 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_name(self, name: str) -> str: ...
def clear_checkbox_id(self, name: str) -> str: ... def clear_checkbox_id(self, name: str) -> str: ...
def is_initial(self, value: Optional[Union[File, str]]) -> bool: ... def is_initial(self, value: Optional[Union[File, str]]) -> bool: ...
def use_required_attribute(self, initial: Optional[Union[FieldFile, str]]) -> bool: ...
class Textarea(Widget): class Textarea(Widget):
template_name: str = ... template_name: str = ...
class DateTimeBaseInput(TextInput): class DateTimeBaseInput(TextInput):
format_key: str = ... format_key: str = ...
supports_microseconds: bool = ...
format: Optional[str] = ... format: Optional[str] = ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...): ... def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...): ...
@@ -128,7 +113,7 @@ class ChoiceWidget(Widget):
def create_option( def create_option(
self, self,
name: str, name: str,
value: Union[time, int, str], value: Any,
label: Union[int, str], label: Union[int, str],
selected: Union[Set[str], bool], selected: Union[Set[str], bool],
index: int, index: int,
@@ -137,13 +122,7 @@ class ChoiceWidget(Widget):
) -> Dict[str, Any]: ... ) -> Dict[str, Any]: ...
def id_for_label(self, id_: str, index: str = ...) -> str: ... def id_for_label(self, id_: str, index: str = ...) -> str: ...
class Select(ChoiceWidget): 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 NullBooleanSelect(Select): ... class NullBooleanSelect(Select): ...
class SelectMultiple(Select): class SelectMultiple(Select):
@@ -154,40 +133,26 @@ class RadioSelect(ChoiceWidget):
option_template_name: str = ... option_template_name: str = ...
class CheckboxSelectMultiple(ChoiceWidget): 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: ... def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ...
class MultiWidget(Widget): class MultiWidget(Widget):
template_name: str = ... template_name: str = ...
widgets: List[Widget] = ... widgets: List[Widget] = ...
def __init__(self, widgets: Sequence[Union[Widget, Type[Widget]]], attrs: Optional[_OptAttrs] = ...) -> None: ... 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]: ... def decompress(self, value: Any) -> Optional[Any]: ...
media: Any = ... media: Any = ...
class SplitDateTimeWidget(MultiWidget): class SplitDateTimeWidget(MultiWidget):
supports_microseconds: bool = ...
def __init__( def __init__(
self, self,
attrs: Optional[Dict[str, str]] = ..., attrs: Optional[_OptAttrs] = ...,
date_format: Optional[str] = ..., date_format: Optional[str] = ...,
time_format: Optional[str] = ..., time_format: Optional[str] = ...,
date_attrs: Optional[Dict[str, str]] = ..., date_attrs: Optional[Dict[str, str]] = ...,
time_attrs: Optional[Dict[str, str]] = ..., time_attrs: Optional[Dict[str, str]] = ...,
) -> None: ... ) -> None: ...
class SplitHiddenDateTimeWidget(SplitDateTimeWidget): 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 SelectDateWidget(Widget): class SelectDateWidget(Widget):
none_value: Any = ... none_value: Any = ...

View File

@@ -31,6 +31,6 @@ def redirect(
_T = TypeVar("_T", bound=Model) _T = TypeVar("_T", bound=Model)
def get_object_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T]], *args: Any, **kwargs: Any) -> _T: ... def get_object_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T, _T]], *args: Any, **kwargs: Any) -> _T: ...
def get_list_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T]], *args: Any, **kwargs: Any) -> List[_T]: ... def get_list_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T, _T]], *args: Any, **kwargs: Any) -> List[_T]: ...
def resolve_url(to: Union[Callable, Model, str], *args: Any, **kwargs: Any) -> str: ... def resolve_url(to: Union[Callable, Model, str], *args: Any, **kwargs: Any) -> str: ...

View File

@@ -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 from django.template.base import Template
class BaseEngine: class BaseEngine:
name: Any = ... name: str = ...
dirs: Any = ... dirs: List[str] = ...
app_dirs: Any = ... app_dirs: bool = ...
def __init__(self, params: Dict[str, Union[List[str], bool, str]]) -> None: ... 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 @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 template_dirs(self) -> Tuple[str]: ...
def iter_template_filenames(self, template_name: str) -> Iterator[str]: ... def iter_template_filenames(self, template_name: str) -> Iterator[str]: ...

View File

@@ -1,20 +1,13 @@
from typing import Any, Dict, Iterator, Optional, List from typing import Any, Dict, Iterator, Optional
from django.template.base import Template as Template
from django.template.exceptions import TemplateDoesNotExist
from django.template.engine import Engine from django.template.engine import Engine
from django.template.exceptions import TemplateDoesNotExist
from .base import BaseEngine from .base import BaseEngine
class DjangoTemplates(BaseEngine): class DjangoTemplates(BaseEngine):
app_dirs: bool
dirs: List[str]
name: str
app_dirname: str = ...
engine: Engine = ... engine: Engine = ...
def __init__(self, params: Dict[str, Any]) -> None: ... 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 get_templatetag_libraries(self, custom_libraries: Dict[str, str]) -> Dict[str, str]: ...
def copy_exception(exc: TemplateDoesNotExist, backend: Optional[DjangoTemplates] = ...) -> TemplateDoesNotExist: ... def copy_exception(exc: TemplateDoesNotExist, backend: Optional[DjangoTemplates] = ...) -> TemplateDoesNotExist: ...

View File

@@ -1,19 +1,13 @@
import string 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 django.http.request import HttpRequest
from .base import BaseEngine from .base import BaseEngine
class TemplateStrings(BaseEngine): class TemplateStrings(BaseEngine):
app_dirs: bool
dirs: List[Any]
name: str
template_dirs: Tuple[str] template_dirs: Tuple[str]
app_dirname: str = ...
def __init__(self, params: Dict[str, Union[Dict[Any, Any], List[Any], bool, str]]) -> None: ... 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): class Template(string.Template):
template: str template: str

View File

@@ -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 django.template.exceptions import TemplateSyntaxError
from .base import BaseEngine from .base import BaseEngine
class Jinja2(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] = ... context_processors: List[str] = ...
def __init__(self, params: Dict[str, Any]) -> None: ... def __init__(self, params: Dict[str, Any]) -> None: ...
def from_string(self, template_code: str) -> Template: ... @property
def get_template(self, template_name: str) -> Template: ... def template_context_processors(self) -> List[Callable]: ...
class Origin: class Origin:
name: str = ... name: str = ...

View File

@@ -1,5 +1,5 @@
from enum import Enum 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.http.request import HttpRequest
from django.template.context import Context as Context from django.template.context import Context as Context
@@ -126,12 +126,12 @@ filter_re: Any
class FilterExpression: class FilterExpression:
token: str = ... token: str = ...
filters: List[Tuple[Callable, List[Tuple[bool, Union[Variable, SafeText]]]]] = ... filters: List[Any] = ...
var: Union[Variable, SafeText] = ... var: Any = ...
def __init__(self, token: str, parser: Parser) -> None: ... 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 @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: class Variable:
var: Union[Dict[Any, Any], str] = ... var: Union[Dict[Any, Any], str] = ...
@@ -152,27 +152,21 @@ class Node:
def __iter__(self) -> None: ... def __iter__(self) -> None: ...
def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ...
class NodeList(list): class NodeList(List[Node]):
contains_nontext: bool = ... contains_nontext: bool = ...
def render(self, context: Context) -> SafeText: ... def render(self, context: Context) -> SafeText: ...
def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ... def get_nodes_by_type(self, nodetype: Type[Node]) -> List[Node]: ...
class TextNode(Node): class TextNode(Node):
origin: Origin
token: Token
s: str = ... s: str = ...
def __init__(self, s: str) -> None: ... def __init__(self, s: str) -> None: ...
def render(self, context: Context) -> str: ...
def render_value_in_context(value: Any, context: Context) -> str: ... def render_value_in_context(value: Any, context: Context) -> str: ...
class VariableNode(Node): class VariableNode(Node):
origin: Origin
token: Token
filter_expression: FilterExpression = ... filter_expression: FilterExpression = ...
def __init__(self, filter_expression: FilterExpression) -> None: ... def __init__(self, filter_expression: FilterExpression) -> None: ...
def render(self, context: Context) -> str: ...
kwarg_re: Any 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]: ...

View File

@@ -1,10 +1,3 @@
from typing import Optional, Tuple
from django.template import Engine
from .filesystem import Loader as FilesystemLoader from .filesystem import Loader as FilesystemLoader
class Loader(FilesystemLoader): class Loader(FilesystemLoader): ...
dirs: None
engine: Engine
def get_dirs(self) -> Tuple: ...

View File

@@ -4,9 +4,9 @@ from django.template.base import Origin, Template
from django.template.engine import Engine from django.template.engine import Engine
class Loader: class Loader:
engine: Any = ... engine: Engine = ...
get_template_cache: Dict[str, Any] = ... get_template_cache: Dict[str, Any] = ...
def __init__(self, engine: Engine) -> None: ... def __init__(self, engine: Engine) -> None: ...
def get_template(self, template_name: str, skip: Optional[List[Origin]] = ...) -> Template: ... 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: ... def reset(self) -> None: ...

View File

@@ -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 django.template.engine import Engine
from .base import Loader as BaseLoader from .base import Loader as BaseLoader
class Loader(BaseLoader): class Loader(BaseLoader):
engine: Engine template_cache: Dict[str, Any] = ...
template_cache: Dict[Any, Any] = ... loaders: List[BaseLoader] = ...
get_template_cache: Dict[str, django.template.exceptions.TemplateDoesNotExist] = ... def __init__(self, engine: Engine, loaders: Sequence[Any]) -> None: ...
loaders: List[django.template.loaders.base.Loader] = ...
def __init__(self, engine: Engine, loaders: Union[List[Tuple[str, Dict[str, str]]], List[str]]) -> None: ...
def get_contents(self, origin: Origin) -> str: ... 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 cache_key(self, template_name: str, skip: Optional[List[Origin]] = ...) -> str: ...
def generate_hash(self, values: List[str]) -> str: ... def generate_hash(self, values: List[str]) -> str: ...
def reset(self) -> None: ...

View File

@@ -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.base import Origin
from django.template.engine import Engine from django.template.engine import Engine
@@ -6,9 +6,7 @@ from django.template.engine import Engine
from .base import Loader as BaseLoader from .base import Loader as BaseLoader
class Loader(BaseLoader): class Loader(BaseLoader):
engine: Engine
dirs: Optional[List[str]] = ... dirs: Optional[List[str]] = ...
def __init__(self, engine: Engine, dirs: Optional[List[str]] = ...) -> None: ... def __init__(self, engine: Engine, dirs: Optional[List[str]] = ...) -> None: ...
def get_dirs(self) -> Union[List[bytes], List[str]]: ... def get_dirs(self) -> Union[List[bytes], List[str]]: ...
def get_contents(self, origin: Origin) -> Any: ... def get_contents(self, origin: Origin) -> Any: ...
def get_template_sources(self, template_name: Union[bytes, str]) -> Iterator[Origin]: ...

View File

@@ -1,4 +1,4 @@
from typing import Dict, Iterator from typing import Dict
from django.template.base import Origin from django.template.base import Origin
from django.template.engine import Engine from django.template.engine import Engine
@@ -6,8 +6,6 @@ from django.template.engine import Engine
from .base import Loader as BaseLoader from .base import Loader as BaseLoader
class Loader(BaseLoader): class Loader(BaseLoader):
engine: Engine
templates_dict: Dict[str, str] = ... templates_dict: Dict[str, str] = ...
def __init__(self, engine: Engine, templates_dict: Dict[str, str]) -> None: ... def __init__(self, engine: Engine, templates_dict: Dict[str, str]) -> None: ...
def get_contents(self, origin: Origin) -> str: ... def get_contents(self, origin: Origin) -> str: ...
def get_template_sources(self, template_name: str) -> Iterator[Origin]: ...

View File

@@ -1,15 +1,12 @@
from typing import Any, List, Optional from typing import Any, List, Optional
from django.template import Node
from django.template.base import FilterExpression, NodeList, Parser, Token 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 register: Any
class CacheNode(Node): class CacheNode(Node):
origin: Origin
token: Token
nodelist: NodeList = ... nodelist: NodeList = ...
expire_time_var: FilterExpression = ... expire_time_var: FilterExpression = ...
fragment_name: str = ... fragment_name: str = ...
@@ -23,6 +20,5 @@ class CacheNode(Node):
vary_on: List[FilterExpression], vary_on: List[FilterExpression],
cache_name: Optional[FilterExpression], cache_name: Optional[FilterExpression],
) -> None: ... ) -> None: ...
def render(self, context: Context) -> SafeText: ...
def do_cache(parser: Parser, token: Token) -> CacheNode: ... def do_cache(parser: Parser, token: Token) -> CacheNode: ...

View File

@@ -1,53 +1,35 @@
from typing import Any, Dict, List, Optional, Tuple 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.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 register: Any
class GetAvailableLanguagesNode(Node): class GetAvailableLanguagesNode(Node):
origin: Origin
token: Token
variable: str = ... variable: str = ...
def __init__(self, variable: str) -> None: ... def __init__(self, variable: str) -> None: ...
def render(self, context: Context) -> str: ...
class GetLanguageInfoNode(Node): class GetLanguageInfoNode(Node):
origin: Origin
token: Token
lang_code: FilterExpression = ... lang_code: FilterExpression = ...
variable: str = ... variable: str = ...
def __init__(self, lang_code: FilterExpression, variable: str) -> None: ... def __init__(self, lang_code: FilterExpression, variable: str) -> None: ...
def render(self, context: Context) -> str: ...
class GetLanguageInfoListNode(Node): class GetLanguageInfoListNode(Node):
origin: Origin
token: Token
languages: FilterExpression = ... languages: FilterExpression = ...
variable: str = ... variable: str = ...
def __init__(self, languages: FilterExpression, variable: str) -> None: ... def __init__(self, languages: FilterExpression, variable: str) -> None: ...
def get_language_info(self, language: Any): ... def get_language_info(self, language: Any): ...
def render(self, context: Context) -> str: ...
class GetCurrentLanguageNode(Node): class GetCurrentLanguageNode(Node):
origin: Origin
token: Token
variable: str = ... variable: str = ...
def __init__(self, variable: str) -> None: ... def __init__(self, variable: str) -> None: ...
def render(self, context: RequestContext) -> str: ...
class GetCurrentLanguageBidiNode(Node): class GetCurrentLanguageBidiNode(Node):
origin: Origin
token: Token
variable: str = ... variable: str = ...
def __init__(self, variable: str) -> None: ... def __init__(self, variable: str) -> None: ...
def render(self, context: RequestContext) -> str: ...
class TranslateNode(Node): class TranslateNode(Node):
origin: Origin
token: Token
noop: bool = ... noop: bool = ...
asvar: Optional[str] = ... asvar: Optional[str] = ...
message_context: Optional[FilterExpression] = ... message_context: Optional[FilterExpression] = ...
@@ -59,11 +41,8 @@ class TranslateNode(Node):
asvar: Optional[str] = ..., asvar: Optional[str] = ...,
message_context: Optional[FilterExpression] = ..., message_context: Optional[FilterExpression] = ...,
) -> None: ... ) -> None: ...
def render(self, context: Context) -> str: ...
class BlockTranslateNode(Node): class BlockTranslateNode(Node):
origin: Origin
token: Token
extra_context: Dict[str, FilterExpression] = ... extra_context: Dict[str, FilterExpression] = ...
singular: List[Token] = ... singular: List[Token] = ...
plural: List[Token] = ... plural: List[Token] = ...
@@ -84,15 +63,11 @@ class BlockTranslateNode(Node):
asvar: Optional[str] = ..., asvar: Optional[str] = ...,
) -> None: ... ) -> None: ...
def render_token_list(self, tokens: List[Token]) -> Tuple[str, List[str]]: ... def render_token_list(self, tokens: List[Token]) -> Tuple[str, List[str]]: ...
def render(self, context: Context, nested: bool = ...) -> str: ...
class LanguageNode(Node): class LanguageNode(Node):
origin: Origin
token: Token
nodelist: NodeList = ... nodelist: NodeList = ...
language: FilterExpression = ... language: FilterExpression = ...
def __init__(self, nodelist: NodeList, language: FilterExpression) -> None: ... 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_available_languages(parser: Parser, token: Token) -> GetAvailableLanguagesNode: ...
def do_get_language_info(parser: Parser, token: Token) -> GetLanguageInfoNode: ... def do_get_language_info(parser: Parser, token: Token) -> GetLanguageInfoNode: ...

View File

@@ -1,22 +1,17 @@
from datetime import date from typing import Any, List
from typing import Any, List, Optional, Union
from django.template.base import Parser, Token
from django.template import Node 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 register: Any
def localize(value: Union[date, float]) -> str: ... def localize(value: Any) -> str: ...
def unlocalize(value: Union[date, float]) -> str: ... def unlocalize(value: Any) -> str: ...
class LocalizeNode(Node): class LocalizeNode(Node):
origin: Origin nodelist: List[Node] = ...
token: Token
nodelist: Union[List[Any], NodeList] = ...
use_l10n: bool = ... use_l10n: bool = ...
def __init__(self, nodelist: Union[List[Any], NodeList], use_l10n: bool) -> None: ... def __init__(self, nodelist: List[Node], use_l10n: bool) -> None: ...
def render(self, context: Context) -> SafeText: ...
def localize_tag(parser: Parser, token: Token) -> LocalizeNode: ... def localize_tag(parser: Parser, token: Token) -> LocalizeNode: ...

View File

@@ -1,14 +1,13 @@
from typing import Any, Optional from typing import Any, Optional
from django import template
from django.template.base import FilterExpression, Parser, Token from django.template.base import FilterExpression, Parser, Token
from django.template.context import Context from django.template.context import Context
from django import template
register: Any register: Any
class PrefixNode(template.Node): class PrefixNode(template.Node):
origin: Origin
token: Token
varname: Optional[str] = ... varname: Optional[str] = ...
name: str = ... name: str = ...
def __init__(self, varname: Optional[str] = ..., name: str = ...) -> None: ... 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: ... def handle_token(cls, parser: Parser, token: Token, name: str) -> PrefixNode: ...
@classmethod @classmethod
def handle_simple(cls, name: str) -> str: ... def handle_simple(cls, name: str) -> str: ...
def render(self, context: Context) -> str: ...
def get_static_prefix(parser: Parser, token: Token) -> PrefixNode: ... def get_static_prefix(parser: Parser, token: Token) -> PrefixNode: ...
def get_media_prefix(parser: Parser, token: Token) -> PrefixNode: ... def get_media_prefix(parser: Parser, token: Token) -> PrefixNode: ...
class StaticNode(template.Node): class StaticNode(template.Node):
origin: Origin
token: Token
path: FilterExpression = ... path: FilterExpression = ...
varname: Optional[str] = ... varname: Optional[str] = ...
def __init__(self, varname: Optional[str] = ..., path: FilterExpression = ...) -> None: ... def __init__(self, varname: Optional[str] = ..., path: FilterExpression = ...) -> None: ...
def url(self, context: Context) -> str: ... def url(self, context: Context) -> str: ...
def render(self, context: Context) -> str: ...
@classmethod @classmethod
def handle_simple(cls, path: str) -> str: ... def handle_simple(cls, path: str) -> str: ...
@classmethod @classmethod

View File

@@ -1,44 +1,32 @@
from datetime import datetime from datetime import datetime
from typing import Any, Optional, Union from typing import Any, Optional, Union
from django.template import Node
from django.template.base import FilterExpression, NodeList, Parser, Token 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.utils.timezone import FixedOffset
from django.template import Node
register: Any register: Any
class datetimeobject(datetime): ... class datetimeobject(datetime): ...
def localtime(value: Optional[Union[datetime, str]]) -> Union[datetimeobject, str]: ... def localtime(value: Optional[Union[datetime, str]]) -> Any: ...
def utc(value: Optional[Union[datetime, str]]) -> Union[datetimeobject, str]: ... def utc(value: Optional[Union[datetime, str]]) -> Any: ...
def do_timezone( def do_timezone(value: Optional[Union[datetime, str]], arg: Optional[Union[FixedOffset, str]]) -> Any: ...
value: Optional[Union[datetime, str]], arg: Optional[Union[FixedOffset, str]]
) -> Union[datetimeobject, str]: ...
class LocalTimeNode(Node): class LocalTimeNode(Node):
origin: Origin
token: Token
nodelist: NodeList = ... nodelist: NodeList = ...
use_tz: bool = ... use_tz: bool = ...
def __init__(self, nodelist: NodeList, use_tz: bool) -> None: ... def __init__(self, nodelist: NodeList, use_tz: bool) -> None: ...
def render(self, context: Context) -> SafeText: ...
class TimezoneNode(Node): class TimezoneNode(Node):
origin: Origin
token: Token
nodelist: NodeList = ... nodelist: NodeList = ...
tz: FilterExpression = ... tz: FilterExpression = ...
def __init__(self, nodelist: NodeList, tz: FilterExpression) -> None: ... def __init__(self, nodelist: NodeList, tz: FilterExpression) -> None: ...
def render(self, context: Context) -> SafeText: ...
class GetCurrentTimezoneNode(Node): class GetCurrentTimezoneNode(Node):
origin: Origin
token: Token
variable: str = ... variable: str = ...
def __init__(self, variable: str) -> None: ... def __init__(self, variable: str) -> None: ...
def render(self, context: Context) -> str: ...
def localtime_tag(parser: Parser, token: Token) -> LocalTimeNode: ... def localtime_tag(parser: Parser, token: Token) -> LocalTimeNode: ...
def timezone_tag(parser: Parser, token: Token) -> TimezoneNode: ... def timezone_tag(parser: Parser, token: Token) -> TimezoneNode: ...

View File

@@ -31,15 +31,8 @@ class Parser(HTMLParser):
open_tags: Any = ... open_tags: Any = ...
element_positions: Any = ... element_positions: Any = ...
def __init__(self) -> None: ... def __init__(self) -> None: ...
def error(self, msg: str) -> Any: ... def format_position(self, position: Any = ..., element: Any = ...) -> str: ...
def format_position(self, position: None = ..., element: None = ...) -> str: ...
@property @property
def current(self) -> Element: ... 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: ... def parse_html(html: str) -> Element: ...

View File

@@ -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 ArchiveException(Exception): ...
class UnrecognizedArchiveFormat(ArchiveException): ... class UnrecognizedArchiveFormat(ArchiveException): ...
@@ -14,21 +14,17 @@ class Archive:
def close(self) -> None: ... def close(self) -> None: ...
class BaseArchive: class BaseArchive:
def split_leading_dir(self, path: str) -> Union[List[str], Tuple[str, str]]: ... def split_leading_dir(self, path: str) -> Sequence[str]: ...
def has_leading_dir(self, paths: Union[Iterator[Any], List[str]]) -> bool: ... def has_leading_dir(self, paths: Iterable[str]) -> bool: ...
def extract(self) -> None: ... def extract(self, to_path: str) -> None: ...
def list(self) -> None: ... def list(self, *args: Any, **kwargs: Any) -> None: ...
class TarArchive(BaseArchive): class TarArchive(BaseArchive):
def __init__(self, file: str) -> None: ... 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: ... def close(self) -> None: ...
class ZipArchive(BaseArchive): class ZipArchive(BaseArchive):
def __init__(self, file: str) -> None: ... 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: ... def close(self) -> None: ...
extension_map: Any extension_map: Dict[str, Type[BaseArchive]]

View File

@@ -1,17 +1,8 @@
from datetime import date as real_date from datetime import date as real_date, datetime as real_datetime, time as real_time
from datetime import datetime as real_datetime from typing import Union
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): ...
class date(real_date): ...
class datetime(real_datetime): ...
class time(real_time): ... class time(real_time): ...
def new_date(d: date) -> date: ... def new_date(d: date) -> date: ...

View File

@@ -1,23 +1,13 @@
from typing import Any, Callable, Optional, Set, Tuple, Type, Union from typing import Any, Callable, Optional, Set, Tuple, Type, Union
from django.contrib.auth.mixins import AccessMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.middleware.cache import CacheMiddleware
from django.test.testcases import LiveServerTestCase
from django.utils.deprecation import MiddlewareMixin from django.utils.deprecation import MiddlewareMixin
from django.views.generic.base import TemplateResponseMixin, View
class classonlymethod(classmethod): class classonlymethod(classmethod): ...
def __get__(
self,
instance: Optional[View],
cls: Type[Union[AccessMixin, SuccessMessageMixin, TemplateResponseMixin, View]] = ...,
) -> Callable: ...
def method_decorator( def method_decorator(
decorator: Union[Callable, Set[Callable], Tuple[Callable, Callable]], name: str = ... decorator: Union[Callable, Set[Callable], Tuple[Callable, Callable]], name: str = ...
) -> Callable: ... ) -> Callable: ...
def decorator_from_middleware_with_args(middleware_class: Type[CacheMiddleware]) -> Callable: ... def decorator_from_middleware_with_args(middleware_class: Type[MiddlewareMixin]) -> Callable: ...
def decorator_from_middleware(middleware_class: Type[MiddlewareMixin]) -> Callable: ... def decorator_from_middleware(middleware_class: Type[MiddlewareMixin]) -> Callable: ...
def available_attrs(fn: Any): ... def available_attrs(fn: Any): ...
def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ... def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callable: ...
@@ -25,5 +15,5 @@ def make_middleware_decorator(middleware_class: Type[MiddlewareMixin]) -> Callab
class classproperty: class classproperty:
fget: Optional[Callable] = ... fget: Optional[Callable] = ...
def __init__(self, method: Optional[Callable] = ...) -> None: ... def __init__(self, method: Optional[Callable] = ...) -> None: ...
def __get__(self, instance: Optional[LiveServerTestCase], cls: Type[LiveServerTestCase] = ...) -> str: ... def __get__(self, instance: Any, cls: Optional[type] = ...) -> Any: ...
def getter(self, method: Callable) -> classproperty: ... def getter(self, method: Callable) -> classproperty: ...

View File

@@ -1,17 +1,14 @@
from datetime import date, datetime from datetime import date, datetime
from io import StringIO
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List, Optional, Tuple, Union
from xml.sax import ContentHandler # type: ignore
from django.http.response import HttpResponse
from django.utils.xmlutils import SimplerXMLGenerator
def rfc2822_date(date: date) -> str: ... def rfc2822_date(date: date) -> str: ...
def rfc3339_date(date: date) -> str: ... def rfc3339_date(date: date) -> str: ...
def get_tag_uri(url: str, date: Optional[date]) -> str: ... def get_tag_uri(url: str, date: Optional[date]) -> str: ...
class SyndicationFeed: class SyndicationFeed:
feed: Any = ... feed: Dict[str, Any] = ...
items: Any = ... items: List[Dict[str, Any]] = ...
def __init__( def __init__(
self, self,
title: str, title: str,
@@ -50,58 +47,30 @@ class SyndicationFeed:
) -> None: ... ) -> None: ...
def num_items(self): ... def num_items(self): ...
def root_attributes(self) -> Dict[Any, Any]: ... 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 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 write(self, outfile: Any, encoding: Any) -> None: ...
def writeString(self, encoding: str) -> str: ... def writeString(self, encoding: str) -> str: ...
def latest_post_date(self) -> datetime: ... def latest_post_date(self) -> datetime: ...
class Enclosure: class Enclosure:
length: Union[int, str] length: Any
mime_type: str mime_type: str
url: str = ... url: str = ...
def __init__(self, url: str, length: Union[int, str], mime_type: str) -> None: ... def __init__(self, url: str, length: Union[int, str], mime_type: str) -> None: ...
class RssFeed(SyndicationFeed): class RssFeed(SyndicationFeed):
content_type: str = ... content_type: str = ...
def write(self, outfile: Union[StringIO, HttpResponse], encoding: str) -> None: ... def write_items(self, handler: ContentHandler) -> None: ...
def rss_attributes(self) -> Dict[str, str]: ... def endChannelElement(self, handler: ContentHandler) -> None: ...
def write_items(self, handler: SimplerXMLGenerator) -> None: ...
def add_root_elements(self, handler: SimplerXMLGenerator) -> None: ...
def endChannelElement(self, handler: SimplerXMLGenerator) -> None: ...
class RssUserland091Feed(RssFeed): class RssUserland091Feed(RssFeed): ...
feed: Dict[str, Optional[Union[List[str], str]]] class Rss201rev2Feed(RssFeed): ...
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 Atom1Feed(SyndicationFeed): 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 = ... content_type: str = ...
ns: str = ... ns: str = ...
def write(self, outfile: Union[StringIO, HttpResponse], encoding: str) -> None: ... def write_items(self, handler: ContentHandler) -> 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: ...
DefaultFeed = Rss201rev2Feed DefaultFeed = Rss201rev2Feed

View File

@@ -1,18 +1,3 @@
from tempfile import _TemporaryFileWrapper from typing import Any
from typing import Any, List, Optional, Tuple, Union
from django.core.checks.messages import CheckMessage def is_iterable(x: Any) -> bool: ...
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: ...

View File

@@ -2,7 +2,6 @@ import logging.config
from logging import LogRecord from logging import LogRecord
from typing import Any, Callable, Dict, Optional, Union from typing import Any, Callable, Dict, Optional, Union
from django.core.mail.backends.locmem import EmailBackend
from django.core.management.color import Style from django.core.management.color import Style
request_logger: Any request_logger: Any
@@ -15,7 +14,7 @@ class AdminEmailHandler(logging.Handler):
email_backend: Optional[str] = ... email_backend: Optional[str] = ...
def __init__(self, include_html: bool = ..., email_backend: Optional[str] = ...) -> None: ... 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 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: ... def format_subject(self, subject: str) -> str: ...
class CallbackFilter(logging.Filter): class CallbackFilter(logging.Filter):

View File

@@ -1,144 +1,106 @@
import types from __future__ import print_function
from typing import Any, Optional
PY2: Any import types
PY3: Any import typing
PY34: Any import unittest
string_types: Any from typing import (
integer_types: Any Any,
class_types: Any AnyStr,
Callable,
Dict,
ItemsView,
Iterable,
KeysView,
Mapping,
NoReturn,
Optional,
Pattern,
Text,
Tuple,
Type,
TypeVar,
Union,
ValuesView,
overload,
)
# Exports
_T = TypeVar("_T")
_K = TypeVar("_K")
_V = TypeVar("_V")
# TODO make constant, then move this stub to 2and3
# https://github.com/python/typeshed/issues/17
PY2 = False
PY3 = True
PY34 = ... # type: bool
string_types = (str,)
integer_types = (int,)
class_types = (type,)
text_type = str text_type = str
binary_type = bytes binary_type = bytes
MAXSIZE: Any
text_type = unicode
binary_type = str
class X: MAXSIZE = ... # type: int
def __len__(self): ...
class _LazyDescr: # def add_move
name: Any = ... # def remove_move
def __init__(self, name: Any) -> None: ...
def __get__(self, obj: Any, tp: Any): ...
class MovedModule(_LazyDescr): def callable(obj: object) -> bool: ...
mod: Any = ... def get_unbound_function(unbound: types.FunctionType) -> types.FunctionType: ...
def __init__(self, name: Any, old: Any, new: Optional[Any] = ...) -> None: ... def create_bound_method(func: types.FunctionType, obj: object) -> types.MethodType: ...
def __getattr__(self, attr: Any): ... def create_unbound_method(func: types.FunctionType, cls: type) -> types.FunctionType: ...
class _LazyModule(types.ModuleType):
__doc__: Any = ...
def __init__(self, name: Any) -> None: ...
def __dir__(self): ...
class MovedAttribute(_LazyDescr):
mod: Any = ...
attr: Any = ...
def __init__(
self, name: Any, old_mod: Any, new_mod: Any, old_attr: Optional[Any] = ..., new_attr: Optional[Any] = ...
) -> None: ...
class _SixMetaPathImporter:
name: Any = ...
known_modules: Any = ...
def __init__(self, six_module_name: Any) -> None: ...
def find_module(self, fullname: Any, path: Optional[Any] = ...): ...
def load_module(self, fullname: Any): ...
def is_package(self, fullname: Any): ...
def get_code(self, fullname: Any): ...
get_source: Any = ...
class _MovedItems(_LazyModule):
__path__: Any = ...
moves: Any
class Module_six_moves_urllib_parse(_LazyModule): ...
class Module_six_moves_urllib_error(_LazyModule): ...
class Module_six_moves_urllib_request(_LazyModule): ...
class Module_six_moves_urllib_response(_LazyModule): ...
class Module_six_moves_urllib_robotparser(_LazyModule): ...
class Module_six_moves_urllib(types.ModuleType):
__path__: Any = ...
parse: Any = ...
error: Any = ...
request: Any = ...
response: Any = ...
robotparser: Any = ...
def __dir__(self): ...
def add_move(move: Any) -> None: ...
def remove_move(name: Any) -> None: ...
advance_iterator = next
next = advance_iterator
callable = callable
def get_unbound_function(unbound: Any): ...
create_bound_method: Any
def create_unbound_method(func: Any, cls: Any): ...
Iterator = object Iterator = object
class Iterator: def get_method_function(meth: types.MethodType) -> types.FunctionType: ...
def next(self): ... def get_method_self(meth: types.MethodType) -> Optional[object]: ...
def get_function_closure(fun: types.FunctionType) -> Optional[Tuple[types._Cell, ...]]: ...
def get_function_code(fun: types.FunctionType) -> types.CodeType: ...
def get_function_defaults(fun: types.FunctionType) -> Optional[Tuple[Any, ...]]: ...
def get_function_globals(fun: types.FunctionType) -> Dict[str, Any]: ...
def iterkeys(d: Mapping[_K, _V]) -> typing.Iterator[_K]: ...
def itervalues(d: Mapping[_K, _V]) -> typing.Iterator[_V]: ...
def iteritems(d: Mapping[_K, _V]) -> typing.Iterator[Tuple[_K, _V]]: ...
callable = callable # def iterlists
get_method_function: Any
get_method_self: Any
get_function_closure: Any
get_function_code: Any
get_function_defaults: Any
get_function_globals: Any
def iterkeys(d: Any, **kw: Any): ... def viewkeys(d: Mapping[_K, _V]) -> KeysView[_K]: ...
def itervalues(d: Any, **kw: Any): ... def viewvalues(d: Mapping[_K, _V]) -> ValuesView[_V]: ...
def iteritems(d: Any, **kw: Any): ... def viewitems(d: Mapping[_K, _V]) -> ItemsView[_K, _V]: ...
def iterlists(d: Any, **kw: Any): ... def b(s: str) -> binary_type: ...
def u(s: str) -> text_type: ...
viewkeys: Any
viewvalues: Any
viewitems: Any
def b(s: Any): ...
def u(s: Any): ...
unichr = chr unichr = chr
int2byte: Any
byte2int: Any
indexbytes: Any
iterbytes = iter
StringIO: Any
BytesIO: Any
unichr = unichr
int2byte = chr
def assertCountEqual(self, *args: Any, **kwargs: Any): ... def int2byte(i: int) -> bytes: ...
def assertRaisesRegex(self, *args: Any, **kwargs: Any): ... def byte2int(bs: binary_type) -> int: ...
def assertRegex(self, *args: Any, **kwargs: Any): ... def indexbytes(buf: binary_type, i: int) -> int: ...
def iterbytes(buf: binary_type) -> typing.Iterator[int]: ...
def assertCountEqual(
self: unittest.TestCase, first: Iterable[_T], second: Iterable[_T], msg: Optional[str] = ...
) -> None: ...
@overload
def assertRaisesRegex(self: unittest.TestCase, msg: Optional[str] = ...) -> Any: ...
@overload
def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ...
def assertRegex(
self: unittest.TestCase, text: AnyStr, expected_regex: Union[AnyStr, Pattern[AnyStr]], msg: Optional[str] = ...
) -> None: ...
exec_: Any exec_ = exec
def reraise(tp: Any, value: Any, tb: Optional[Any] = ...) -> None: ... def reraise(
def raise_from(value: Any, from_value: Any) -> None: ... tp: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType] = ...
) -> NoReturn: ...
def raise_from(value: Union[BaseException, Type[BaseException]], from_value: Optional[BaseException]) -> NoReturn: ...
print_: Any print_ = print
_print = print_
def wraps(wrapped: Any, assigned: Any = ..., updated: Any = ...): ... def with_metaclass(meta: type, *bases: type) -> type: ...
def add_metaclass(metaclass: type) -> Callable[[_T], _T]: ...
wraps: Any def ensure_binary(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> bytes: ...
def ensure_str(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> str: ...
def with_metaclass(meta: Any, *bases: Any): ... def ensure_text(s: Union[bytes, Text], encoding: str = ..., errors: str = ...) -> Text: ...
def add_metaclass(metaclass: Any): ... def python_2_unicode_compatible(klass: _T) -> _T: ...
def python_2_unicode_compatible(klass: Any): ...
__path__: Any
__package__ = __name__
memoryview = memoryview
buffer_types: Any
memoryview = memoryview
memoryview = buffer

View File

@@ -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.db.models.base import Model
from django.utils.functional import SimpleLazyObject from django.utils.functional import SimpleLazyObject
@@ -34,7 +34,7 @@ class StreamingBuffer:
def flush(self): ... def flush(self): ...
def close(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 smart_split_re: Any

View File

@@ -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 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): class UTC(tzinfo):
def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
@@ -16,9 +16,9 @@ class FixedOffset(tzinfo):
def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
class ReferenceLocalTimezone(tzinfo): class ReferenceLocalTimezone(tzinfo):
STDOFFSET = ... # type: timedelta STDOFFSET: timedelta = ...
DSTOFFSET = ... # type: timedelta DSTOFFSET: timedelta = ...
DSTDIFF = ... # type: timedelta DSTDIFF: timedelta = ...
def __init__(self) -> None: ... def __init__(self) -> None: ...
def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ... def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
@@ -27,7 +27,7 @@ class ReferenceLocalTimezone(tzinfo):
class LocalTimezone(ReferenceLocalTimezone): class LocalTimezone(ReferenceLocalTimezone):
def tzname(self, dt: Optional[datetime]) -> str: ... def tzname(self, dt: Optional[datetime]) -> str: ...
utc = ... # type: UTC utc: UTC = ...
def get_fixed_timezone(offset: Union[timedelta, int]) -> tzinfo: ... def get_fixed_timezone(offset: Union[timedelta, int]) -> tzinfo: ...
def get_default_timezone() -> tzinfo: ... def get_default_timezone() -> tzinfo: ...
@@ -38,15 +38,15 @@ def activate(timezone: tzinfo) -> None: ...
def deactivate() -> None: ... def deactivate() -> None: ...
class override(ContextDecorator): class override(ContextDecorator):
timezone = ... # type: tzinfo timezone: tzinfo = ...
old_timezone = ... # type: tzinfo old_timezone: tzinfo = ...
def __init__(self, timezone: tzinfo) -> None: ... def __init__(self, timezone: tzinfo) -> None: ...
def __enter__(self) -> None: ... def __enter__(self) -> None: ...
def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> 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 now() -> datetime: ...
def is_aware(value: datetime) -> bool: ... def is_aware(value: _AnyTime) -> bool: ...
def is_naive(value: datetime) -> bool: ... def is_naive(value: _AnyTime) -> bool: ...
def make_aware(value: datetime, timezone: tzinfo = None, is_dst: bool = None) -> datetime: ... def make_aware(value: _AnyTime, timezone: Optional[tzinfo] = None, is_dst: Optional[bool] = None) -> datetime: ...
def make_naive(value: datetime, timezone: tzinfo = None) -> datetime: ... def make_naive(value: _AnyTime, timezone: Optional[tzinfo] = None) -> datetime: ...

View File

@@ -0,0 +1,5 @@
from typing import Callable, TypeVar
_C = TypeVar("_C", bound=Callable)
def gzip_page(view_func: _C) -> _C: ...

View File

@@ -11,7 +11,7 @@ class MultipleObjectMixin(ContextMixin):
allow_empty: bool = ... allow_empty: bool = ...
queryset: Optional[QuerySet] = ... queryset: Optional[QuerySet] = ...
model: Optional[Type[Model]] = ... model: Optional[Type[Model]] = ...
paginate_by: Optional[int] = ... paginate_by: int = ...
paginate_orphans: int = ... paginate_orphans: int = ...
context_object_name: Optional[str] = ... context_object_name: Optional[str] = ...
paginator_class: Type[Paginator] = ... paginator_class: Type[Paginator] = ...

View File

@@ -8,6 +8,7 @@ from dataclasses import dataclass
class Config: class Config:
django_settings_module: Optional[str] = None django_settings_module: Optional[str] = None
ignore_missing_settings: bool = False ignore_missing_settings: bool = False
ignore_missing_model_attributes: bool = False
@classmethod @classmethod
def from_config_file(cls, fpath: str) -> 'Config': def from_config_file(cls, fpath: str) -> 'Config':
@@ -22,5 +23,9 @@ class Config:
django_settings = django_settings.strip() django_settings = django_settings.strip()
return Config(django_settings_module=django_settings, return Config(django_settings_module=django_settings,
ignore_missing_settings=bool(ini_config.get('mypy_django_plugin', 'ignore_missing_settings', ignore_missing_settings=bool(ini_config.get('mypy_django_plugin',
'ignore_missing_settings',
fallback=False)),
ignore_missing_model_attributes=bool(ini_config.get('mypy_django_plugin',
'ignore_missing_model_attributes',
fallback=False))) fallback=False)))

View File

@@ -1,15 +1,20 @@
import typing import typing
from typing import Dict, Optional from collections import OrderedDict
from typing import Dict, Optional, cast
from mypy.checker import TypeChecker from mypy.mro import calculate_mro
from mypy.nodes import ( from mypy.nodes import (
AssignmentStmt, ClassDef, Expression, ImportedName, Lvalue, MypyFile, NameExpr, SymbolNode, TypeInfo, GDEF, MDEF, AssignmentStmt, Block, CallExpr, ClassDef, Expression, ImportedName, Lvalue, MypyFile, NameExpr,
SymbolNode, SymbolTable, SymbolTableNode, TypeInfo, Var,
) )
from mypy.plugin import FunctionContext, MethodContext from mypy.plugin import CheckerPluginInterface, FunctionContext, MethodContext
from mypy.types import ( from mypy.types import (
AnyType, Instance, NoneTyp, Type, TypeOfAny, TypeVarType, UnionType, AnyType, Instance, NoneTyp, TupleType, Type, TypedDictType, TypeOfAny, TypeVarType, UnionType,
) )
if typing.TYPE_CHECKING:
from mypy.checker import TypeChecker
MODEL_CLASS_FULLNAME = 'django.db.models.base.Model' MODEL_CLASS_FULLNAME = 'django.db.models.base.Model'
FIELD_FULLNAME = 'django.db.models.fields.Field' FIELD_FULLNAME = 'django.db.models.fields.Field'
CHAR_FIELD_FULLNAME = 'django.db.models.fields.CharField' CHAR_FIELD_FULLNAME = 'django.db.models.fields.CharField'
@@ -163,7 +168,7 @@ def get_argument_type_by_name(ctx: typing.Union[FunctionContext, MethodContext],
return arg_types[0] return arg_types[0]
def get_setting_expr(api: TypeChecker, setting_name: str) -> Optional[Expression]: def get_setting_expr(api: 'TypeChecker', setting_name: str) -> Optional[Expression]:
try: try:
settings_sym = api.modules['django.conf'].names['settings'] settings_sym = api.modules['django.conf'].names['settings']
except KeyError: except KeyError:
@@ -211,7 +216,8 @@ def extract_field_setter_type(tp: Instance) -> Optional[Type]:
return None return None
def extract_field_getter_type(tp: Instance) -> Optional[Type]: def extract_field_getter_type(tp: Type) -> Optional[Type]:
""" Extract return type of __get__ of subclass of Field"""
if not isinstance(tp, Instance): if not isinstance(tp, Instance):
return None return None
if tp.type.has_base(FIELD_FULLNAME): if tp.type.has_base(FIELD_FULLNAME):
@@ -222,19 +228,26 @@ def extract_field_getter_type(tp: Instance) -> Optional[Type]:
return None return None
def get_django_metadata(model: TypeInfo) -> Dict[str, typing.Any]: def get_django_metadata(model_info: TypeInfo) -> Dict[str, typing.Any]:
return model.metadata.setdefault('django', {}) return model_info.metadata.setdefault('django', {})
def get_related_field_primary_key_names(base_model: TypeInfo) -> typing.List[str]: def get_related_field_primary_key_names(base_model: TypeInfo) -> typing.List[str]:
django_metadata = get_django_metadata(base_model) return get_django_metadata(base_model).setdefault('related_field_primary_keys', [])
return django_metadata.setdefault('related_field_primary_keys', [])
def get_fields_metadata(model: TypeInfo) -> Dict[str, typing.Any]: def get_fields_metadata(model: TypeInfo) -> Dict[str, typing.Any]:
return get_django_metadata(model).setdefault('fields', {}) return get_django_metadata(model).setdefault('fields', {})
def get_lookups_metadata(model: TypeInfo) -> Dict[str, typing.Any]:
return get_django_metadata(model).setdefault('lookups', {})
def get_related_managers_metadata(model: TypeInfo) -> Dict[str, typing.Any]:
return get_django_metadata(model).setdefault('related_managers', {})
def extract_explicit_set_type_of_model_primary_key(model: TypeInfo) -> Optional[Type]: def extract_explicit_set_type_of_model_primary_key(model: TypeInfo) -> Optional[Type]:
""" """
If field with primary_key=True is set on the model, extract its __set__ type. If field with primary_key=True is set on the model, extract its __set__ type.
@@ -296,3 +309,135 @@ def get_assigned_value_for_class(type_info: TypeInfo, name: str) -> Optional[Exp
if isinstance(lvalue, NameExpr) and lvalue.name == name: if isinstance(lvalue, NameExpr) and lvalue.name == name:
return rvalue return rvalue
return None return None
def is_field_nullable(model: TypeInfo, field_name: str) -> bool:
return get_fields_metadata(model).get(field_name, {}).get('null', False)
def is_foreign_key_like(t: Type) -> bool:
if not isinstance(t, Instance):
return False
return has_any_of_bases(t.type, (FOREIGN_KEY_FULLNAME, ONETOONE_FIELD_FULLNAME))
def build_class_with_annotated_fields(api: 'TypeChecker', base: Type, fields: 'OrderedDict[str, Type]',
name: str) -> Instance:
"""Build an Instance with `name` that contains the specified `fields` as attributes and extends `base`."""
# Credit: This code is largely copied/modified from TypeChecker.intersect_instance_callable and
# NamedTupleAnalyzer.build_namedtuple_typeinfo
from mypy.checker import gen_unique_name
cur_module = cast(MypyFile, api.scope.stack[0])
gen_name = gen_unique_name(name, cur_module.names)
cdef = ClassDef(name, Block([]))
cdef.fullname = cur_module.fullname() + '.' + gen_name
info = TypeInfo(SymbolTable(), cdef, cur_module.fullname())
cdef.info = info
info.bases = [base]
def add_field(var: Var, is_initialized_in_class: bool = False,
is_property: bool = False) -> None:
var.info = info
var.is_initialized_in_class = is_initialized_in_class
var.is_property = is_property
var._fullname = '%s.%s' % (info.fullname(), var.name())
info.names[var.name()] = SymbolTableNode(MDEF, var)
vars = [Var(item, typ) for item, typ in fields.items()]
for var in vars:
add_field(var, is_property=True)
calculate_mro(info)
info.calculate_metaclass_type()
cur_module.names[gen_name] = SymbolTableNode(GDEF, info, plugin_generated=True)
return Instance(info, [])
def make_named_tuple(api: 'TypeChecker', fields: 'OrderedDict[str, Type]', name: str) -> Type:
if not fields:
# No fields specified, so fallback to a subclass of NamedTuple that allows
# __getattr__ / __setattr__ for any attribute name.
fallback = api.named_generic_type('django._NamedTupleAnyAttr', [])
else:
fallback = build_class_with_annotated_fields(
api=api,
base=api.named_generic_type('typing.NamedTuple', []),
fields=fields,
name=name
)
return TupleType(list(fields.values()), fallback=fallback)
def make_typeddict(api: CheckerPluginInterface, fields: 'OrderedDict[str, Type]',
required_keys: typing.Set[str]) -> TypedDictType:
object_type = api.named_generic_type('mypy_extensions._TypedDict', [])
typed_dict_type = TypedDictType(fields, required_keys=required_keys, fallback=object_type)
return typed_dict_type
def make_tuple(api: 'TypeChecker', fields: typing.List[Type]) -> TupleType:
implicit_any = AnyType(TypeOfAny.special_form)
fallback = api.named_generic_type('builtins.tuple', [implicit_any])
return TupleType(fields, fallback=fallback)
def get_private_descriptor_type(type_info: TypeInfo, private_field_name: str, is_nullable: bool) -> Type:
node = type_info.get(private_field_name).node
if isinstance(node, Var):
descriptor_type = node.type
if is_nullable:
descriptor_type = make_optional(descriptor_type)
return descriptor_type
return AnyType(TypeOfAny.unannotated)
def iter_over_classdefs(module_file: MypyFile) -> typing.Iterator[ClassDef]:
for defn in module_file.defs:
if isinstance(defn, ClassDef):
yield defn
def iter_call_assignments(klass: ClassDef) -> typing.Iterator[typing.Tuple[Lvalue, CallExpr]]:
for lvalue, rvalue in iter_over_assignments(klass):
if isinstance(rvalue, CallExpr):
yield lvalue, rvalue
def get_related_manager_type_from_metadata(model_info: TypeInfo, related_manager_name: str,
api: CheckerPluginInterface) -> Optional[Instance]:
related_manager_metadata = get_related_managers_metadata(model_info)
if not related_manager_metadata:
return None
if related_manager_name not in related_manager_metadata:
return None
manager_class_name = related_manager_metadata[related_manager_name]['manager']
of = related_manager_metadata[related_manager_name]['of']
of_types = []
for of_type_name in of:
if of_type_name == 'any':
of_types.append(AnyType(TypeOfAny.implementation_artifact))
else:
try:
of_type = api.named_generic_type(of_type_name, [])
except AssertionError:
# Internal error: attempted lookup of unknown name
of_type = AnyType(TypeOfAny.implementation_artifact)
of_types.append(of_type)
return api.named_generic_type(manager_class_name, of_types)
def get_primary_key_field_name(model_info: TypeInfo) -> Optional[str]:
for base in model_info.mro:
fields = get_fields_metadata(base)
for field_name, field_props in fields.items():
is_primary_key = field_props.get('primary_key', False)
if is_primary_key:
return field_name
return None

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