84 Commits

Author SHA1 Message Date
Maxim Kurnikov
9ea25f3e56 bump version 2019-02-22 00:13:59 +03:00
Maxim Kurnikov
dacf88c692 optimize hooks a bit 2019-02-22 00:12:23 +03:00
Maxim Kurnikov
3d14d07e4e incremental = True for plugin tests should be fixed now 2019-02-21 17:35:46 +03:00
Maxim Kurnikov
6e6d1645d3 enable incremental mode for tests, disable it for one so that it would pass 2019-02-21 00:06:09 +03:00
Maxim Kurnikov
2bd018951b forms, generic views fixes 2019-02-20 22:24:26 +03:00
Maxim Kurnikov
14ea848dd7 add nested Meta inheritance support for forms 2019-02-20 21:52:28 +03:00
Maxim Kurnikov
2d3b5492f0 fix form errors in CI 2019-02-20 21:24:49 +03:00
Maxim Kurnikov
194258ab8e Merge pull request #23 from syastrov/better-types-for-transaction-atomic
Add better typings plus test for transaction.atomic.
2019-02-20 21:12:14 +03:00
Maxim Kurnikov
116aa2c539 clean up forms 2019-02-20 15:22:46 +03:00
Seth Yastrov
67c99434e5 Add better typings plus test for transaction.atomic.
- All cases are handled, including bare decorator (@transaction.atomic).
- Decorated function's signature is preserved when type-checking.
2019-02-20 06:40:22 +01:00
Maxim Kurnikov
5d8cdbcf29 fix integer set type 2019-02-20 02:38:45 +03:00
Maxim Kurnikov
78810f55b6 Merge pull request #26 from roderik333/supertype-processformview
*args and **kwargs changed from 'object' to 'str' and 'any' in post()…
2019-02-19 15:23:50 +03:00
Rune Steinnes
36662896bc *args and **kwargs changed from 'object' to 'str' and 'any' in post(), put() and get() 2019-02-19 12:48:07 +01:00
Maxim Kurnikov
e54dbb79c9 Merge pull request #24 from roderik333/replace-wsgirequest-in-loginrequiredmixin
Replaced WSGIRequest with http.HttpRequest in mixin:LoginRequiredMixin
2019-02-19 13:54:43 +03:00
Rune Steinnes
41f283552a Replaced WSGIRequest with http.HttpRequest in mixin:LoginRequiredMixin 2019-02-19 11:16:27 +01:00
Maxim Kurnikov
ab73d53ae5 add support for models defined in the same module be specified as name of class in related fields 2019-02-19 00:43:27 +03:00
Maxim Kurnikov
d24be4b35f add supported versions to README 2019-02-19 00:42:12 +03:00
Maxim Kurnikov
9d60b472df fix *args, **kwargs for views.generic.base 2019-02-18 15:45:01 +03:00
Maxim Kurnikov
632e063e22 back to incremental = True for tests 2019-02-18 02:16:13 +03:00
Maxim Kurnikov
66224416b5 bump version 2019-02-18 01:47:45 +03:00
Maxim Kurnikov
e5b2496eb5 update django tests sources to latest commit 2019-02-18 01:05:57 +03:00
Maxim Kurnikov
f980311be0 finish strict_optional support, enable it for typechecking of django tests 2019-02-18 00:52:56 +03:00
Maxim Kurnikov
400a0f0486 silence some false positives 2019-02-17 20:20:33 +03:00
Maxim Kurnikov
882ec71d23 remove redundant test 2019-02-17 18:08:58 +03:00
Maxim Kurnikov
e9f9202ed1 preliminary support for strict_optional 2019-02-17 18:07:53 +03:00
Maxim Kurnikov
6763217a80 some strict optional fixes 2019-02-16 21:28:37 +03:00
Maxim Kurnikov
6da5ead6f0 move to pypi version of pytest plugin 2019-02-15 22:01:35 +03:00
Maxim Kurnikov
c382d6aa2f fix redefining field with name id with different than int type 2019-02-15 21:54:40 +03:00
Maxim Kurnikov
63a14f7107 chmod +x 2019-02-15 20:06:13 +03:00
Maxim Kurnikov
dc33dd9493 fix setup.py definition 2019-02-15 20:03:55 +03:00
Maxim Kurnikov
4cb10390cf bump version 2019-02-14 03:34:49 +03:00
Maxim Kurnikov
c1640b619f fix stale import 2019-02-14 03:21:11 +03:00
Maxim Kurnikov
a08ad80a0d fix star import parsing for settings 2019-02-14 03:16:07 +03:00
Maxim Kurnikov
f30cd092f1 add default for MYPY_DJANGO_CONFIG 2019-02-13 23:02:49 +03:00
Maxim Kurnikov
dcd9ee0bb8 enable 'validation' test folder 2019-02-13 21:12:58 +03:00
Maxim Kurnikov
26a80a8279 add properly typed FOREIGN_KEY_FIELD_NAME_id fields to models 2019-02-13 21:05:02 +03:00
Maxim Kurnikov
82de0a8791 lint 2019-02-13 20:00:42 +03:00
Maxim Kurnikov
79ebe20f2e add more test folders 2019-02-13 19:44:25 +03:00
Maxim Kurnikov
587c2c484b more accurate types for from_queryset() 2019-02-13 17:55:50 +03:00
Maxim Kurnikov
4a22da29cb add support for default related managers, fixes #18 2019-02-13 17:11:22 +03:00
Maxim Kurnikov
70378b8f40 preserve fallback to Any for unrecognized field types for init/create 2019-02-13 17:00:35 +03:00
Maxim Kurnikov
b7f7713c5a add support for get_user_model(), fixes #16 2019-02-13 15:56:21 +03:00
Maxim Kurnikov
2720b74242 add proper generic support for get_object_or_404/get_list_or_404, fixes #22 2019-02-13 14:52:10 +03:00
Maxim Kurnikov
563c0add5e add release script 2019-02-13 14:36:33 +03:00
Maxim Kurnikov
3191740c6b bump version 2019-02-13 14:36:17 +03:00
Maxim Kurnikov
cf7c263fb5 fix tests 2019-02-12 17:09:28 +03:00
Maxim Kurnikov
16a983152a CharField can receive ints 2019-02-12 04:08:30 +03:00
Maxim Kurnikov
9eb95fbab3 add BaseManager.create() typechecking 2019-02-12 03:54:48 +03:00
Maxim Kurnikov
7aafca2e5d Change license to MIT 2019-02-11 13:56:34 +03:00
Maxim Kurnikov
d05e739d75 fix ci 2019-02-11 01:29:30 +03:00
Maxim Kurnikov
faefdcca5b fix ci 2019-02-11 01:12:59 +03:00
Maxim Kurnikov
643f852775 enable two more test folders 2019-02-10 04:41:54 +03:00
Maxim Kurnikov
6b7507206a fix couple edge cases with __init__ 2019-02-10 04:32:27 +03:00
Maxim Kurnikov
5f6f597266 add config file support 2019-02-09 03:21:49 +03:00
Maxim Kurnikov
5c6aa9a00b bump mypy version 2019-02-09 03:03:49 +03:00
Maxim Kurnikov
916df1efb6 add Model.__init__ typechecking 2019-02-08 17:16:03 +03:00
Maxim Kurnikov
dead370244 fix ci 2019-02-07 20:58:12 +03:00
Maxim Kurnikov
dcb4da378b add dataclasses as a dependency for python3.6 2019-02-07 19:19:16 +03:00
Maxim Kurnikov
d4cb729c93 rework settings, add loading of the django.conf.global_settings, cleanups 2019-02-07 19:13:39 +03:00
Maxim Kurnikov
faee26703e fix ci 2019-02-07 02:10:53 +03:00
Maxim Kurnikov
f7b586f038 ci should be good now 2019-02-07 01:43:34 +03:00
Maxim Kurnikov
56cd3bc77d fix ci 2019-02-07 01:27:29 +03:00
Maxim Kurnikov
11500f337d try ci fix 2019-02-07 01:19:19 +03:00
Maxim Kurnikov
723d9fbfb7 fix 2019-02-07 01:04:43 +03:00
Maxim Kurnikov
3fb3bbcf19 fix values_list 2019-02-07 01:01:05 +03:00
Maxim Kurnikov
191496ed72 enable some test folders, bunch of fixes 2019-02-07 00:08:05 +03:00
Maxim Kurnikov
d43cb1fcd7 fixes 2019-02-06 22:20:12 +03:00
Maxim Kurnikov
2559901ff3 more test folders 2019-02-06 20:56:44 +03:00
Maxim Kurnikov
0c121d65d1 fixes 2019-02-06 20:46:05 +03:00
Maxim Kurnikov
d18fc0bf5f enable 6 more test folders 2019-02-06 14:29:42 +03:00
Maxim Kurnikov
c534e75aaf remove Meta entries 2019-02-06 13:22:53 +03:00
Maxim Kurnikov
af30bb6c4a Merge pull request #15 from HyreAS/more-fields
More fields
2019-02-05 16:46:57 +03:00
Maxim Kurnikov
dbc9b49867 add test_runner/lookup test folders 2019-02-05 16:41:28 +03:00
Aleksander Vognild Burkow
a9c1f35494 Update decimal reveal_type test 2019-02-05 14:30:23 +01:00
Aleksander Vognild Burkow
4ea4c3eddd Ignore external psycopg2 types 2019-02-05 14:23:06 +01:00
Maxim Kurnikov
e4d2b795e3 fix ci 2019-02-05 16:09:42 +03:00
Maxim Kurnikov
be0b2eebb2 add central directory for mypy cache 2019-02-05 15:35:01 +03:00
Maxim Kurnikov
38291e0651 fix ci 2019-02-04 19:38:19 +03:00
Maxim Kurnikov
69d4ccaf54 fixes, add some testing folders 2019-02-04 19:31:37 +03:00
Aleksander Vognild Burkow
6c87ccf228 Add tests for the new fields 2019-02-04 17:15:34 +01:00
Aleksander Vognild Burkow
08bf5660bf Add additional django field __get__ types
These are taken from the corresponding
django/contrib/postgres/fields/ranges.py file.
2019-02-04 17:08:00 +01:00
Aleksander Vognild Burkow
7819165e42 Add decimal field typings 2019-02-04 17:08:00 +01:00
Maxim Kurnikov
3dcab64e07 add stricter dependencies 2019-02-04 18:47:01 +03:00
Maxim Kurnikov
5a08a99d8b disable deployment on tags for now 2019-02-04 18:46:13 +03:00
150 changed files with 3655 additions and 1966 deletions

View File

@@ -25,10 +25,10 @@ install: |
pip install -r ./dev-requirements.txt
pip install -r ./scripts/typecheck-tests-requirements.txt
deploy:
provider: pypi
user: "mkurnikov"
password:
secure: 0E+hkaIdtpEtyL1KZeglunZ5/PKjouFfa8ljakAwoig7VNUL+2sO/bTyg38wRQl0NvzDzEHSMEt1bzg4Tq7b7Zp6nLuewG/w7mGLzqaOlTySiPEfRsg8s6uO2KrTn7g9VhlXH6UtyTXoQdMt6aE8+bt/GmEesanS57NB2mhwmylFgQwlJFu4LfIv/+aGmc4eLeGI2Qhvs9QYf7qvYlLQldgFh8mAckQEEvaBg35sf+puypZgf4nkx1k/dfG9wnFWZU8PJ41LbMw/Wj+k/9NpF8ePwiAr0fvRMErZd8nvoiWjQQjhzgrLVHhXEP5pTHh3zjDuGFMWyKuBhC6WLsG4qOQz/HvxeYvNI+jaTp15BgxtefG/pCNDUl/8GlCde7xVt7xzEcYNJSRaZPY2oofEFSd9qDnr4kqmyCXpNsaHRHvkL61bFjXUcfOsMMYvQCC6N2Jjb7S97RbnDdkOZO/lnFhVANT2rigsaXlSlWyN6f7ApxDNvu6Ehu5yrx6IjlPZJ0sI9vvY3IoS6Fik7w9E6zjNVjbmUn1D4MKFP4v5ppNASOqYcZeLd42j8rjEp0gIc3ccz9aUIT9q8VqSXSdUbqA6SVwvHXIVPxJMXj0bqWBG1iKs0cPBuzRVpRrwkENWCSWElDAewM1qFEnK0LppyoYFbqoQ8F5FG0+re7QttKQ=
on:
tags: true
#deploy:
# provider: pypi
# user: "mkurnikov"
# password:
# secure: 0E+hkaIdtpEtyL1KZeglunZ5/PKjouFfa8ljakAwoig7VNUL+2sO/bTyg38wRQl0NvzDzEHSMEt1bzg4Tq7b7Zp6nLuewG/w7mGLzqaOlTySiPEfRsg8s6uO2KrTn7g9VhlXH6UtyTXoQdMt6aE8+bt/GmEesanS57NB2mhwmylFgQwlJFu4LfIv/+aGmc4eLeGI2Qhvs9QYf7qvYlLQldgFh8mAckQEEvaBg35sf+puypZgf4nkx1k/dfG9wnFWZU8PJ41LbMw/Wj+k/9NpF8ePwiAr0fvRMErZd8nvoiWjQQjhzgrLVHhXEP5pTHh3zjDuGFMWyKuBhC6WLsG4qOQz/HvxeYvNI+jaTp15BgxtefG/pCNDUl/8GlCde7xVt7xzEcYNJSRaZPY2oofEFSd9qDnr4kqmyCXpNsaHRHvkL61bFjXUcfOsMMYvQCC6N2Jjb7S97RbnDdkOZO/lnFhVANT2rigsaXlSlWyN6f7ApxDNvu6Ehu5yrx6IjlPZJ0sI9vvY3IoS6Fik7w9E6zjNVjbmUn1D4MKFP4v5ppNASOqYcZeLd42j8rjEp0gIc3ccz9aUIT9q8VqSXSdUbqA6SVwvHXIVPxJMXj0bqWBG1iKs0cPBuzRVpRrwkENWCSWElDAewM1qFEnK0LppyoYFbqoQ8F5FG0+re7QttKQ=
# on:
# tags: true

View File

@@ -1,27 +1,8 @@
Copyright (c) Maxim Kurnikov.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of Django nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -7,6 +7,10 @@
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns.
Supports Python 3.6/3.7, and Django 2.1.x series.
Could be run on earlier versions of Django, but expect some missing imports warnings.
## Installation
```
@@ -23,7 +27,24 @@ plugins =
in your `mypy.ini` file.
Also, it uses value of `DJANGO_SETTINGS_MODULE` from the environment, so set it before execution, otherwise some features will not work.
## Configuration
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file. Default is `./mypy_django.ini`
Config file format (.ini):
```
[mypy_django_plugin]
# specify settings module to use for django.conf.settings, this setting
# could also be specified with DJANGO_SETTINGS_MODULE environment variable
# (it also takes priority over config file)
django_settings = mysettings.local
# 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
ignore_missing_settings = True
```
## To get help

View File

@@ -1,3 +1,3 @@
black
-e git+https://github.com/mkurnikov/pytest-mypy-plugins.git#egg=pytest-mypy-plugins
pytest-mypy-plugins
-e .

View File

@@ -1,4 +1,4 @@
from typing import Any, Iterator, Type, Optional
from typing import Any, Iterator, Type, Optional, Dict
from django.db.models.base import Model
@@ -12,7 +12,7 @@ class AppConfig:
verbose_name: str = ...
path: str = ...
models_module: None = ...
models: None = ...
models: Dict[str, Type[Model]] = ...
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
@classmethod
def create(cls, entry: str) -> AppConfig: ...

View File

@@ -1,5 +1,5 @@
import collections
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict
from django.db.migrations.state import AppConfigStub
from django.db.models.base import Model
@@ -12,6 +12,7 @@ class Apps:
stored_app_configs: List[Any] = ...
apps_ready: bool = ...
loading: bool = ...
_pending_operations: DefaultDict[Tuple[str, str], List]
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
models_ready: bool = ...
ready: bool = ...

View File

@@ -5,156 +5,67 @@ by the DJANGO_SETTINGS_MODULE environment variable.
# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
def gettext_noop(s):
return s
from typing import Any, Dict, List, Optional, Pattern, Tuple, Protocol, Union, Callable, TYPE_CHECKING, Sequence
####################
# CORE #
####################
if TYPE_CHECKING:
from django.db.models.base import Model
DEBUG = False
DEBUG: bool = ...
# Whether the framework should propagate raw exceptions rather than catching
# them. This is useful under some testing situations and should never be used
# on a live site.
DEBUG_PROPAGATE_EXCEPTIONS = False
DEBUG_PROPAGATE_EXCEPTIONS: bool = ...
# People who get code error notifications.
# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
ADMINS = []
ADMINS: List[Tuple[str, str]] = ...
# List of IP addresses, as strings, that:
# * See debug comments, when DEBUG is true
# * Receive x-headers
INTERNAL_IPS = []
INTERNAL_IPS: List[str] = ...
# Hosts/domain names that are valid for this site.
# "*" matches anything, ".example.com" matches example.com and all subdomains
ALLOWED_HOSTS = []
ALLOWED_HOSTS: List[str] = ...
# Local time zone for this installation. All choices can be found here:
# https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all
# systems may support all possibilities). When USE_TZ is True, this is
# interpreted as the default user time zone.
TIME_ZONE = "America/Chicago"
TIME_ZONE: str = ...
# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ = False
USE_TZ: bool = ...
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "en-us"
LANGUAGE_CODE: str = ...
# Languages we provide translations for, out of the box.
LANGUAGES = [
("af", gettext_noop("Afrikaans")),
("ar", gettext_noop("Arabic")),
("ast", gettext_noop("Asturian")),
("az", gettext_noop("Azerbaijani")),
("bg", gettext_noop("Bulgarian")),
("be", gettext_noop("Belarusian")),
("bn", gettext_noop("Bengali")),
("br", gettext_noop("Breton")),
("bs", gettext_noop("Bosnian")),
("ca", gettext_noop("Catalan")),
("cs", gettext_noop("Czech")),
("cy", gettext_noop("Welsh")),
("da", gettext_noop("Danish")),
("de", gettext_noop("German")),
("dsb", gettext_noop("Lower Sorbian")),
("el", gettext_noop("Greek")),
("en", gettext_noop("English")),
("en-au", gettext_noop("Australian English")),
("en-gb", gettext_noop("British English")),
("eo", gettext_noop("Esperanto")),
("es", gettext_noop("Spanish")),
("es-ar", gettext_noop("Argentinian Spanish")),
("es-co", gettext_noop("Colombian Spanish")),
("es-mx", gettext_noop("Mexican Spanish")),
("es-ni", gettext_noop("Nicaraguan Spanish")),
("es-ve", gettext_noop("Venezuelan Spanish")),
("et", gettext_noop("Estonian")),
("eu", gettext_noop("Basque")),
("fa", gettext_noop("Persian")),
("fi", gettext_noop("Finnish")),
("fr", gettext_noop("French")),
("fy", gettext_noop("Frisian")),
("ga", gettext_noop("Irish")),
("gd", gettext_noop("Scottish Gaelic")),
("gl", gettext_noop("Galician")),
("he", gettext_noop("Hebrew")),
("hi", gettext_noop("Hindi")),
("hr", gettext_noop("Croatian")),
("hsb", gettext_noop("Upper Sorbian")),
("hu", gettext_noop("Hungarian")),
("ia", gettext_noop("Interlingua")),
("id", gettext_noop("Indonesian")),
("io", gettext_noop("Ido")),
("is", gettext_noop("Icelandic")),
("it", gettext_noop("Italian")),
("ja", gettext_noop("Japanese")),
("ka", gettext_noop("Georgian")),
("kab", gettext_noop("Kabyle")),
("kk", gettext_noop("Kazakh")),
("km", gettext_noop("Khmer")),
("kn", gettext_noop("Kannada")),
("ko", gettext_noop("Korean")),
("lb", gettext_noop("Luxembourgish")),
("lt", gettext_noop("Lithuanian")),
("lv", gettext_noop("Latvian")),
("mk", gettext_noop("Macedonian")),
("ml", gettext_noop("Malayalam")),
("mn", gettext_noop("Mongolian")),
("mr", gettext_noop("Marathi")),
("my", gettext_noop("Burmese")),
("nb", gettext_noop("Norwegian Bokmål")),
("ne", gettext_noop("Nepali")),
("nl", gettext_noop("Dutch")),
("nn", gettext_noop("Norwegian Nynorsk")),
("os", gettext_noop("Ossetic")),
("pa", gettext_noop("Punjabi")),
("pl", gettext_noop("Polish")),
("pt", gettext_noop("Portuguese")),
("pt-br", gettext_noop("Brazilian Portuguese")),
("ro", gettext_noop("Romanian")),
("ru", gettext_noop("Russian")),
("sk", gettext_noop("Slovak")),
("sl", gettext_noop("Slovenian")),
("sq", gettext_noop("Albanian")),
("sr", gettext_noop("Serbian")),
("sr-latn", gettext_noop("Serbian Latin")),
("sv", gettext_noop("Swedish")),
("sw", gettext_noop("Swahili")),
("ta", gettext_noop("Tamil")),
("te", gettext_noop("Telugu")),
("th", gettext_noop("Thai")),
("tr", gettext_noop("Turkish")),
("tt", gettext_noop("Tatar")),
("udm", gettext_noop("Udmurt")),
("uk", gettext_noop("Ukrainian")),
("ur", gettext_noop("Urdu")),
("vi", gettext_noop("Vietnamese")),
("zh-hans", gettext_noop("Simplified Chinese")),
("zh-hant", gettext_noop("Traditional Chinese")),
]
LANGUAGES: List[Tuple[str, str]] = ...
# Languages using BiDi (right-to-left) layout
LANGUAGES_BIDI = ["he", "ar", "fa", "ur"]
LANGUAGES_BIDI: List[str] = ...
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
LOCALE_PATHS = []
USE_I18N: bool = ...
LOCALE_PATHS: List[str] = ...
# Settings for language cookie
LANGUAGE_COOKIE_NAME = "django_language"
LANGUAGE_COOKIE_AGE = None
LANGUAGE_COOKIE_DOMAIN = None
LANGUAGE_COOKIE_PATH = "/"
LANGUAGE_COOKIE_NAME: str = ...
LANGUAGE_COOKIE_AGE: Optional[int] = ...
LANGUAGE_COOKIE_DOMAIN: Optional[str] = ...
LANGUAGE_COOKIE_PATH: str = ...
# If you set this to True, Django will format dates, numbers and calendars
# according to user current locale.
USE_L10N = False
USE_L10N: bool = ...
# Not-necessarily-technical managers of the site. They get broken link
# notifications and other various emails.
@@ -163,66 +74,69 @@ MANAGERS = ADMINS
# Default content type and charset to use for all HttpResponse objects, if a
# MIME type isn't manually specified. These are used to construct the
# Content-Type header.
DEFAULT_CONTENT_TYPE = "text/html"
DEFAULT_CHARSET = "utf-8"
DEFAULT_CONTENT_TYPE: str = ...
DEFAULT_CHARSET: str = ...
# Encoding of files read from disk (template and initial SQL files).
FILE_CHARSET = "utf-8"
FILE_CHARSET: str = ...
# Email address that error messages come from.
SERVER_EMAIL = "root@localhost"
SERVER_EMAIL: str = ...
# Database connection info. If left empty, will default to the dummy backend.
DATABASES = {}
DATABASES: Dict[str, Dict[str, Any]] = ...
# Classes used to implement DB routing behavior.
DATABASE_ROUTERS = []
class Router(Protocol):
def allow_migrate(self, db, app_label, **hints): ...
DATABASE_ROUTERS: List[Union[str, Router]] = ...
# The email backend to use. For possible shortcuts see django.core.mail.
# The default is to use the SMTP backend.
# Third-party backends can be specified by providing a Python path
# to a module that defines an EmailBackend class.
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_BACKEND: str = ...
# Host for sending email.
EMAIL_HOST = "localhost"
EMAIL_HOST: str = ...
# Port for sending email.
EMAIL_PORT = 25
EMAIL_PORT: int = ...
# Whether to send SMTP 'Date' header in the local time zone or in UTC.
EMAIL_USE_LOCALTIME = False
EMAIL_USE_LOCALTIME: bool = ...
# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER = ""
EMAIL_HOST_PASSWORD = ""
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = None
EMAIL_TIMEOUT = None
EMAIL_HOST_USER: str = ...
EMAIL_HOST_PASSWORD: str = ...
EMAIL_USE_TLS: bool = ...
EMAIL_USE_SSL: bool = ...
EMAIL_SSL_CERTFILE: Optional[str] = ...
EMAIL_SSL_KEYFILE: Optional[str] = ...
EMAIL_TIMEOUT: Optional[int] = ...
# List of strings representing installed apps.
INSTALLED_APPS = []
INSTALLED_APPS: List[str] = ...
TEMPLATES = []
TEMPLATES: List[Dict[str, Any]] = ...
# Default form rendering class.
FORM_RENDERER = "django.forms.renderers.DjangoTemplates"
FORM_RENDERER: str = ...
# Default email address to use for various automated correspondence from
# the site managers.
DEFAULT_FROM_EMAIL = "webmaster@localhost"
DEFAULT_FROM_EMAIL: str = ...
# Subject-line prefix for email messages send with django.core.mail.mail_admins
# or ...mail_managers. Make sure to include the trailing space.
EMAIL_SUBJECT_PREFIX = "[Django] "
EMAIL_SUBJECT_PREFIX: str = ...
# Whether to append trailing slashes to URLs.
APPEND_SLASH = True
APPEND_SLASH: bool = ...
# Whether to prepend the "www." subdomain to URLs that don't have it.
PREPEND_WWW = False
PREPEND_WWW: bool = ...
# Override the server-derived value of SCRIPT_NAME
FORCE_SCRIPT_NAME = None
@@ -237,9 +151,9 @@ FORCE_SCRIPT_NAME = None
# re.compile(r'^SiteSucker.*'),
# re.compile(r'^sohu-search'),
# ]
DISALLOWED_USER_AGENTS = []
DISALLOWED_USER_AGENTS: List[Pattern] = ...
ABSOLUTE_URL_OVERRIDES = {}
ABSOLUTE_URL_OVERRIDES: Dict[str, Callable[[Model], str]] = ...
# List of compiled regular expression objects representing URLs that need not
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples:
@@ -251,54 +165,51 @@ ABSOLUTE_URL_OVERRIDES = {}
# re.compile(r'^/phpmyadmin/'),
# re.compile(r'\.(cgi|php|pl)$'),
# ]
IGNORABLE_404_URLS = []
IGNORABLE_404_URLS: List[Pattern] = ...
# A secret key for this particular Django installation. Used in secret-key
# hashing algorithms. Set this in your settings, or Django will complain
# loudly.
SECRET_KEY = ""
SECRET_KEY: str = ...
# Default file storage mechanism that holds media.
DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"
DEFAULT_FILE_STORAGE: str = ...
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ""
MEDIA_ROOT: str = ...
# URL that handles the media served from MEDIA_ROOT.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ""
MEDIA_URL: str = ...
# Absolute path to the directory static files should be collected to.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = None
STATIC_ROOT: Optional[str] = ...
# URL that handles the static files served from STATIC_ROOT.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = None
STATIC_URL: Optional[str] = ...
# List of upload handler classes to be applied in order.
FILE_UPLOAD_HANDLERS = [
"django.core.files.uploadhandler.MemoryFileUploadHandler",
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
]
FILE_UPLOAD_HANDLERS: List[str] = ...
# Maximum size, in bytes, of a request before it will be streamed to the
# file system instead of into memory.
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB
FILE_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB
# Maximum size in bytes of request data (excluding file uploads) that will be
# read before a SuspiciousOperation (RequestDataTooBig) is raised.
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 # i.e. 2.5 MB
DATA_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB
# Maximum number of GET/POST parameters that will be read before a
# SuspiciousOperation (TooManyFieldsSent) is raised.
DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000
DATA_UPLOAD_MAX_NUMBER_FIELDS: int = ...
# Directory in which upload streamed files will be temporarily saved. A value of
# `None` will make Django use the operating system's default temporary directory
# (i.e. "/tmp" on *nix systems).
FILE_UPLOAD_TEMP_DIR = None
FILE_UPLOAD_TEMP_DIR: Optional[str] = ...
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https://docs.python.org/library/os.html#files-and-directories.
@@ -313,116 +224,91 @@ FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
# The directory where this setting is pointing should contain subdirectories
# named as the locales, containing a formats.py file
# (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use)
FORMAT_MODULE_PATH = None
FORMAT_MODULE_PATH: Optional[str] = ...
# Default formatting for date objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = "N j, Y"
DATE_FORMAT: str = ...
# Default formatting for datetime objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATETIME_FORMAT = "N j, Y, P"
DATETIME_FORMAT: str = ...
# Default formatting for time objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
TIME_FORMAT = "P"
TIME_FORMAT: str = ...
# Default formatting for date objects when only the year and month are relevant.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
YEAR_MONTH_FORMAT = "F Y"
YEAR_MONTH_FORMAT: str = ...
# Default formatting for date objects when only the month and day are relevant.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
MONTH_DAY_FORMAT = "F j"
MONTH_DAY_FORMAT: str = ...
# Default short formatting for date objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATE_FORMAT = "m/d/Y"
SHORT_DATE_FORMAT: str = ...
# Default short formatting for datetime objects.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATETIME_FORMAT = "m/d/Y P"
SHORT_DATETIME_FORMAT: str = ...
# Default formats to be used when parsing dates from input boxes, in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
DATE_INPUT_FORMATS = [
"%Y-%m-%d",
"%m/%d/%Y",
"%m/%d/%y", # '2006-10-25', '10/25/2006', '10/25/06'
"%b %d %Y",
"%b %d, %Y", # 'Oct 25 2006', 'Oct 25, 2006'
"%d %b %Y",
"%d %b, %Y", # '25 Oct 2006', '25 Oct, 2006'
"%B %d %Y",
"%B %d, %Y", # 'October 25 2006', 'October 25, 2006'
"%d %B %Y",
"%d %B, %Y", # '25 October 2006', '25 October, 2006'
]
DATE_INPUT_FORMATS: List[str] = ...
# Default formats to be used when parsing times from input boxes, in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
TIME_INPUT_FORMATS = ["%H:%M:%S", "%H:%M:%S.%f", "%H:%M"] # '14:30:59' # '14:30:59.000200' # '14:30'
TIME_INPUT_FORMATS: List[str] = ... # '14:30:59' # '14:30:59.000200' # '14:30'
# Default formats to be used when parsing dates and times from input boxes,
# in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
DATETIME_INPUT_FORMATS = [
"%Y-%m-%d %H:%M:%S", # '2006-10-25 14:30:59'
"%Y-%m-%d %H:%M:%S.%f", # '2006-10-25 14:30:59.000200'
"%Y-%m-%d %H:%M", # '2006-10-25 14:30'
"%Y-%m-%d", # '2006-10-25'
"%m/%d/%Y %H:%M:%S", # '10/25/2006 14:30:59'
"%m/%d/%Y %H:%M:%S.%f", # '10/25/2006 14:30:59.000200'
"%m/%d/%Y %H:%M", # '10/25/2006 14:30'
"%m/%d/%Y", # '10/25/2006'
"%m/%d/%y %H:%M:%S", # '10/25/06 14:30:59'
"%m/%d/%y %H:%M:%S.%f", # '10/25/06 14:30:59.000200'
"%m/%d/%y %H:%M", # '10/25/06 14:30'
"%m/%d/%y", # '10/25/06'
]
DATETIME_INPUT_FORMATS: List[str] = ...
# First day of week, to be used on calendars
# 0 means Sunday, 1 means Monday...
FIRST_DAY_OF_WEEK = 0
FIRST_DAY_OF_WEEK: int = ...
# Decimal separator symbol
DECIMAL_SEPARATOR = "."
DECIMAL_SEPARATOR: str = ...
# Boolean that sets whether to add thousand separator when formatting numbers
USE_THOUSAND_SEPARATOR = False
USE_THOUSAND_SEPARATOR: bool = ...
# Number of digits that will be together, when splitting them by
# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
NUMBER_GROUPING = 0
NUMBER_GROUPING: int = ...
# Thousand separator symbol
THOUSAND_SEPARATOR = ","
THOUSAND_SEPARATOR: str = ...
# The tablespaces to use for each model when not specified otherwise.
DEFAULT_TABLESPACE = ""
DEFAULT_INDEX_TABLESPACE = ""
DEFAULT_TABLESPACE: str = ...
DEFAULT_INDEX_TABLESPACE: str = ...
# Default X-Frame-Options header value
X_FRAME_OPTIONS = "SAMEORIGIN"
X_FRAME_OPTIONS: str = ...
USE_X_FORWARDED_HOST = False
USE_X_FORWARDED_PORT = False
USE_X_FORWARDED_HOST: bool = ...
USE_X_FORWARDED_PORT: bool = ...
# The Python dotted path to the WSGI application that Django's internal server
# (runserver) will use. If `None`, the return value of
# 'django.core.wsgi.get_wsgi_application' is used, thus preserving the same
# behavior as previous versions of Django. Otherwise this should point to an
# actual WSGI application object.
WSGI_APPLICATION = None
WSGI_APPLICATION: Optional[str] = ...
# If your Django app is behind a proxy that sets a header to specify secure
# connections, AND that proxy ensures that user-submitted headers with the
@@ -431,7 +317,7 @@ WSGI_APPLICATION = None
# that header/value, request.is_secure() will return True.
# WARNING! Only set this if you fully understand what you're doing. Otherwise,
# you may be opening yourself up to a security risk.
SECURE_PROXY_SSL_HEADER = None
SECURE_PROXY_SSL_HEADER: Optional[Tuple[str, str]] = ...
##############
# MIDDLEWARE #
@@ -440,7 +326,7 @@ SECURE_PROXY_SSL_HEADER = None
# List of middleware to use. Order is important; in the request phase, these
# middleware will be applied in the order given, and in the response
# phase the middleware will be applied in reverse order.
MIDDLEWARE = []
MIDDLEWARE: List[str] = ...
############
# SESSIONS #
@@ -453,7 +339,7 @@ SESSION_COOKIE_NAME = "sessionid"
# Age of cookie, in seconds (default: 2 weeks).
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
# A string like "example.com", or None for standard domain cookie.
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_DOMAIN: Optional[str] = ...
# Whether the session cookie should be secure (https:// only).
SESSION_COOKIE_SECURE = False
# The path of the session cookie.
@@ -471,7 +357,7 @@ SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_ENGINE = "django.contrib.sessions.backends.db"
# Directory to store session files if using the file session module. If None,
# the backend will use a sensible default.
SESSION_FILE_PATH = None
SESSION_FILE_PATH: Optional[str] = ...
# class to serialize session data
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
@@ -480,7 +366,7 @@ SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
#########
# The cache backends to use.
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
CACHES: Dict[str, Dict[str, Any]] = ...
CACHE_MIDDLEWARE_KEY_PREFIX = ""
CACHE_MIDDLEWARE_SECONDS = 600
CACHE_MIDDLEWARE_ALIAS = "default"
@@ -489,15 +375,15 @@ CACHE_MIDDLEWARE_ALIAS = "default"
# AUTHENTICATION #
##################
AUTH_USER_MODEL = "auth.User"
AUTH_USER_MODEL: str = ...
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]
AUTHENTICATION_BACKENDS: Sequence[str] = ...
LOGIN_URL = "/accounts/login/"
LOGIN_REDIRECT_URL = "/accounts/profile/"
LOGIN_REDIRECT_URL: str = ...
LOGOUT_REDIRECT_URL = None
LOGOUT_REDIRECT_URL: Optional[str] = ...
# The number of days a password reset link is valid for
PASSWORD_RESET_TIMEOUT_DAYS = 3
@@ -505,14 +391,9 @@ PASSWORD_RESET_TIMEOUT_DAYS = 3
# the first hasher in this list is the preferred algorithm. any
# password using different algorithms will be converted automatically
# upon login
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
]
PASSWORD_HASHERS: List[str] = ...
AUTH_PASSWORD_VALIDATORS = []
AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] = ...
###########
# SIGNING #
@@ -537,7 +418,7 @@ CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_SAMESITE = "Lax"
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
CSRF_TRUSTED_ORIGINS = []
CSRF_TRUSTED_ORIGINS: List[str] = ...
CSRF_USE_SESSIONS = False
############
@@ -558,7 +439,7 @@ MESSAGE_STORAGE = "django.contrib.messages.storage.fallback.FallbackStorage"
LOGGING_CONFIG = "logging.config.dictConfig"
# Custom logging configuration.
LOGGING = {}
LOGGING: Dict[str, Any] = ...
# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
@@ -573,39 +454,35 @@ TEST_RUNNER = "django.test.runner.DiscoverRunner"
# Apps that don't need to be serialized at test database creation time
# (only apps with migrations are to start with)
TEST_NON_SERIALIZED_APPS = []
TEST_NON_SERIALIZED_APPS: List[str] = ...
############
# FIXTURES #
############
# The list of directories to search for fixtures
FIXTURE_DIRS = []
FIXTURE_DIRS: List[str] = ...
###############
# STATICFILES #
###############
# A list of locations of additional static files
STATICFILES_DIRS = []
STATICFILES_DIRS: List[str] = ...
# The default file storage backend used during the build process
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
STATICFILES_STORAGE: str = ...
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
]
STATICFILES_FINDERS: List[str] = ...
##############
# MIGRATIONS #
##############
# Migration module overrides for apps, by app label.
MIGRATION_MODULES = {}
MIGRATION_MODULES: Dict[str, str] = ...
#################
# SYSTEM CHECKS #
@@ -615,7 +492,7 @@ MIGRATION_MODULES = {}
# issues like warnings, infos or debugs will not generate a message. Silencing
# serious issues like errors and criticals does not result in hiding the
# message, but Django will not stop you from e.g. running server.
SILENCED_SYSTEM_CHECKS = []
SILENCED_SYSTEM_CHECKS: List[str] = ...
#######################
# SECURITY MIDDLEWARE #
@@ -625,6 +502,6 @@ SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_REDIRECT_EXEMPT = []
SECURE_REDIRECT_EXEMPT: List[str] = ...
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False

View File

@@ -5,10 +5,10 @@ from django.http.response import HttpResponse, HttpResponseBase
from django.urls import URLResolver, URLPattern
handler400 = ... # type: str
handler403 = ... # type: str
handler404 = ... # type: str
handler500 = ... # type: str
handler400: Callable[..., HttpResponse] = ...
handler403: Callable[..., HttpResponse] = ...
handler404: Callable[..., HttpResponse] = ...
handler500: Callable[..., HttpResponse] = ...
IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]]

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Iterator
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
@@ -16,7 +16,7 @@ class ListFilter:
self, request: WSGIRequest, params: Dict[str, str], model: Type[Model], model_admin: ModelAdmin
) -> None: ...
def has_output(self) -> bool: ...
def choices(self, changelist: Any) -> None: ...
def choices(self, changelist: Any) -> Optional[Iterator[Dict[str, Any]]]: ...
def queryset(self, request: Any, queryset: QuerySet) -> Optional[QuerySet]: ...
def expected_parameters(self) -> Optional[List[str]]: ...

View File

@@ -1,20 +1,17 @@
import datetime
from typing import Any, Dict, List, Optional, Union
from typing import Any, Optional, Union
from uuid import UUID
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.db.models.base import Model
from django.db import models
ADDITION: int
CHANGE: int
DELETION: int
ACTION_FLAG_CHOICES: Any
class LogEntryManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
class LogEntryManager(models.Manager["LogEntry"]):
def log_action(
self,
user_id: int,
@@ -22,28 +19,18 @@ class LogEntryManager(models.Manager):
object_id: Union[int, str, UUID],
object_repr: str,
action_flag: int,
change_message: Union[
Dict[str, Dict[str, List[str]]], List[Dict[str, Dict[str, Union[List[str], str]]]], str
] = ...,
change_message: Any = ...,
) -> LogEntry: ...
class LogEntry(models.Model):
content_type_id: int
id: None
user_id: int
action_time: datetime.datetime = ...
user: Any = ...
content_type: Any = ...
object_id: str = ...
object_repr: str = ...
action_flag: int = ...
change_message: str = ...
objects: Any = ...
class Meta:
verbose_name: Any = ...
verbose_name_plural: Any = ...
db_table: str = ...
ordering: Any = ...
action_time: models.DateTimeField = ...
user: models.ForeignKey = ...
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id: models.TextField = ...
object_repr: models.CharField = ...
action_flag: models.PositiveSmallIntegerField = ...
change_message: models.TextField = ...
objects: LogEntryManager = ...
def is_addition(self) -> bool: ...
def is_change(self) -> bool: ...
def is_deletion(self) -> bool: ...

View File

@@ -1,6 +1,7 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union, Iterator
from django.contrib.admin.filters import ListFilter
from django.contrib.admin.models import LogEntry
from django.contrib.admin.sites import AdminSite
from django.contrib.admin.views.main import ChangeList
@@ -56,28 +57,29 @@ class BaseModelAdmin:
checks_class: Any = ...
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
def __init__(self) -> None: ...
def formfield_for_dbfield(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> Optional[Field]: ...
def formfield_for_choice_field(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> TypedChoiceField: ...
def get_field_queryset(self, db: None, db_field: RelatedField, request: WSGIRequest) -> Optional[QuerySet]: ...
def formfield_for_dbfield(
self, db_field: Field, request: Optional[WSGIRequest], **kwargs: Any
) -> Optional[Field]: ...
def formfield_for_choice_field(
self, db_field: Field, request: Optional[WSGIRequest], **kwargs: Any
) -> TypedChoiceField: ...
def get_field_queryset(
self, db: None, db_field: RelatedField, request: Optional[WSGIRequest]
) -> Optional[QuerySet]: ...
def formfield_for_foreignkey(
self, db_field: ForeignKey, request: WSGIRequest, **kwargs: Any
self, db_field: ForeignKey, request: Optional[WSGIRequest], **kwargs: Any
) -> Optional[ModelChoiceField]: ...
def formfield_for_manytomany(
self, db_field: ManyToManyField, request: WSGIRequest, **kwargs: Any
self, db_field: ManyToManyField, request: Optional[WSGIRequest], **kwargs: Any
) -> ModelMultipleChoiceField: ...
def get_autocomplete_fields(self, request: WSGIRequest) -> Tuple: ...
def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ...
def get_empty_value_display(self) -> SafeText: ...
def get_exclude(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
def get_fields(
self, request: WSGIRequest, obj: Optional[Model] = ...
) -> Union[List[Union[Callable, str]], Tuple[str, str]]: ...
def get_exclude(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Any: ...
def get_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Sequence[Union[Callable, str]]: ...
def get_fieldsets(
self, request: WSGIRequest, obj: Optional[Model] = ...
) -> Union[
List[Tuple[None, Dict[str, List[Union[Callable, str]]]]],
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
]: ...
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
def get_readonly_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
def get_prepopulated_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
@@ -85,7 +87,7 @@ class BaseModelAdmin:
def get_sortable_by(self, request: WSGIRequest) -> Union[List[Callable], List[str], Tuple]: ...
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
def to_field_allowed(self, request: WSGIRequest, to_field: str) -> bool: ...
def has_add_permission(self, request: WSGIRequest) -> bool: ...
def has_add_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_change_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
@@ -93,21 +95,21 @@ class BaseModelAdmin:
class ModelAdmin(BaseModelAdmin):
formfield_overrides: Any
list_display: Sequence[str] = ...
list_display_links: Sequence[str] = ...
list_filter: Sequence[str] = ...
list_select_related: Sequence[str] = ...
list_display: Sequence[Union[str, Callable]] = ...
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
list_select_related: Union[bool, Sequence[str]] = ...
list_per_page: int = ...
list_max_show_all: int = ...
list_editable: Sequence[str] = ...
search_fields: Any = ...
date_hierarchy: Any = ...
search_fields: Sequence[str] = ...
date_hierarchy: Optional[Any] = ...
save_as: bool = ...
save_as_continue: bool = ...
save_on_top: bool = ...
paginator: Any = ...
preserve_filters: bool = ...
inlines: Any = ...
inlines: Sequence[Type[InlineModelAdmin]] = ...
add_form_template: Any = ...
change_form_template: Any = ...
change_list_template: Any = ...
@@ -138,7 +140,7 @@ class ModelAdmin(BaseModelAdmin):
def get_object(self, request: WSGIRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
def get_changelist_form(self, request: Any, **kwargs: Any): ...
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
def get_formsets_with_inlines(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
def get_formsets_with_inlines(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Iterator[Any]: ...
def get_paginator(
self,
request: WSGIRequest,
@@ -147,18 +149,8 @@ class ModelAdmin(BaseModelAdmin):
orphans: int = ...,
allow_empty_first_page: bool = ...,
) -> Paginator: ...
def log_addition(
self,
request: WSGIRequest,
object: Model,
message: Union[Dict[str, Dict[Any, Any]], List[Dict[str, Dict[str, str]]]],
) -> LogEntry: ...
def log_change(
self,
request: WSGIRequest,
object: Model,
message: Union[Dict[str, Dict[str, List[str]]], List[Dict[str, Dict[str, Union[List[str], str]]]]],
) -> LogEntry: ...
def log_addition(self, request: WSGIRequest, object: Model, message: Any) -> LogEntry: ...
def log_change(self, request: WSGIRequest, object: Model, message: Any) -> LogEntry: ...
def log_deletion(self, request: WSGIRequest, object: Model, object_repr: str) -> LogEntry: ...
def action_checkbox(self, obj: Model) -> SafeText: ...
def get_actions(self, request: WSGIRequest) -> OrderedDict: ...

View File

@@ -32,7 +32,7 @@ def result_list(
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
]: ...
def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Union[Dict[str, str], List[Dict[str, str]], bool]]]: ...
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Any]]: ...
def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ...
def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Optional
from typing import Any, Callable, Dict, List
from django.template.base import Parser, Token
from django.template.context import Context

View File

@@ -1,5 +1,6 @@
import collections
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
from uuid import UUID
from django.contrib.admin.options import BaseModelAdmin
@@ -8,28 +9,23 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.deletion import Collector
from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, OneToOneRel
from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.forms import BaseForm
from django.utils.safestring import SafeText
from django.db.models.fields import Field, reverse_related
class FieldIsAForeignKeyColumnName(Exception): ...
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
def prepare_lookup_value(key: str, value: Union[datetime, str]) -> Union[bool, datetime, str]: ...
def quote(s: Union[int, str, UUID]) -> Union[int, str, UUID]: ...
def quote(s: Union[int, str, UUID]) -> str: ...
def unquote(s: str) -> str: ...
def flatten(
fields: Union[List[Union[Callable, str]], List[Union[List[str], str]], List[Union[Tuple[str, str], str]], Tuple]
) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(
fieldsets: Union[
List[Tuple[Optional[str], Dict[str, Tuple[str]]]],
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
]
) -> List[Union[Callable, str]]: ...
def flatten(fields: Any) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
def get_deleted_objects(
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
@@ -47,7 +43,7 @@ class NestedObjects(Collector):
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
def collect(
self,
objs: Union[List[Model], QuerySet],
objs: Union[Sequence[Optional[Model]], QuerySet],
source: Optional[Type[Model]] = ...,
source_attr: Optional[str] = ...,
**kwargs: Any
@@ -62,7 +58,11 @@ def lookup_field(
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
) -> Tuple[Optional[Field], Callable, Callable]: ...
def label_for_field(
name: Union[Callable, str], model: Type[Model], model_admin: Optional[BaseModelAdmin] = ..., return_attr: bool = ...
name: Union[Callable, str],
model: Type[Model],
model_admin: Optional[BaseModelAdmin] = ...,
return_attr: bool = ...,
form: Optional[BaseForm] = ...,
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
def help_text_for_field(name: str, model: Type[Model]) -> str: ...
def display_for_field(

View File

@@ -1,9 +1,13 @@
from typing import Any, Dict, List, Optional, Tuple, Type
from typing import Any, Dict, List, Optional, Tuple, Type, Union
from django.contrib.auth.models import User, Group
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.fields import Field
from django.db.models.fields.related import ManyToManyField
from django.db.models.options import Options
from django.forms.models import ModelMultipleChoiceField
from django.forms.fields import Field as FormField
from django.forms.widgets import Widget
from django.http.response import HttpResponse
from django.urls.resolvers import URLPattern
@@ -27,10 +31,7 @@ class GroupAdmin(admin.ModelAdmin):
class UserAdmin(admin.ModelAdmin):
admin_site: AdminSite
formfield_overrides: Dict[
Type[Union[django.db.models.fields.DateTimeCheckMixin, Field]],
Dict[str, Type[Union[django.forms.fields.SplitDateTimeField, Widget]]],
]
formfield_overrides: Dict[Type[Field], Dict[str, Type[Union[FormField, Widget]]]]
model: Type[User]
opts: Options
add_form_template: str = ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Tuple, List
from typing import Any, Optional, Tuple, List, overload
from django.db import models
@@ -13,6 +13,7 @@ class AbstractBaseUser(models.Model):
last_login: Optional[models.DateTimeField] = ...
is_active: models.BooleanField = ...
REQUIRED_FIELDS: List[str] = ...
class Meta: ...
def get_username(self) -> str: ...
def clean(self) -> None: ...
def save(self, *args: Any, **kwargs: Any) -> None: ...
@@ -29,4 +30,8 @@ class AbstractBaseUser(models.Model):
@classmethod
def get_email_field_name(cls) -> str: ...
@classmethod
@overload
def normalize_username(cls, username: str) -> str: ...
@classmethod
@overload
def normalize_username(cls, username: Any) -> Any: ...

View File

@@ -1,5 +1,7 @@
from typing import Any, Callable, List, Optional, Set, Union
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME
def user_passes_test(
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
) -> Callable: ...

View File

@@ -42,10 +42,6 @@ class UserCreationForm(forms.ModelForm):
error_messages: Any = ...
password1: Any = ...
password2: Any = ...
class Meta:
model: Any = ...
fields: Any = ...
field_classes: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> User: ...
@@ -62,10 +58,6 @@ class UserChangeForm(forms.ModelForm):
is_bound: bool
label_suffix: str
password: Any = ...
class Meta:
model: Any = ...
fields: str = ...
field_classes: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password(self) -> str: ...

View File

@@ -13,8 +13,8 @@ class AuthenticationMiddleware(MiddlewareMixin):
class RemoteUserMiddleware(MiddlewareMixin):
header: str = ...
force_logout_if_no_header: bool = ...
def process_request(self, request: WSGIRequest) -> None: ...
def clean_username(self, username: str, request: WSGIRequest) -> str: ...
def process_request(self, request: HttpRequest) -> None: ...
def clean_username(self, username: str, request: HttpRequest) -> str: ...
class PersistentRemoteUserMiddleware(RemoteUserMiddleware):
force_logout_if_no_header: bool = ...

View File

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

View File

@@ -1,46 +1,33 @@
import datetime
from typing import Any, List, Optional, Set, Tuple, Type, Union
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
from django.contrib.contenttypes.models import ContentType
from django.db.models.manager import EmptyManager
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.db import models
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
class PermissionManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
class Permission(models.Model):
content_type_id: int
id: int
name: str = ...
content_type: Any = ...
codename: str = ...
name: models.CharField = ...
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename: models.CharField = ...
def natural_key(self) -> Tuple[str, str, str]: ...
class GroupManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_by_natural_key(self, name: str) -> Group: ...
class Group(models.Model):
id: None
name: str = ...
permissions: Any = ...
name: models.CharField = ...
permissions: models.ManyToManyField = models.ManyToManyField(Permission)
def natural_key(self): ...
class UserManager(BaseUserManager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def create_user(
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> AbstractUser: ...
@@ -49,24 +36,23 @@ class UserManager(BaseUserManager):
) -> AbstractBaseUser: ...
class PermissionsMixin(models.Model):
is_superuser: Any = ...
groups: Any = ...
user_permissions: Any = ...
is_superuser: models.BooleanField = ...
groups: models.ManyToManyField = models.ManyToManyField(Group)
user_permissions: models.ManyToManyField = models.ManyToManyField(Permission)
def get_group_permissions(self, obj: None = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Optional[str] = ...) -> Set[str]: ...
def has_perm(self, perm: Union[Tuple[str, Any], str], obj: Optional[str] = ...) -> bool: ...
def has_perms(self, perm_list: Union[List[str], Set[str], Tuple[str]], obj: None = ...) -> bool: ...
def has_module_perms(self, app_label: str) -> bool: ...
class AbstractUser(AbstractBaseUser, PermissionsMixin):
is_superuser: bool
username_validator: Any = ...
username: str = ...
first_name: str = ...
last_name: str = ...
email: str = ...
is_staff: bool = ...
date_joined: datetime.datetime = ...
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
username_validator: UnicodeUsernameValidator = ...
username: models.CharField = ...
first_name: models.CharField = ...
last_name: models.CharField = ...
email: models.EmailField = ...
is_staff: models.BooleanField = ...
date_joined: models.DateTimeField = ...
EMAIL_FIELD: str = ...
USERNAME_FIELD: str = ...
def clean(self) -> None: ...

View File

@@ -1,46 +1,46 @@
from pathlib import PosixPath
from typing import Any, Dict, List, Optional, Tuple, Union
from pathlib import Path, PosixPath
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import User
def get_default_password_validators() -> Union[
List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]
]: ...
def get_password_validators(
validator_config: List[Dict[str, Union[Dict[str, int], str]]]
) -> Union[List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]]: ...
class PasswordValidator(Protocol):
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...): ...
def get_default_password_validators() -> List[PasswordValidator]: ...
def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ...
def validate_password(
password: str, user: Optional[AbstractBaseUser] = ..., password_validators: Optional[List[Any]] = ...
password: str,
user: Optional[AbstractBaseUser] = ...,
password_validators: Optional[Sequence[PasswordValidator]] = ...,
) -> None: ...
def password_changed(
password: str, user: Optional[AbstractBaseUser] = ..., password_validators: None = ...
password: str,
user: Optional[AbstractBaseUser] = ...,
password_validators: Optional[Sequence[PasswordValidator]] = ...,
) -> None: ...
def password_validators_help_texts(password_validators: Optional[List[Any]] = ...) -> List[str]: ...
def password_validators_help_texts(password_validators: Optional[Sequence[PasswordValidator]] = ...) -> List[str]: ...
password_validators_help_text_html: Any
class MinimumLengthValidator:
min_length: int = ...
def __init__(self, min_length: int = ...) -> None: ...
def validate(self, password: str, user: Optional[User] = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
def get_help_text(self) -> str: ...
class UserAttributeSimilarityValidator:
DEFAULT_USER_ATTRIBUTES: Any = ...
user_attributes: Tuple[str, str, str, str] = ...
DEFAULT_USER_ATTRIBUTES: Sequence[str] = ...
user_attributes: Sequence[str] = ...
max_similarity: float = ...
def __init__(
self, user_attributes: Union[List[str], Tuple[str, str, str, str]] = ..., max_similarity: float = ...
) -> None: ...
def validate(self, password: str, user: Optional[User] = ...) -> None: ...
def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
def get_help_text(self) -> str: ...
class CommonPasswordValidator:
DEFAULT_PASSWORD_LIST_PATH: Any = ...
DEFAULT_PASSWORD_LIST_PATH: Path = ...
passwords: Set[str] = ...
def __init__(self, password_list_path: Union[PosixPath, str] = ...) -> None: ...
def validate(self, password: str, user: None = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
def get_help_text(self) -> str: ...
class NumericPasswordValidator:

View File

@@ -0,0 +1,4 @@
from django.core import validators
class ASCIIUsernameValidator(validators.RegexValidator): ...
class UnicodeUsernameValidator(validators.RegexValidator): ...

View File

@@ -32,9 +32,7 @@ class LoginView(SuccessURLAllowedHostsMixin, FormView):
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, Union[AuthenticationForm, LoginView, Site, RequestSite, str]]: ...
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ...
class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
next_page: Any = ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Generic
from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import Error
@@ -51,7 +51,7 @@ class GenericForeignKey(FieldCacheMixin):
class GenericRel(ForeignObjectRel):
field: GenericRelation
limit_choices_to: Dict[Any, Any]
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]]
model: Type[Model]
multiple: bool
on_delete: Callable
@@ -65,7 +65,7 @@ class GenericRel(ForeignObjectRel):
to: Union[Type[Model], str],
related_name: None = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: None = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
) -> None: ...
class GenericRelation(ForeignObject):
@@ -87,7 +87,7 @@ class GenericRelation(ForeignObject):
content_type_field: str = ...,
for_concrete_model: bool = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: None = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...

View File

@@ -4,12 +4,7 @@ from django.db import models
from django.db.models.base import Model
from django.db.models.query import QuerySet
class ContentTypeManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class ContentTypeManager(models.Manager["ContentType"]):
def get_by_natural_key(self, app_label: str, model: str) -> ContentType: ...
def get_for_model(self, model: Union[Type[Model], Model], for_concrete_model: bool = ...) -> ContentType: ...
def get_for_models(self, *models: Any, for_concrete_models: bool = ...) -> Dict[Type[Model], ContentType]: ...
@@ -18,14 +13,9 @@ class ContentTypeManager(models.Manager):
class ContentType(models.Model):
id: int
app_label: str = ...
model: str = ...
objects: Any = ...
class Meta:
verbose_name: Any = ...
verbose_name_plural: Any = ...
db_table: str = ...
unique_together: Any = ...
app_label: models.CharField = ...
model: models.CharField = ...
objects: ContentTypeManager = ...
@property
def name(self) -> str: ...
def model_class(self) -> Optional[Type[Model]]: ...

View File

@@ -15,8 +15,5 @@ class FlatpageForm(forms.ModelForm):
is_bound: bool
label_suffix: str
url: Any = ...
class Meta:
model: Any = ...
fields: str = ...
def clean_url(self) -> str: ...
def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ...

View File

@@ -1,19 +1,13 @@
from typing import Any, Optional
from django.contrib.sites.models import Site
from django.db import models
class FlatPage(models.Model):
id: None
url: str = ...
title: str = ...
content: str = ...
enable_comments: bool = ...
template_name: str = ...
registration_required: bool = ...
sites: Any = ...
class Meta:
db_table: str = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
ordering: Any = ...
url: models.CharField = ...
title: models.CharField = ...
content: models.TextField = ...
enable_comments: models.BooleanField = ...
template_name: models.CharField = ...
registration_required: models.BooleanField = ...
sites: models.ManyToManyField[Site] = ...
def get_absolute_url(self) -> str: ...

View File

@@ -1 +1,24 @@
from .api import get_level as get_level, set_level as set_level
from .api import (
get_level as get_level,
set_level as set_level,
add_message as add_message,
debug as debug,
error as error,
success as success,
get_messages as get_messages,
MessageFailure as MessageFailure,
info as info,
warning as warning,
)
from .constants import (
DEBUG as DEBUG,
DEFAULT_LEVELS as DEFAULT_LEVELS,
DEFAULT_TAGS as DEFAULT_TAGS,
ERROR as ERROR,
INFO as INFO,
SUCCESS as SUCCESS,
WARNING as WARNING,
)
default_app_config: str = ...

View File

@@ -1,8 +1,7 @@
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class MessageMiddleware(MiddlewareMixin):
def process_request(self, request: WSGIRequest) -> None: ...
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
def process_request(self, request: HttpRequest) -> None: ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...

View File

@@ -8,3 +8,4 @@ from .ranges import (
DateRangeField as DateRangeField,
DateTimeRangeField as DateTimeRangeField,
)
from .hstore import HStoreField as HStoreField

View File

@@ -1,26 +1,51 @@
from typing import Any, Dict, List, Optional, Tuple, Union, TypeVar, Generic, Sequence
from typing import Any, Iterable, List, Optional, Sequence, TypeVar, Union
from django.db.models.expressions import Combinable
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
from django.db.models.fields import Field
from .mixins import CheckFieldDefaultMixin
_T = TypeVar("_T", bound=Field)
# __set__ value type
_ST = TypeVar("_ST")
# __get__ return type
_GT = TypeVar("_GT")
class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]):
_pyi_private_set_type: Union[Sequence[Any], Combinable]
_pyi_private_get_type: List[Any]
class ArrayField(CheckFieldDefaultMixin, Field, Generic[_T]):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
base_field: Any = ...
size: Any = ...
default_validators: Any = ...
from_db_value: Any = ...
def __init__(self, base_field: _T, size: None = ..., **kwargs: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def __init__(
self,
base_field: Field,
size: Optional[int] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
) -> None: ...
@property
def description(self): ...
def get_db_prep_value(self, value: Any, connection: Any, prepared: bool = ...): ...
def to_python(self, value: Any): ...
def value_to_string(self, obj: Any): ...
def get_transform(self, name: Any): ...
def validate(self, value: Any, model_instance: Any) -> None: ...
def run_validators(self, value: Any) -> None: ...
def __set__(self, instance, value: Sequence[_T]): ...
def __get__(self, instance, owner) -> List[_T]: ...

View File

@@ -0,0 +1,17 @@
from typing import Any
from django.db.models import Field, Transform
from .mixins import CheckFieldDefaultMixin
class HStoreField(CheckFieldDefaultMixin, Field):
def get_transform(self, name) -> Any: ...
class KeyTransform(Transform):
def __init__(self, key_name: str, *args: Any, **kwargs: Any): ...
class KeyTransformFactory:
def __init__(self, key_name: str): ...
def __call__(self, *args, **kwargs) -> KeyTransform: ...
class KeysTransform(Transform): ...
class ValuesTransform(Transform): ...

View File

@@ -2,6 +2,8 @@ from typing import Any
from django.db import models
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange # type: ignore
class RangeField(models.Field):
empty_strings_allowed: bool = ...
base_field: Any = ...
@@ -10,8 +12,17 @@ class RangeField(models.Field):
def to_python(self, value: Any): ...
def value_to_string(self, obj: Any): ...
class IntegerRangeField(RangeField): ...
class BigIntegerRangeField(RangeField): ...
class FloatRangeField(RangeField): ...
class DateTimeRangeField(RangeField): ...
class DateRangeField(RangeField): ...
class IntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class BigIntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class FloatRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class DateTimeRangeField(RangeField):
def __get__(self, instance, owner) -> DateTimeTZRange: ...
class DateRangeField(RangeField):
def __get__(self, instance, owner) -> DateRange: ...

View File

@@ -1,16 +1,6 @@
from typing import Any, Optional
from django.db import models
class Redirect(models.Model):
id: None
site_id: int
site: Any = ...
old_path: str = ...
new_path: str = ...
class Meta:
verbose_name: Any = ...
verbose_name_plural: Any = ...
db_table: str = ...
unique_together: Any = ...
ordering: Any = ...
site: models.ForeignKey = ...
old_path: models.CharField = ...
new_path: models.CharField = ...

View File

@@ -8,26 +8,18 @@ VALID_KEY_CHARS: Any
class CreateError(Exception): ...
class UpdateError(Exception): ...
class SessionBase:
class SessionBase(Dict[str, Any]):
TEST_COOKIE_NAME: str = ...
TEST_COOKIE_VALUE: str = ...
accessed: bool = ...
modified: bool = ...
serializer: Any = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ...
def __contains__(self, key: str) -> bool: ...
def __getitem__(self, key: str) -> Any: ...
def __setitem__(self, key: str, value: Any) -> None: ...
def __delitem__(self, key: str) -> None: ...
def get(self, key: str, default: Optional[str] = ...) -> Any: ...
def pop(self, key: str, default: Any = ...) -> Any: ...
def setdefault(self, key: str, value: str) -> str: ...
def set_test_cookie(self) -> None: ...
def test_cookie_worked(self) -> bool: ...
def delete_test_cookie(self) -> None: ...
def encode(self, session_dict: Dict[str, Model]) -> str: ...
def decode(self, session_data: Union[bytes, str]) -> Dict[str, Model]: ...
def update(self, dict_: Dict[str, int]) -> None: ...
def has_key(self, key: Any): ...
def keys(self): ...
def values(self): ...

View File

@@ -1,13 +1,14 @@
from typing import Any, Dict, Optional, Type, Union
from typing import Dict, Optional, Type, Union
from django.contrib.sessions.backends.base import SessionBase
from django.contrib.sessions.base_session import AbstractBaseSession
from django.contrib.sessions.models import Session
from django.core.signing import Serializer
from django.db.models.base import Model
class SessionStore(SessionBase):
accessed: bool
serializer: Type[django.core.signing.JSONSerializer]
serializer: Type[Serializer]
def __init__(self, session_key: Optional[str] = ...) -> None: ...
@classmethod
def get_model_class(cls) -> Type[Session]: ...

View File

@@ -15,10 +15,6 @@ class AbstractBaseSession(models.Model):
session_data: Any = ...
expire_date: Any = ...
objects: Any = ...
class Meta:
abstract: bool = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
@classmethod
def get_session_store_class(cls) -> None: ...
def get_decoded(self) -> Dict[str, int]: ...

View File

@@ -1,11 +1,11 @@
from typing import Type
from django.contrib.sessions.backends.base import SessionBase
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class SessionMiddleware(MiddlewareMixin):
SessionStore: Type[SessionBase] = ...
def process_request(self, request: WSGIRequest) -> None: ...
def process_response(self, request: WSGIRequest, response: HttpResponse) -> HttpResponse: ...
def process_request(self, request: HttpRequest) -> None: ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...

View File

@@ -16,5 +16,3 @@ class Session(AbstractBaseSession):
objects: Any = ...
@classmethod
def get_session_store_class(cls) -> Type[SessionStore]: ...
class Meta(AbstractBaseSession.Meta):
db_table: str = ...

View File

@@ -7,24 +7,14 @@ from django.db import models
SITE_CACHE: Any
class SiteManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_current(self, request: Optional[HttpRequest] = ...) -> Site: ...
def clear_cache(self) -> None: ...
def get_by_natural_key(self, domain: str) -> Site: ...
class Site(models.Model):
id: int
domain: str = ...
name: str = ...
objects: Any = ...
class Meta:
db_table: str = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
ordering: Any = ...
domain: models.CharField = ...
name: models.CharField = ...
objects: SiteManager = ...
def natural_key(self) -> Tuple[str]: ...
def clear_site_cache(sender: Type[Site], **kwargs: Any) -> None: ...

View File

@@ -1,8 +1,9 @@
from typing import Any, Iterator, List, Optional, Tuple, Union
from typing import Any, Iterator, List, Optional, Tuple, Union, Mapping, overload
from django.contrib.staticfiles.storage import StaticFilesStorage
from django.core.checks.messages import Error
from django.core.files.storage import DefaultStorage, FileSystemStorage
from django.core.files.storage import DefaultStorage, FileSystemStorage, Storage
from typing_extensions import Literal
searched_locations: Any
@@ -13,7 +14,7 @@ class BaseFinder:
class FileSystemFinder(BaseFinder):
locations: List[Any] = ...
storages: collections.OrderedDict = ...
storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
@@ -24,22 +25,27 @@ class AppDirectoriesFinder(BaseFinder):
storage_class: Any = ...
source_dir: str = ...
apps: List[str] = ...
storages: collections.OrderedDict = ...
storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ...
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
def find_in_app(self, app: str, path: str) -> Optional[str]: ...
class BaseStorageFinder(BaseFinder):
storage: Any = ...
def __init__(self, storage: Optional[StaticFilesStorage] = ..., *args: Any, **kwargs: Any) -> None: ...
storage: Storage = ...
def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ...
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, DefaultStorage]]: ...
class DefaultStorageFinder(BaseStorageFinder):
storage: django.contrib.staticfiles.storage.StaticFilesStorage = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class DefaultStorageFinder(BaseStorageFinder): ...
def find(path: str, all: bool = ...) -> Optional[Union[List[str], str]]: ...
def get_finders() -> Iterator[BaseFinder]: ...
@overload
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
@overload
def get_finder(
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"]
) -> AppDirectoriesFinder: ...
@overload
def get_finder(import_path: str) -> BaseFinder: ...

View File

@@ -23,5 +23,5 @@ class Feed:
def feed_extra_kwargs(self, obj: None) -> Dict[Any, Any]: ...
def item_extra_kwargs(self, item: Model) -> Dict[Any, Any]: ...
def get_object(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> None: ...
def get_context_data(self, **kwargs: Any) -> Dict[str, Model]: ...
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ...
def get_feed(self, obj: None, request: WSGIRequest) -> SyndicationFeed: ...

View File

@@ -1,6 +1,5 @@
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
from typing import Any, Dict, Iterator, List, Mapping, Optional, Tuple, Union
from django.db.models.base import Model
from django.forms.utils import ErrorDict
class FieldDoesNotExist(Exception): ...
@@ -31,20 +30,13 @@ class ValidationError(Exception):
message: Any = ...
code: Any = ...
params: Any = ...
def __init__(
self,
message: Any,
code: Optional[str] = ...,
params: Optional[
Union[Dict[str, Union[Tuple[str], Type[Model], Model, str]], Dict[str, Union[int, str]]]
] = ...,
) -> None: ...
def __init__(self, message: Any, code: Optional[str] = ..., params: Optional[Mapping[str, Any]] = ...) -> None: ...
@property
def message_dict(self) -> Dict[str, List[str]]: ...
@property
def messages(self) -> List[str]: ...
def update_error_dict(
self, error_dict: Union[Dict[str, List[ValidationError]], ErrorDict]
self, error_dict: Mapping[str, Any]
) -> Union[Dict[str, List[ValidationError]], ErrorDict]: ...
def __iter__(self) -> Iterator[Union[Tuple[str, List[str]], str]]: ...

View File

@@ -1,45 +1,48 @@
# Stubs for django.core.files.uploadedfile (Python 3.5)
from typing import Any, Dict, IO, Iterator, Optional, Union
from django.core.files import temp as tempfile
from django.core.files.base import File
class UploadedFile(File):
content_type = ... # type: Optional[str]
charset = ... # type: Optional[str]
content_type_extra = ... # type: Optional[Dict[str, str]]
content_type: Optional[str] = ...
charset: Optional[str] = ...
content_type_extra: Optional[Dict[str, str]] = ...
def __init__(
self,
file: IO,
name: str = None,
content_type: str = None,
size: int = None,
charset: str = None,
content_type_extra: Dict[str, str] = None,
file: Optional[IO] = ...,
name: Optional[str] = ...,
content_type: Optional[str] = ...,
size: Optional[int] = ...,
charset: Optional[str] = ...,
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
class TemporaryUploadedFile(UploadedFile):
def __init__(
self, name: str, content_type: str, size: int, charset: str, content_type_extra: Dict[str, str] = None
self,
name: Optional[str],
content_type: Optional[str],
size: Optional[int],
charset: Optional[str],
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
def temporary_file_path(self) -> str: ...
class InMemoryUploadedFile(UploadedFile):
field_name = ... # type: Optional[str]
field_name: Optional[str] = ...
def __init__(
self,
file: IO,
field_name: Optional[str],
name: str,
name: Optional[str],
content_type: Optional[str],
size: int,
size: Optional[int],
charset: Optional[str],
content_type_extra: Dict[str, str] = None,
content_type_extra: Dict[str, str] = ...,
) -> None: ...
def chunks(self, chunk_size: int = None) -> Iterator[bytes]: ...
def multiple_chunks(self, chunk_size: int = None) -> bool: ...
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
class SimpleUploadedFile(InMemoryUploadedFile):
def __init__(self, name: str, content: bytes, content_type: str = "") -> None: ...
def __init__(self, name: str, content: Optional[Union[bytes, str]], content_type: str = ...) -> None: ...
@classmethod
def from_dict(cls: Any, file_dict: Dict[str, Union[str, bytes]]) -> None: ...

View File

@@ -1,6 +1,6 @@
from argparse import ArgumentParser, HelpFormatter, Namespace
from io import StringIO, TextIOBase, TextIOWrapper
from typing import Any, Callable, List, Optional, Tuple, Union, Type
from typing import Any, Callable, List, Optional, Union
from django.apps.config import AppConfig
from django.core.management.color import Style
@@ -9,17 +9,6 @@ class CommandError(Exception): ...
class SystemCheckError(CommandError): ...
class CommandParser(ArgumentParser):
add_help: bool
allow_abbrev: bool
argument_default: None
conflict_handler: str
description: str
epilog: None
formatter_class: Type[DjangoHelpFormatter]
fromfile_prefix_chars: None
prefix_chars: str
prog: str
usage: None
missing_args_message: None = ...
called_from_command_line: bool = ...
def __init__(self, **kwargs: Any) -> None: ...

View File

@@ -30,7 +30,7 @@ def get_public_serializer_formats() -> List[str]: ...
def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ...
def serialize(
format: str, queryset: Union[Iterator[Any], List[Model], QuerySet], **options: Any
) -> Optional[Union[List[OrderedDict], bytes, str]]: ...
) -> Optional[Union[bytes, str]]: ...
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
def sort_dependencies(
app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]]

View File

@@ -3,7 +3,8 @@ from io import BytesIO
from typing import Any, Dict
from wsgiref import simple_server
from django.core.handlers.wsgi import WSGIRequest
from django.core.handlers.wsgi import WSGIRequest, WSGIHandler
from django.core.wsgi import get_wsgi_application as get_wsgi_application
class WSGIServer(simple_server.WSGIServer):
request_queue_size: int = ...
@@ -31,3 +32,5 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler):
requestline: str = ...
request_version: str = ...
def handle(self) -> None: ...
def get_internal_wsgi_application() -> WSGIHandler: ...

View File

@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Dict, List, Optional, Type, Union
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Type, Union, Protocol
from django.contrib.sessions.serializers import PickleSerializer
@@ -11,38 +11,30 @@ def b64_decode(s: bytes) -> bytes: ...
def base64_hmac(salt: str, value: Union[bytes, str], key: Union[bytes, str]) -> str: ...
def get_cookie_signer(salt: str = ...) -> TimestampSigner: ...
class Serializer(Protocol):
def dumps(self, obj: Any) -> bytes: ...
def loads(self, data: bytes) -> Any: ...
class JSONSerializer:
def dumps(self, obj: Union[Dict[str, Union[int, str]], List[str], str]) -> bytes: ...
def dumps(self, obj: Any) -> bytes: ...
def loads(self, data: bytes) -> Dict[str, Union[int, str]]: ...
def dumps(
obj: Union[Dict[str, Union[datetime, str]], List[str], str],
key: None = ...,
salt: str = ...,
serializer: Type[Union[PickleSerializer, JSONSerializer]] = ...,
compress: bool = ...,
obj: Any, key: None = ..., salt: str = ..., serializer: Type[Serializer] = ..., compress: bool = ...
) -> str: ...
def loads(
s: str,
key: None = ...,
salt: str = ...,
serializer: Type[Union[PickleSerializer, JSONSerializer]] = ...,
max_age: Optional[int] = ...,
) -> Union[Dict[str, Union[datetime, str]], Dict[str, Union[int, str]], List[str], str]: ...
s: str, key: None = ..., salt: str = ..., serializer: Type[Serializer] = ..., max_age: Optional[int] = ...
) -> Any: ...
class Signer:
key: str = ...
sep: str = ...
salt: Any = ...
salt: str = ...
def __init__(self, key: Optional[Union[bytes, str]] = ..., sep: str = ..., salt: Optional[str] = ...) -> None: ...
def signature(self, value: Union[bytes, str]) -> str: ...
def sign(self, value: str) -> str: ...
def unsign(self, signed_value: str) -> str: ...
class TimestampSigner(Signer):
key: str
salt: str
sep: str
def timestamp(self) -> str: ...
def sign(self, value: str) -> str: ...
def unsign(self, value: str, max_age: Optional[int] = ...) -> str: ...
def unsign(self, value: str, max_age: Optional[Union[int, timedelta]] = ...) -> str: ...

View File

@@ -5,6 +5,7 @@ from typing import Any, Dict, List, Optional, Union, Pattern
from uuid import UUID
from django.core.files.base import File
from django.core.exceptions import ValidationError as ValidationError
EMPTY_VALUES: Any

View File

@@ -12,6 +12,8 @@ from .utils import (
InternalError as InternalError,
InterfaceError as InterfaceError,
ConnectionHandler as ConnectionHandler,
Error as Error,
ConnectionDoesNotExist as ConnectionDoesNotExist,
)
from . import migrations

View File

@@ -24,7 +24,7 @@ class DummyNode(Node):
parents: Set[Any]
origin: Any = ...
error_message: Any = ...
def __init__(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
def __init__(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ...
__class__: Any = ...
def promote(self) -> None: ...
def raise_error(self) -> None: ...
@@ -35,7 +35,7 @@ class MigrationGraph:
cached: bool = ...
def __init__(self) -> None: ...
def add_node(self, key: Tuple[str, str], migration: Optional[Migration]) -> None: ...
def add_dummy_node(self, key: Tuple[str, str], origin: Migration, error_message: str) -> None: ...
def add_dummy_node(self, key: Tuple[str, str], origin: Union[Migration, str], error_message: str) -> None: ...
def add_dependency(
self,
migration: Optional[Union[Migration, str]],

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Set, Tuple, Union
from typing import Any, Dict, Optional, Set, Tuple, Union, Sequence
from django.db import DefaultConnectionProxy
from django.db.backends.base.base import BaseDatabaseWrapper
@@ -34,4 +34,6 @@ class MigrationLoader:
def build_graph(self) -> None: ...
def check_consistent_history(self, connection: Any) -> None: ...
def detect_conflicts(self) -> Dict[str, Set[str]]: ...
def project_state(self, nodes: Optional[Tuple[str, str]] = ..., at_end: bool = ...) -> ProjectState: ...
def project_state(
self, nodes: Optional[Tuple[str, str], Sequence[Tuple[str, str]]] = ..., at_end: bool = ...
) -> ProjectState: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from typing import Any, Collection, Dict, List, Optional, Sequence, Tuple, Union
from django.db.migrations.operations.base import Operation
from django.db.models.indexes import Index
@@ -13,17 +13,17 @@ class ModelOperation(Operation):
class CreateModel(ModelOperation):
serialization_expand_args: Any = ...
fields: Any = ...
fields: Sequence[Tuple[str, Field]] = ...
options: Any = ...
bases: Any = ...
managers: Any = ...
bases: Optional[Sequence[Union[type, str]]] = ...
managers: Optional[Sequence[Tuple[str, Manager]]] = ...
def __init__(
self,
name: str,
fields: List[Tuple[str, Field]],
fields: Sequence[Tuple[str, Field]],
options: Optional[Dict[str, Any]] = ...,
bases: Optional[Union[Tuple[Type[Any], ...], Tuple[str, ...]]] = ...,
managers: Optional[List[Tuple[str, Manager]]] = ...,
bases: Optional[Sequence[Union[type, str]]] = ...,
managers: Optional[Sequence[Tuple[str, Manager]]] = ...,
) -> None: ...
def model_to_key(self, model: str) -> List[str]: ...
@@ -45,13 +45,13 @@ class FieldRelatedOptionOperation(ModelOptionOperation): ...
class AlterUniqueTogether(FieldRelatedOptionOperation):
option_name: str = ...
unique_together: Any = ...
def __init__(self, name: str, unique_together: Set[Tuple[str, ...]]) -> None: ...
unique_together: Collection[Sequence[str]] = ...
def __init__(self, name: str, unique_together: Optional[Collection[Sequence[str]]]) -> None: ...
class AlterIndexTogether(FieldRelatedOptionOperation):
option_name: str = ...
index_together: Set[Tuple[str, ...]] = ...
def __init__(self, name: str, index_together: Set[Tuple[str, ...]]) -> None: ...
index_together: Collection[Sequence[str]] = ...
def __init__(self, name: str, index_together: Optional[Collection[Sequence[str]]]) -> None: ...
class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
order_with_respect_to: str = ...
@@ -74,9 +74,9 @@ class IndexOperation(Operation):
class AddIndex(IndexOperation):
model_name: str = ...
index: Index = ...
def __init__(self, model_name: str, index: Index) -> None: ...
def __init__(self, model_name: str, index: Union[str, Index]) -> None: ...
class RemoveIndex(IndexOperation):
model_name: str = ...
name: str = ...
def __init__(self, model_name: str, name: str) -> None: ...
def __init__(self, model_name: str, name: Union[str, Index]) -> None: ...

View File

@@ -1,16 +1,17 @@
from typing import Any, Callable, List, Optional
from typing import Any, Callable, Optional, Sequence, Dict
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.operations.models import CreateModel
from django.db.migrations.state import ProjectState, StateApps
from django.db.migrations.state import StateApps
from .base import Operation
class SeparateDatabaseAndState(Operation):
serialization_expand_args: Any = ...
database_operations: Any = ...
state_operations: Any = ...
def __init__(self, database_operations: List[Any] = ..., state_operations: List[CreateModel] = ...) -> None: ...
database_operations: Sequence[Operation] = ...
state_operations: Sequence[Operation] = ...
def __init__(
self, database_operations: Sequence[Operation] = ..., state_operations: Sequence[Operation] = ...
) -> None: ...
class RunSQL(Operation):
noop: str = ...
@@ -30,17 +31,17 @@ class RunSQL(Operation):
class RunPython(Operation):
reduces_to_sql: bool = ...
atomic: Any = ...
code: Any = ...
reverse_code: Any = ...
hints: Any = ...
elidable: Any = ...
atomic: bool = ...
code: Callable = ...
reverse_code: Optional[Callable] = ...
hints: Optional[Dict[str, Any]] = ...
elidable: bool = ...
def __init__(
self,
code: Callable,
reverse_code: Optional[Callable] = ...,
atomic: Optional[bool] = ...,
hints: None = ...,
hints: Optional[Dict[str, Any]] = ...,
elidable: bool = ...,
) -> None: ...
@staticmethod

View File

@@ -9,10 +9,6 @@ class MigrationRecorder:
app: Any = ...
name: Any = ...
applied: Any = ...
class Meta:
apps: Any = ...
app_label: str = ...
db_table: str = ...
connection: Optional[BaseDatabaseWrapper] = ...
def __init__(self, connection: Optional[BaseDatabaseWrapper]) -> None: ...
@property

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, DefaultDict, Union, Sequence
from django.apps.registry import Apps
from django.db.models.base import Model
@@ -19,13 +19,19 @@ class AppConfigStub:
def import_models(self) -> None: ...
class ModelState:
name: str
app_label: str
fields: List[Tuple[str, Field]]
options: Dict[str, Any] = ...
bases: Tuple[Type[Model]] = ...
managers: List[Tuple[str, Manager]] = ...
def __init__(
self,
app_label: str,
name: str,
fields: List[Tuple[str, Field]],
options: Optional[Dict[str, Any]] = ...,
bases: Optional[Tuple[Type[Model]]] = ...,
bases: Optional[Sequence[Union[Type[Model], str]]] = ...,
managers: Optional[List[Tuple[str, Manager]]] = ...,
) -> None: ...
def clone(self) -> ModelState: ...
@@ -33,9 +39,9 @@ class ModelState:
@classmethod
def from_model(cls, model: Type[Model], exclude_rels: bool = ...) -> ModelState: ...
def get_field_by_name(self, name: str) -> Field: ...
@cached_property
@property
def name_lower(self) -> str: ...
def render(self, apps: StateApps) -> Any: ...
def render(self, apps: Apps) -> Any: ...
class ProjectState:
is_delayed: bool
@@ -45,7 +51,7 @@ class ProjectState:
self, models: Optional[Dict[Tuple[str, str], ModelState]] = ..., real_apps: Optional[List[str]] = ...
) -> None: ...
def add_model(self, model_state: ModelState) -> None: ...
@cached_property
@property
def apps(self) -> StateApps: ...
def clear_delayed_apps_cache(self) -> None: ...
def clone(self) -> ProjectState: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Set, Tuple, Type, List
from typing import Any, Optional, Set, Tuple, Type, List, Union
from django.db.migrations.migration import Migration
from django.db.migrations.operations.base import Operation
@@ -24,7 +24,7 @@ class OperationWriter:
class MigrationWriter:
migration: Migration = ...
needs_manual_porting: bool = ...
def __init__(self, migration: Migration) -> None: ...
def __init__(self, migration: Union[type, Migration]) -> None: ...
def as_string(self) -> str: ...
@property
def basedir(self) -> str: ...

View File

@@ -12,6 +12,7 @@ from .aggregates import (
)
from .fields import (
FieldDoesNotExist as FieldDoesNotExist,
AutoField as AutoField,
IntegerField as IntegerField,
PositiveIntegerField as PositiveIntegerField,
@@ -38,6 +39,7 @@ from .fields import (
BinaryField as BinaryField,
DurationField as DurationField,
BigAutoField as BigAutoField,
CommaSeparatedIntegerField as CommaSeparatedIntegerField,
)
from .fields.related import (
@@ -45,8 +47,17 @@ from .fields.related import (
OneToOneField as OneToOneField,
ManyToManyField as ManyToManyField,
ForeignObject as ForeignObject,
ManyToManyRel as ManyToManyRel,
ManyToOneRel as ManyToOneRel,
OneToOneRel as OneToOneRel,
ForeignObjectRel as ForeignObjectRel,
)
from .fields.files import (
ImageField as ImageField,
FileField as FileField,
FieldFile as FieldFile,
FileDescriptor as FileDescriptor,
)
from .fields.files import ImageField as ImageField, FileField as FileField
from .fields.proxy import OrderWrt as OrderWrt
from .deletion import (

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence, Generic
from django.db.models.manager import Manager
@@ -7,12 +7,12 @@ class ModelBase(type): ...
_Self = TypeVar("_Self", bound="Model")
class Model(metaclass=ModelBase):
class DoesNotExist(Exception):
pass
class DoesNotExist(Exception): ...
class Meta: ...
_meta: Any
_default_manager: Manager[Model]
pk: Any = ...
objects: Manager[Model]
def __init__(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 full_clean(self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...) -> None: ...
def clean_fields(self, exclude: List[str] = ...) -> None: ...
@@ -22,8 +22,16 @@ class Model(metaclass=ModelBase):
force_insert: bool = ...,
force_update: bool = ...,
using: Optional[str] = ...,
update_fields: Optional[Union[List[str], str]] = ...,
update_fields: Optional[Union[Sequence[str], str]] = ...,
) -> None: ...
def save_base(
self,
raw: bool = ...,
force_insert: bool = ...,
force_update: bool = ...,
using: Optional[str] = ...,
update_fields: Optional[Union[Sequence[str], str]] = ...,
): ...
def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> _Self: ...
def get_deferred_fields(self) -> Set[str]: ...

View File

@@ -10,3 +10,4 @@ def PROTECT(collector, field, sub_objs, using): ...
def SET(value: Any) -> Callable: ...
class ProtectedError(IntegrityError): ...
class Collector: ...

View File

@@ -168,12 +168,12 @@ class RawSQL(Expression):
def __init__(self, sql: str, params: Sequence[Any], output_field: Optional[_OutputField] = ...) -> None: ...
class Func(SQLiteNumericMixin, Expression):
function: Any = ...
function: str = ...
template: str = ...
arg_joiner: str = ...
arity: Any = ...
arity: int = ...
source_expressions: List[Expression] = ...
extra: Any = ...
extra: Dict[Any, Any] = ...
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: ...

View File

@@ -1,28 +1,42 @@
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type
import decimal
import uuid
from datetime import date, datetime, time, timedelta
from typing import Any, Callable, Dict, Generic, Iterable, Optional, Tuple, Type, TypeVar, Union
from django.db.models import Model
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
from django.db.models.expressions import Combinable
from django.db.models.query_utils import RegisterLookupMixin
from django.forms import Field as FormField, Widget
from django.db.models.expressions import F, Combinable
from django.forms import Widget, Field as FormField
from .mixins import NOT_PROVIDED as NOT_PROVIDED
_Choice = Tuple[Any, str]
_Choice = Tuple[Any, Any]
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
_ValidatorCallable = Callable[..., None]
_ErrorMessagesToOverride = Dict[str, Any]
class Field(RegisterLookupMixin):
# __set__ value type
_ST = TypeVar("_ST")
# __get__ return type
_GT = TypeVar("_GT")
class Field(RegisterLookupMixin, Generic[_ST, _GT]):
_pyi_private_set_type: Any
_pyi_private_get_type: Any
widget: Widget
help_text: str
db_table: str
remote_field: Field
max_length: Optional[int]
model: Type[Model]
name: str
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
@@ -44,32 +58,40 @@ class Field(RegisterLookupMixin):
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
def __get__(self, instance, owner) -> Any: ...
def __set__(self, instance, value: _ST) -> None: ...
def __get__(self, instance, owner) -> _GT: ...
def deconstruct(self) -> Any: ...
def set_attributes_from_name(self, name: str) -> None: ...
def db_type(self, connection: Any) -> str: ...
def db_parameters(self, connection: Any) -> Dict[str, str]: ...
def get_prep_value(self, value: Any) -> Any: ...
def get_internal_type(self) -> str: ...
def formfield(self, **kwargs) -> FormField: ...
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
def to_python(self, value: Any) -> Any: ...
class IntegerField(Field):
def __set__(self, instance, value: Union[int, F]) -> None: ...
def __get__(self, instance, owner) -> int: ...
class IntegerField(Field[_ST, _GT]):
_pyi_private_set_type: Union[float, int, str, Combinable]
_pyi_private_get_type: int
class PositiveIntegerRelDbTypeMixin:
def rel_db_type(self, connection: Any): ...
class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField): ...
class SmallIntegerField(IntegerField): ...
class BigIntegerField(IntegerField): ...
class FloatField(Field): ...
class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_ST, _GT]): ...
class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_ST, _GT]): ...
class SmallIntegerField(IntegerField[_ST, _GT]): ...
class BigIntegerField(IntegerField[_ST, _GT]): ...
class DecimalField(IntegerField):
class FloatField(Field[_ST, _GT]):
_pyi_private_set_type: Union[float, int, str, Combinable]
_pyi_private_get_type: float
class DecimalField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, float, decimal.Decimal, Combinable]
_pyi_private_get_type: decimal.Decimal
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
max_digits: Optional[int] = ...,
decimal_places: Optional[int] = ...,
@@ -90,13 +112,16 @@ class DecimalField(IntegerField):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class AutoField(Field):
def __get__(self, instance, owner) -> int: ...
class AutoField(Field[_ST, _GT]):
_pyi_private_set_type: Union[Combinable, int, str]
_pyi_private_get_type: int
class CharField(Field):
class CharField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, int, Combinable]
_pyi_private_get_type: str
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
@@ -118,13 +143,11 @@ class CharField(Field):
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
def __set__(self, instance, value: Union[str, Combinable]) -> None: ...
def __get__(self, instance, owner) -> str: ...
class SlugField(CharField):
class SlugField(CharField[_ST, _GT]):
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
@@ -148,25 +171,29 @@ class SlugField(CharField):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class EmailField(CharField): ...
class URLField(CharField): ...
class EmailField(CharField[_ST, _GT]): ...
class URLField(CharField[_ST, _GT]): ...
class TextField(Field):
def __set__(self, instance, value: str) -> None: ...
def __get__(self, instance, owner) -> str: ...
class TextField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, Combinable]
_pyi_private_get_type: str
class BooleanField(Field):
def __set__(self, instance, value: bool) -> None: ...
def __get__(self, instance, owner) -> bool: ...
class BooleanField(Field[_ST, _GT]):
_pyi_private_set_type: Union[bool, Combinable]
_pyi_private_get_type: bool
class NullBooleanField(Field):
def __set__(self, instance, value: Optional[bool]) -> None: ...
def __get__(self, instance, owner) -> Optional[bool]: ...
class NullBooleanField(Field[_ST, _GT]):
_pyi_private_set_type: Optional[Union[bool, Combinable]]
_pyi_private_get_type: Optional[bool]
class FileField(Field): ...
class IPAddressField(Field): ...
class IPAddressField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, Combinable]
_pyi_private_get_type: str
class GenericIPAddressField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, int, Callable[..., Any], Combinable]
_pyi_private_get_type: str
class GenericIPAddressField(Field):
default_error_messages: Any = ...
unpack_ipv4: Any = ...
protocol: Any = ...
@@ -195,10 +222,12 @@ class GenericIPAddressField(Field):
class DateTimeCheckMixin: ...
class DateField(DateTimeCheckMixin, Field):
class DateField(DateTimeCheckMixin, Field[_ST, _GT]):
_pyi_private_set_type: Union[str, date, Combinable]
_pyi_private_get_type: date
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
auto_now: bool = ...,
auto_now_add: bool = ...,
@@ -220,10 +249,12 @@ class DateField(DateTimeCheckMixin, Field):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class TimeField(DateTimeCheckMixin, Field):
class TimeField(DateTimeCheckMixin, Field[_ST, _GT]):
_pyi_private_set_type: Union[str, time, datetime, Combinable]
_pyi_private_get_type: time
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
auto_now: bool = ...,
auto_now_add: bool = ...,
@@ -244,13 +275,22 @@ class TimeField(DateTimeCheckMixin, Field):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class DateTimeField(DateField): ...
class UUIDField(Field): ...
class DateTimeField(DateField[_ST, _GT]):
_pyi_private_get_type: datetime
class FilePathField(Field):
class UUIDField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, uuid.UUID]
_pyi_private_get_type: uuid.UUID
class FilePathField(Field[_ST, _GT]):
path: str = ...
match: Optional[Any] = ...
recursive: bool = ...
allow_files: bool = ...
allow_folders: bool = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
path: str = ...,
match: Optional[Any] = ...,
@@ -275,6 +315,10 @@ class FilePathField(Field):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class BinaryField(Field): ...
class DurationField(Field): ...
class BigAutoField(AutoField): ...
class BinaryField(Field[_ST, _GT]): ...
class DurationField(Field[_ST, _GT]):
_pyi_private_get_type: timedelta
class BigAutoField(AutoField[_ST, _GT]): ...
class CommaSeparatedIntegerField(CharField[_ST, _GT]): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, List, Optional, Type, Union
from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable
from django.core.checks.messages import Error
from django.core.files.base import File
@@ -6,9 +6,11 @@ from django.core.files.images import ImageFile
from django.core.files.storage import FileSystemStorage, Storage
from django.db.models.base import Model
from django.db.models.fields import Field
from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride
from django.forms import fields as form_fields
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
class FieldFile(File):
instance: Model = ...
field: FileField = ...
@@ -29,31 +31,39 @@ class FieldFile(File):
class FileDescriptor:
field: FileField = ...
def __init__(self, field: FileField) -> None: ...
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
class FileField(Field):
attr_class: Any = ...
descriptor_class: Any = ...
description: Any = ...
storage: Any = ...
upload_to: Any = ...
upload_to: Union[str, Callable] = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
upload_to: Union[Callable, str] = ...,
upload_to: Union[str, Callable] = ...,
storage: Optional[Storage] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def deconstruct(self) -> Any: ...
def get_internal_type(self) -> str: ...
def get_prep_value(self, value: Union[FieldFile, str]) -> str: ...
def pre_save(self, model_instance: Model, add: bool) -> FieldFile: ...
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
def save_form_data(self, instance: Model, data: Optional[Union[bool, File, str]]) -> None: ...
def formfield(self, **kwargs: Any) -> form_fields.FileField: ...
class ImageFileDescriptor(FileDescriptor):
field: ImageField
@@ -72,7 +82,4 @@ class ImageField(FileField):
height_field: Optional[str] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def deconstruct(self) -> Any: ...
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
def formfield(self, **kwargs: Any) -> form_fields.ImageField: ...

View File

@@ -29,10 +29,11 @@ from django.db.models.fields.reverse_related import (
ForeignObjectRel as ForeignObjectRel,
ManyToManyRel as ManyToManyRel,
ManyToOneRel as ManyToOneRel,
OneToOneRel as OneToOneRel,
)
from django.db.models.query_utils import PathInfo, Q
from django.db.models.expressions import F
from django.db.models.expressions import Combinable
if TYPE_CHECKING:
from django.db.models.manager import RelatedManager
@@ -48,7 +49,12 @@ _ErrorMessagesToOverride = Dict[str, Any]
RECURSIVE_RELATIONSHIP_CONSTANT: str = ...
class RelatedField(FieldCacheMixin, Field):
# __set__ value type
_ST = TypeVar("_ST")
# __get__ return type
_GT = TypeVar("_GT")
class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
one_to_many: bool = ...
one_to_one: bool = ...
many_to_many: bool = ...
@@ -80,8 +86,9 @@ class ForeignObject(RelatedField):
rel: None = ...,
related_name: Optional[str] = ...,
related_query_name: None = ...,
limit_choices_to: None = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
parent_link: bool = ...,
db_constraint: bool = ...,
swappable: bool = ...,
verbose_name: Optional[str] = ...,
name: Optional[str] = ...,
@@ -102,16 +109,82 @@ class ForeignObject(RelatedField):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class ForeignKey(RelatedField, Generic[_T]):
def __init__(self, to: Union[Type[_T], str], on_delete: Any, related_name: str = ..., **kwargs): ...
def __set__(self, instance, value: Union[Model, F]) -> None: ...
def __get__(self, instance, owner) -> _T: ...
class ForeignKey(RelatedField[_ST, _GT]):
_pyi_private_set_type: Union[Any, Combinable]
_pyi_private_get_type: Any
def __init__(
self,
to: Union[Type[Model], str],
on_delete: Callable[..., None],
to_field: Optional[str] = ...,
related_name: str = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
parent_link: bool = ...,
db_constraint: bool = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class OneToOneField(RelatedField, Generic[_T]):
def __init__(self, to: Union[Type[_T], str], on_delete: Any, related_name: str = ..., **kwargs): ...
def __get__(self, instance, owner) -> _T: ...
class OneToOneField(RelatedField[_ST, _GT]):
_pyi_private_set_type: Union[Any, Combinable]
_pyi_private_get_type: Any
def __init__(
self,
to: Union[Type[Model], str],
on_delete: Any,
to_field: Optional[str] = ...,
related_name: str = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
parent_link: bool = ...,
db_constraint: bool = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class ManyToManyField(RelatedField[_ST, _GT]):
_pyi_private_set_type: Sequence[Any]
_pyi_private_get_type: RelatedManager[Any]
class ManyToManyField(RelatedField, Generic[_T]):
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ...
@@ -125,17 +198,35 @@ class ManyToManyField(RelatedField, Generic[_T]):
to: Union[Type[_T], str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Callable] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
symmetrical: Optional[bool] = ...,
through: Optional[Union[str, Type[Model]]] = ...,
through_fields: Optional[Tuple[str, str]] = ...,
db_constraint: bool = ...,
db_table: Optional[str] = ...,
swappable: bool = ...,
**kwargs: Any
verbose_name: Optional[Union[str, bytes]] = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
) -> None: ...
def __set__(self, instance, value: Sequence[_T]) -> None: ...
def __get__(self, instance, owner) -> RelatedManager[_T]: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def deconstruct(self) -> Tuple[Optional[str], str, List[Any], Dict[str, str]]: ...
def get_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...

View File

@@ -26,7 +26,7 @@ class ForeignObjectRel(FieldCacheMixin):
model: Union[Type[Model], str] = ...
related_name: Optional[str] = ...
related_query_name: Optional[str] = ...
limit_choices_to: Union[Callable, Dict[str, Any]] = ...
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...
parent_link: bool = ...
on_delete: Callable = ...
symmetrical: bool = ...
@@ -38,7 +38,7 @@ class ForeignObjectRel(FieldCacheMixin):
to: Union[Type[Model], str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Any = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
parent_link: bool = ...,
on_delete: Optional[Callable] = ...,
) -> None: ...
@@ -86,7 +86,7 @@ class ManyToOneRel(ForeignObjectRel):
field_name: Optional[str],
related_name: Optional[str] = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Callable, Dict[str, Union[int, str]], Q]] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
parent_link: bool = ...,
on_delete: Callable = ...,
) -> None: ...

View File

@@ -9,22 +9,19 @@ class CumeDist(Func):
window_compatible: bool = ...
class DenseRank(Func):
extra: Dict[Any, Any]
source_expressions: List[Any]
function: str = ...
name: str = ...
output_field: Any = ...
window_compatible: bool = ...
class FirstValue(Func):
arity: int = ...
function: str = ...
name: str = ...
window_compatible: bool = ...
class LagLeadFunction(Func):
window_compatible: bool = ...
def __init__(self, expression: Optional[str], offset: int = ..., default: None = ..., **extra: Any) -> Any: ...
def __init__(
self, expression: Optional[str], offset: int = ..., default: Optional[int] = ..., **extra: Any
) -> None: ...
class Lag(LagLeadFunction):
function: str = ...

View File

@@ -4,7 +4,6 @@ from django.db.models.base import Model
from django.db.models.query import QuerySet
_T = TypeVar("_T", bound=Model, covariant=True)
_Self = TypeVar("_Self", bound="BaseManager")
class BaseManager(QuerySet[_T]):
creation_counter: int = ...
@@ -17,7 +16,7 @@ class BaseManager(QuerySet[_T]):
def deconstruct(self) -> Tuple[bool, str, None, Tuple, Dict[str, int]]: ...
def check(self, **kwargs: Any) -> List[Any]: ...
@classmethod
def from_queryset(cls: Type[_Self], queryset_class: Any, class_name: Optional[Any] = ...) -> Type[_Self]: ...
def from_queryset(cls, queryset_class: Type[QuerySet], class_name: Optional[str] = ...) -> Any: ...
@classmethod
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...

View File

@@ -20,7 +20,7 @@ from django.db.models.fields import Field, mixins, AutoField
PROXY_PARENTS: Any
EMPTY_RELATION_TREE: Any
IMMUTABLE_WARNING: str
DEFAULT_NAMES: Any
DEFAULT_NAMES: Tuple[str, ...]
def normalize_together(
option_together: Any
@@ -102,7 +102,7 @@ class Options:
def swapped(self) -> Optional[str]: ...
def many_to_many(self) -> ImmutableList: ...
def fields_map(self) -> Dict[str, ForeignObjectRel]: ...
def get_field(self, field_name: Union[Callable, str]) -> Union[Field, mixins.FieldCacheMixin]: ...
def get_field(self, field_name: Union[Callable, str]) -> Field: ...
def get_base_chain(self, model: Type[Model]) -> List[Type[Model]]: ...
def get_parent_list(self) -> List[Type[Model]]: ...
def get_ancestor_link(self, ancestor: Type[Model]) -> Optional[OneToOneField]: ...

View File

@@ -16,11 +16,33 @@ from typing import (
)
from django.db.models.base import Model
from django.db.models.expressions import Combinable
from django.db.models.expressions import Combinable as Combinable, F as F
from django.db.models.sql.query import Query, RawQuery
from typing_extensions import Literal
from django.db import models
from django.db.models import Manager
from django.db.models.query_utils import Q as Q
_Row = TypeVar("_Row", covariant=True)
class BaseIterable(Sequence[_Row]):
def __init__(self, queryset: QuerySet, chunked_fetch: bool = ..., chunk_size: int = ...): ...
def __iter__(self) -> Iterator[_Row]: ...
def __contains__(self, x: object) -> bool: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> _Row: ...
@overload
def __getitem__(self, s: slice) -> Sequence[_Row]: ...
class ModelIterable(BaseIterable[Model]): ...
class ValuesIterable(BaseIterable[Dict[str, Any]]): ...
class ValuesListIterable(BaseIterable[Tuple]): ...
class NamedValuesListIterable(ValuesListIterable): ...
class FlatValuesListIterable(BaseIterable):
def __iter__(self) -> Iterator[Any]: ...
_T = TypeVar("_T", bound=models.Model, covariant=True)
@@ -62,7 +84,9 @@ class QuerySet(Iterable[_T], Sized):
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
def first(self) -> Optional[_T]: ...
def last(self) -> Optional[_T]: ...
def in_bulk(self, id_list: Any = ..., *, field_name: str = ...) -> Dict[Union[int, str], models.Model]: ...
def in_bulk(
self, id_list: Any = ..., *, field_name: str = ..., **kwargs: Any
) -> Dict[Union[int, str], models.Model]: ...
def delete(self) -> Tuple[int, Dict[str, int]]: ...
def update(self, **kwargs: Any) -> int: ...
def _update(self, values: Any) -> Optional[Any]: ...
@@ -73,6 +97,12 @@ class QuerySet(Iterable[_T], Sized):
) -> RawQuerySet: ...
def values(self, *fields: Union[str, Combinable], **expressions: Any) -> QuerySet: ...
def values_list(self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ...) -> QuerySet: ...
# @overload
# def values_list(self, *fields: Union[str, Combinable], named: Literal[True]) -> NamedValuesListIterable: ...
# @overload
# def values_list(self, *fields: Union[str, Combinable], flat: Literal[True]) -> FlatValuesListIterable: ...
# @overload
# def values_list(self, *fields: Union[str, Combinable]) -> ValuesListIterable: ...
def dates(self, field_name: str, kind: str, order: str = ...) -> QuerySet: ...
def datetimes(self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...) -> QuerySet: ...
def none(self) -> QuerySet[_T]: ...
@@ -154,8 +184,5 @@ class Prefetch(object):
def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: Union[str, Prefetch]) -> None: ...
def get_prefetcher(instance: Model, through_attr: str, to_attr: str) -> Tuple[Any, Any, bool, bool]: ...
class ModelIterable(Iterable[_T]):
def __iter__(self) -> Iterator[_T]: ...
class InstanceCheckMeta(type): ...
class EmptyQuerySet(metaclass=InstanceCheckMeta): ...

View File

@@ -1,17 +1,15 @@
import collections
from collections import OrderedDict, namedtuple
from datetime import datetime
from decimal import Decimal
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
from uuid import UUID
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
from django.db.models.sql.datastructures import BaseTable
from django.db.models import Model, Field, Q, FilteredRelation, Expression, QuerySet
from django.db.models.lookups import Lookup
from django.db.models.query_utils import PathInfo
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.datastructures import BaseTable
from django.db.models.sql.where import WhereNode
from django.db.models import Expression, Field, FilteredRelation, Model, Q, QuerySet
JoinInfo = namedtuple("JoinInfo", ["final_field", "targets", "opts", "joins", "path", "transform_function"])
class RawQuery:
@@ -55,9 +53,7 @@ class Query:
select_for_update_nowait: bool = ...
select_for_update_skip_locked: bool = ...
select_for_update_of: Tuple = ...
select_related: Union[
Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]]]]]], bool
] = ...
select_related: Union[Dict[str, Any], bool] = ...
max_depth: int = ...
values_select: Tuple = ...
annotation_select_mask: Optional[Set[str]] = ...
@@ -178,6 +174,7 @@ class Query:
def set_values(self, fields: Union[List[str], Tuple]) -> None: ...
def trim_start(self, names_with_path: List[Tuple[str, List[PathInfo]]]) -> Tuple[str, bool]: ...
def is_nullable(self, field: Field) -> bool: ...
def build_lookup(self, lookups: Sequence[str], lhs: Query, rhs: Optional[Query]) -> Lookup: ...
class JoinPromoter:
connector: str = ...

View File

@@ -1,5 +1,4 @@
from contextlib import ContextDecorator
from typing import Any, Callable, Optional, Union, ContextManager
from typing import Any, Callable, Optional, overload, TypeVar
from django.db import ProgrammingError
@@ -18,12 +17,23 @@ def get_rollback(using: None = ...) -> bool: ...
def set_rollback(rollback: bool, using: Optional[str] = ...) -> None: ...
def on_commit(func: Callable, using: None = ...) -> None: ...
class Atomic(ContextDecorator):
_C = TypeVar("_C", bound=Callable) # Any callable
# Don't inherit from ContextDecorator, so we can provide a more specific signature for __call__
class Atomic:
using: Optional[str] = ...
savepoint: bool = ...
def __init__(self, using: Optional[str], savepoint: bool) -> None: ...
# When decorating, return the decorated function as-is, rather than clobbering it as ContextDecorator does.
def __call__(self, func: _C) -> _C: ...
def __enter__(self) -> None: ...
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
def atomic(using: Optional[Union[Callable, str]] = ..., savepoint: bool = ...) -> ContextManager[Atomic]: ...
# Bare decorator
@overload
def atomic(using: _C) -> _C: ...
# Decorator or context-manager with parameters
@overload
def atomic(using: Optional[str] = None, savepoint: bool = True) -> Atomic: ...
def non_atomic_requests(using: Callable = ...) -> Callable: ...

View File

@@ -14,17 +14,10 @@ class Signal:
sender_receivers_cache: Any = ...
def __init__(self, providing_args: List[str] = ..., use_caching: bool = ...) -> None: ...
def connect(
self,
receiver: Callable,
sender: Optional[Union[Type[Model], AppConfig, str]] = ...,
weak: bool = ...,
dispatch_uid: Optional[str] = ...,
self, receiver: Callable, sender: Optional[object] = ..., weak: bool = ..., dispatch_uid: Optional[str] = ...
) -> None: ...
def disconnect(
self,
receiver: Optional[Callable] = ...,
sender: Optional[Union[Type[Model], AppConfig, str]] = ...,
dispatch_uid: Optional[str] = ...,
self, receiver: Optional[Callable] = ..., sender: Optional[object] = ..., dispatch_uid: Optional[str] = ...
) -> bool: ...
def has_listeners(self, sender: Any = ...) -> bool: ...
def send(self, sender: Any, **named: Any) -> List[Tuple[Callable, Optional[str]]]: ...

View File

@@ -1,12 +1,8 @@
import decimal
from datetime import date, datetime, time, timedelta
from datetime import datetime, timedelta
from decimal import Decimal
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Type
from uuid import UUID
from typing import Any, Callable, List, Optional, Pattern, Sequence, Type, Union
from django.core.files.base import File
from django.core.validators import BaseValidator
from django.db.models.fields.files import FieldFile
from django.forms.boundfield import BoundField
from django.forms.forms import BaseForm
from django.forms.widgets import Widget
@@ -31,16 +27,16 @@ class Field:
self,
*,
required: bool = ...,
widget: Optional[Any] = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Any = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...
label_suffix: Optional[Any] = ...,
) -> None: ...
def prepare_value(self, value: Any) -> Any: ...
def to_python(self, value: Optional[Any]) -> Optional[Any]: ...
@@ -49,60 +45,60 @@ class Field:
def clean(self, value: Any) -> Any: ...
def bound_data(self, data: Any, initial: Any) -> Any: ...
def widget_attrs(self, widget: Widget) -> Any: ...
def has_changed(self, initial: Any, data: Optional[str]) -> bool: ...
def has_changed(self, initial: Any, data: Any) -> bool: ...
def get_bound_field(self, form: BaseForm, field_name: str) -> BoundField: ...
def __deepcopy__(self, memo: Dict[Any, Any]) -> Field: ...
class CharField(Field):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
max_length: Optional[Union[int, str]] = ...
min_length: Optional[Union[int, str]] = ...
strip: bool = ...
empty_value: Optional[str] = ...
def __init__(
self,
*,
max_length: Optional[Any] = ...,
min_length: Optional[Any] = ...,
strip: bool = ...,
empty_value: str = ...,
**kwargs: Any
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class IntegerField(Field):
disabled: bool
error_messages: Dict[str, str]
max_value: Optional[Any]
min_value: Optional[Any]
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
re_decimal: Any = ...
def __init__(self, *, max_value: Optional[Any] = ..., min_value: Optional[Any] = ..., **kwargs: Any) -> None: ...
def __init__(
self,
max_value: Optional[Any] = ...,
min_value: Optional[Any] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class FloatField(IntegerField):
disabled: bool
error_messages: Dict[str, str]
max_value: Optional[float]
min_value: Optional[float]
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
def validate(self, value: Optional[float]) -> None: ...
class DecimalField(IntegerField):
decimal_places: Optional[int]
disabled: bool
error_messages: Dict[str, str]
max_digits: Optional[int]
max_value: Optional[Union[decimal.Decimal, int]]
min_value: Optional[Union[decimal.Decimal, int]]
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
def __init__(
self,
*,
@@ -110,118 +106,95 @@ class DecimalField(IntegerField):
min_value: Optional[Any] = ...,
max_digits: Optional[Any] = ...,
decimal_places: Optional[Any] = ...,
**kwargs: Any
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
def validate(self, value: Optional[Decimal]) -> None: ...
class BaseTemporalField(Field):
input_formats: Any = ...
def __init__(self, *, input_formats: Optional[Any] = ..., **kwargs: Any) -> None: ...
def strptime(self, value: Any, format: Any) -> Any: ...
def __init__(
self,
input_formats: Optional[Any] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
def strptime(self, value: Any, format: str) -> Any: ...
class DateField(BaseTemporalField):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
input_formats: Any = ...
default_error_messages: Any = ...
def strptime(self, value: str, format: str) -> date: ...
class TimeField(BaseTemporalField):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
input_formats: Any = ...
default_error_messages: Any = ...
def strptime(self, value: str, format: str) -> time: ...
class DateTimeField(BaseTemporalField):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
input_formats: Any = ...
default_error_messages: Any = ...
def prepare_value(self, value: Optional[datetime]) -> Optional[datetime]: ...
def strptime(self, value: str, format: str) -> datetime: ...
class DateField(BaseTemporalField): ...
class TimeField(BaseTemporalField): ...
class DateTimeField(BaseTemporalField): ...
class DurationField(Field):
disabled: bool
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
def prepare_value(self, value: Optional[Union[timedelta, str]]) -> Optional[str]: ...
class RegexField(CharField):
disabled: bool
empty_value: str
error_messages: Dict[str, str]
max_length: Optional[int]
min_length: Optional[int]
required: bool
show_hidden_initial: bool
strip: bool
def __init__(self, regex: str, **kwargs: Any) -> None: ...
regex: Any = ...
regex: str = ...
def __init__(
self,
regex: Union[str, Pattern],
max_length: Optional[Any] = ...,
min_length: Optional[Any] = ...,
strip: bool = ...,
empty_value: Optional[str] = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class EmailField(CharField):
disabled: bool
empty_value: Optional[str]
error_messages: Dict[str, str]
max_length: Optional[int]
min_length: Optional[int]
required: bool
show_hidden_initial: bool
strip: bool
default_validators: Any = ...
def __init__(self, **kwargs: Any) -> None: ...
class EmailField(CharField): ...
class FileField(Field):
disabled: bool
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
max_length: Optional[int] = ...
allow_empty_file: bool = ...
def __init__(self, *, max_length: Optional[Any] = ..., allow_empty_file: bool = ..., **kwargs: Any) -> None: ...
def bound_data(self, data: Any, initial: Optional[FieldFile]) -> Optional[Union[File, str]]: ...
def __init__(
self,
max_length: Optional[Any] = ...,
allow_empty_file: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
def clean(self, data: Any, initial: Optional[Any] = ...): ...
class ImageField(FileField):
allow_empty_file: bool
disabled: bool
max_length: Optional[int]
required: bool
show_hidden_initial: bool
default_validators: Any = ...
default_error_messages: Any = ...
class URLField(CharField):
disabled: bool
empty_value: Optional[str]
error_messages: Dict[str, str]
max_length: Optional[int]
min_length: Optional[int]
required: bool
show_hidden_initial: bool
strip: bool
default_error_messages: Any = ...
default_validators: Any = ...
def __init__(self, **kwargs: Any) -> None: ...
class BooleanField(Field):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
def validate(self, value: bool) -> None: ...
class NullBooleanField(BooleanField):
disabled: bool
required: bool
show_hidden_initial: bool
def validate(self, value: Optional[bool]) -> None: ...
class ImageField(FileField): ...
class URLField(CharField): ...
class BooleanField(Field): ...
class NullBooleanField(BooleanField): ...
class CallableChoiceIterator:
choices_func: Callable = ...
@@ -229,125 +202,191 @@ class CallableChoiceIterator:
def __iter__(self) -> None: ...
class ChoiceField(Field):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
choices: Any = ...
def __init__(self, *, choices: Any = ..., **kwargs: Any) -> None: ...
def validate(self, value: Any) -> None: ...
def __init__(
self,
choices: Any = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
def valid_value(self, value: str) -> bool: ...
class TypedChoiceField(ChoiceField):
disabled: bool
required: bool
show_hidden_initial: bool
coerce: Union[Callable, Type[Union[bool, float, str]]] = ...
coerce: Union[Callable, Type[Any]] = ...
empty_value: Optional[str] = ...
def __init__(self, *, coerce: Any = ..., empty_value: str = ..., **kwargs: Any) -> None: ...
def __init__(
self,
coerce: Any = ...,
empty_value: Optional[str] = ...,
choices: Any = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class MultipleChoiceField(ChoiceField):
disabled: bool
error_messages: Dict[str, str]
required: bool
show_hidden_initial: bool
hidden_widget: Any = ...
default_error_messages: Any = ...
def validate(self, value: List[str]) -> None: ...
class MultipleChoiceField(ChoiceField): ...
class TypedMultipleChoiceField(MultipleChoiceField):
disabled: bool
required: bool
show_hidden_initial: bool
coerce: Union[Callable, Type[float]] = ...
empty_value: Optional[List[Any]] = ...
def __init__(self, *, coerce: Any = ..., **kwargs: Any) -> None: ...
def validate(self, value: List[str]) -> None: ...
def __init__(
self,
coerce: Any = ...,
empty_value: Optional[str] = ...,
choices: Any = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class ComboField(Field):
disabled: bool
required: bool
show_hidden_initial: bool
fields: Any = ...
def __init__(self, fields: List[CharField], **kwargs: Any) -> None: ...
def __init__(
self,
fields: Sequence[Field],
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class MultiValueField(Field):
disabled: bool
required: bool
show_hidden_initial: bool
default_error_messages: Any = ...
require_all_fields: bool = ...
fields: Any = ...
def __init__(self, fields: Tuple[Field, Field], *, require_all_fields: bool = ..., **kwargs: Any) -> None: ...
def validate(self, value: Union[datetime, str]) -> None: ...
def __init__(
self,
fields: Sequence[Field],
require_all_fields: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
def compress(self, data_list: Any) -> Any: ...
class FilePathField(ChoiceField):
allow_files: bool
allow_folders: bool
disabled: bool
match: Optional[str]
path: str
recursive: bool
required: bool
show_hidden_initial: bool
choices: Any = ...
match_re: Any = ...
def __init__(
self,
path: str,
*,
match: Optional[Any] = ...,
recursive: bool = ...,
allow_files: bool = ...,
allow_folders: bool = ...,
**kwargs: Any
choices: Any = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class SplitDateTimeField(MultiValueField):
disabled: bool
require_all_fields: bool
required: bool
show_hidden_initial: bool
hidden_widget: Any = ...
default_error_messages: Any = ...
def __init__(
self, *, input_date_formats: Optional[Any] = ..., input_time_formats: Optional[Any] = ..., **kwargs: Any
self,
input_date_formats: Optional[Any] = ...,
input_time_formats: Optional[Any] = ...,
fields: Sequence[Field] = ...,
require_all_fields: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
def compress(self, data_list: List[Optional[datetime]]) -> Optional[datetime]: ...
class GenericIPAddressField(CharField):
disabled: bool
empty_value: str
error_messages: Dict[str, str]
max_length: None
min_length: None
required: bool
show_hidden_initial: bool
strip: bool
unpack_ipv4: bool = ...
default_validators: List[Callable] = ...
def __init__(self, *, protocol: str = ..., unpack_ipv4: bool = ..., **kwargs: Any) -> None: ...
def __init__(
self,
protocol: str = ...,
unpack_ipv4: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class SlugField(CharField):
disabled: bool
empty_value: str
max_length: Optional[int]
min_length: None
required: bool
show_hidden_initial: bool
strip: bool
allow_unicode: bool = ...
def __init__(self, *, allow_unicode: bool = ..., **kwargs: Any) -> None: ...
def __init__(
self,
allow_unicode: bool = ...,
required: bool = ...,
widget: Optional[Union[Widget, Type[Widget]]] = ...,
label: Optional[Any] = ...,
initial: Optional[Any] = ...,
help_text: str = ...,
error_messages: Optional[Any] = ...,
show_hidden_initial: bool = ...,
validators: Sequence[Any] = ...,
localize: bool = ...,
disabled: bool = ...,
label_suffix: Optional[Any] = ...,
) -> None: ...
class UUIDField(CharField):
disabled: bool
empty_value: str
max_length: None
min_length: None
required: bool
show_hidden_initial: bool
strip: bool
default_error_messages: Any = ...
def prepare_value(self, value: UUID) -> str: ...
class UUIDField(CharField): ...

View File

@@ -1,49 +1,45 @@
from collections import OrderedDict
from datetime import date, datetime
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
from datetime import datetime
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Type, Union
from django.core.exceptions import ValidationError
from django.core.exceptions import ValidationError as ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db.models.query import QuerySet
from django.forms.boundfield import BoundField
from django.forms.fields import Field
from django.forms.renderers import BaseRenderer
from django.forms.utils import ErrorDict, ErrorList
from django.forms.widgets import Media, MediaDefiningClass
from django.http.request import QueryDict
from django.utils.datastructures import MultiValueDict
from django.utils.safestring import SafeText
class DeclarativeFieldsMetaclass(MediaDefiningClass):
def __new__(
mcs: Type[DeclarativeFieldsMetaclass], name: str, bases: Tuple[Type[BaseForm]], attrs: OrderedDict
) -> Type[BaseForm]: ...
def __new__(mcs, name: str, bases: Sequence[Type[BaseForm]], attrs: Dict[str, Any]) -> Type[BaseForm]: ...
class BaseForm:
default_renderer: Any = ...
field_order: Any = ...
prefix: Any = ...
use_required_attribute: bool = ...
is_bound: Any = ...
data: Any = ...
files: Any = ...
is_bound: bool = ...
data: Dict[str, Any] = ...
files: Optional[Dict[str, Any]] = ...
auto_id: Any = ...
initial: Any = ...
error_class: Any = ...
label_suffix: Any = ...
empty_permitted: Any = ...
fields: Any = ...
renderer: Any = ...
initial: Dict[str, Any] = ...
error_class: Type[ErrorList] = ...
prefix: str = ...
label_suffix: str = ...
empty_permitted: bool = ...
fields: Dict[str, Any] = ...
renderer: BaseRenderer = ...
def __init__(
self,
data: Optional[Union[Dict[str, Union[List[int], int, str]], Dict[str, Union[List[str], str]], QueryDict]] = ...,
files: Optional[Union[Dict[str, SimpleUploadedFile], MultiValueDict]] = ...,
data: Optional[Mapping[str, Any]] = ...,
files: Optional[Mapping[str, Any]] = ...,
auto_id: Optional[Union[bool, str]] = ...,
prefix: Optional[str] = ...,
initial: Optional[Union[Dict[str, List[int]], Dict[str, date], Dict[str, str]]] = ...,
initial: Optional[Mapping[str, Any]] = ...,
error_class: Type[ErrorList] = ...,
label_suffix: None = ...,
label_suffix: Optional[str] = ...,
empty_permitted: bool = ...,
field_order: None = ...,
field_order: Optional[Any] = ...,
use_required_attribute: Optional[bool] = ...,
renderer: Any = ...,
) -> None: ...

View File

@@ -1,8 +1,4 @@
import collections
from typing import Any, List, Optional, Union, Dict, Type
from django.forms.renderers import BaseRenderer
from django.forms.utils import ErrorList
from typing import Any, Dict, Mapping, Optional, Sequence, Sized
from django.forms import Form
@@ -17,21 +13,9 @@ DEFAULT_MIN_NUM: int = ...
DEFAULT_MAX_NUM: int = ...
class ManagementForm(Form):
auto_id: Union[bool, str]
cleaned_data: Dict[str, Optional[int]]
data: Dict[str, Union[List[int], int, str]]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[str, int]
is_bound: bool
label_suffix: str
prefix: str
renderer: BaseRenderer
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class BaseFormSet:
class BaseFormSet(Sized, Mapping[str, Any]):
is_bound: Any = ...
prefix: Any = ...
auto_id: Any = ...
@@ -57,6 +41,7 @@ class BaseFormSet:
def management_form(self): ...
def total_form_count(self): ...
def initial_form_count(self): ...
@property
def forms(self): ...
def get_form_kwargs(self, index: Any): ...
@property
@@ -101,4 +86,4 @@ def formset_factory(
min_num: Optional[Any] = ...,
validate_min: bool = ...,
): ...
def all_valid(formsets: List[Any]) -> bool: ...
def all_valid(formsets: Sequence[Any]) -> bool: ...

View File

@@ -1,10 +1,11 @@
from collections import OrderedDict
from datetime import date, datetime
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, Sequence
from typing import Any, Callable, Dict, Iterator, List, MutableMapping, Optional, Sequence, Tuple, Type, Union
from unittest.mock import MagicMock
from uuid import UUID
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files.base import File
from django.db import models
from django.db.models import ForeignKey
from django.db.models.base import Model
from django.db.models.manager import Manager
@@ -14,9 +15,8 @@ from django.forms.fields import CharField, ChoiceField, Field
from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass
from django.forms.formsets import BaseFormSet
from django.forms.utils import ErrorList
from django.forms.widgets import Input, Widget, Select
from django.http.request import QueryDict
from django.utils.datastructures import MultiValueDict
from django.forms.widgets import Input, Widget
from typing_extensions import Literal
ALL_FIELDS: str
@@ -57,21 +57,19 @@ class ModelFormOptions:
def __init__(self, options: Optional[type] = ...) -> None: ...
class ModelFormMetaclass(DeclarativeFieldsMetaclass):
def __new__(
mcs: Type[ModelFormMetaclass], name: str, bases: Tuple[Type[ModelForm]], attrs: OrderedDict
) -> Type[ModelForm]: ...
def __new__(mcs, name: str, bases: Sequence[Type[ModelForm]], attrs: Dict[str, Any]) -> Type[ModelForm]: ...
class BaseModelForm(BaseForm):
instance: Any = ...
def __init__(
self,
data: Optional[Union[Dict[str, Any], QueryDict]] = ...,
files: Optional[Union[Dict[str, SimpleUploadedFile], MultiValueDict]] = ...,
data: Optional[Dict[str, Any]] = ...,
files: Optional[Dict[str, File]] = ...,
auto_id: Union[bool, str] = ...,
prefix: None = ...,
initial: Optional[Union[Dict[str, List[int]], Dict[str, int]]] = ...,
prefix: Optional[str] = ...,
initial: Optional[Dict[str, Any]] = ...,
error_class: Type[ErrorList] = ...,
label_suffix: None = ...,
label_suffix: Optional[str] = ...,
empty_permitted: bool = ...,
instance: Optional[Model] = ...,
use_required_attribute: None = ...,
@@ -87,16 +85,16 @@ class ModelForm(BaseModelForm): ...
def modelform_factory(
model: Type[Model],
form: Type[ModelForm] = ...,
fields: Optional[Union[List[str], str]] = ...,
exclude: None = ...,
formfield_callback: Optional[str] = ...,
widgets: None = ...,
localized_fields: None = ...,
labels: None = ...,
help_texts: None = ...,
error_messages: None = ...,
field_classes: None = ...,
) -> Any: ...
fields: Optional[Union[Sequence[str], Literal["__all__"]]] = ...,
exclude: Optional[Sequence[str]] = ...,
formfield_callback: Optional[Union[str, Callable[[models.Field], Field]]] = ...,
widgets: Optional[MutableMapping[str, Widget]] = ...,
localized_fields: Optional[Sequence[str]] = ...,
labels: Optional[MutableMapping[str, str]] = ...,
help_texts: Optional[MutableMapping[str, str]] = ...,
error_messages: Optional[MutableMapping[str, Dict[str, Any]]] = ...,
field_classes: Optional[MutableMapping[str, Type[Field]]] = ...,
) -> Type[ModelForm]: ...
class BaseModelFormSet(BaseFormSet):
model: Any = ...
@@ -148,13 +146,13 @@ def modelformset_factory(
exclude: Optional[Sequence[str]] = ...,
widgets: Optional[Dict[str, Any]] = ...,
validate_max: bool = ...,
localized_fields: None = ...,
localized_fields: Optional[Sequence[str]] = ...,
labels: Optional[Dict[str, str]] = ...,
help_texts: Optional[Dict[str, str]] = ...,
error_messages: Optional[Dict[str, Dict[str, str]]] = ...,
validate_min: bool = ...,
field_classes: Optional[Dict[str, Any]] = ...,
) -> Any: ...
field_classes: Optional[Dict[str, Type[Field]]] = ...,
) -> Type[BaseModelFormSet]: ...
class BaseInlineFormSet(BaseModelFormSet):
instance: Any = ...
@@ -192,14 +190,14 @@ def inlineformset_factory(
formfield_callback: Optional[Callable] = ...,
widgets: Optional[Dict[str, Any]] = ...,
validate_max: bool = ...,
localized_fields: None = ...,
localized_fields: Optional[Sequence[str]] = ...,
labels: Optional[Dict[str, str]] = ...,
help_texts: Optional[Dict[str, str]] = ...,
error_messages: Optional[Dict[str, Dict[str, str]]] = ...,
min_num: Optional[int] = ...,
validate_min: bool = ...,
field_classes: Optional[Dict[str, Any]] = ...,
) -> Any: ...
) -> Type[BaseInlineFormSet]: ...
class InlineForeignKeyField(Field):
disabled: bool
@@ -235,7 +233,7 @@ class ModelChoiceField(ChoiceField):
iterator: Any = ...
empty_label: Optional[str] = ...
queryset: Any = ...
limit_choices_to: None = ...
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...
to_field_name: None = ...
def __init__(
self,
@@ -248,7 +246,7 @@ class ModelChoiceField(ChoiceField):
initial: Optional[Any] = ...,
help_text: str = ...,
to_field_name: Optional[Any] = ...,
limit_choices_to: Optional[Any] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
**kwargs: Any
) -> None: ...
def get_limit_choices_to(self) -> Optional[Union[Dict[str, datetime], Q, MagicMock]]: ...

View File

@@ -1,16 +1,16 @@
from collections import UserList
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Sequence
from django.core.exceptions import ValidationError
from django.utils.safestring import SafeText
def pretty_name(name: str) -> str: ...
def flatatt(attrs: Dict[str, Optional[str]]) -> SafeText: ...
def flatatt(attrs: Dict[str, Any]) -> SafeText: ...
class ErrorDict(dict):
def as_data(self) -> Dict[str, List[ValidationError]]: ...
def get_json_data(self, escape_html: bool = ...) -> Dict[str, List[Dict[str, str]]]: ...
def get_json_data(self, escape_html: bool = ...) -> Dict[str, Any]: ...
def as_json(self, escape_html: bool = ...) -> str: ...
def as_ul(self) -> str: ...
def as_text(self) -> str: ...
@@ -18,7 +18,11 @@ class ErrorDict(dict):
class ErrorList(UserList):
data: List[Union[ValidationError, str]]
error_class: str = ...
def __init__(self, initlist: Optional[ErrorList] = ..., error_class: Optional[str] = ...) -> None: ...
def __init__(
self,
initlist: Optional[Union[ErrorList, Sequence[Union[str, Exception]]]] = ...,
error_class: Optional[str] = ...,
) -> None: ...
def as_data(self) -> List[ValidationError]: ...
def get_json_data(self, escape_html: bool = ...) -> List[Dict[str, str]]: ...
def as_json(self, escape_html: bool = ...) -> str: ...

View File

@@ -1,17 +1,16 @@
from datetime import time
from decimal import Decimal
from itertools import chain
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, Iterable
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
from django.contrib.admin.options import BaseModelAdmin
from django.core.files.base import File
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db.models.fields.files import FieldFile
from django.forms.forms import BaseForm
from django.forms.renderers import EngineMixin
from django.utils.datastructures import MultiValueDict
from django.utils.safestring import SafeText
_OptAttrs = Dict[str, str]
class MediaOrderConflictWarning(RuntimeWarning): ...
class Media:
@@ -32,9 +31,7 @@ class Media:
def __add__(self, other: Media) -> Media: ...
class MediaDefiningClass(type):
def __new__(
mcs: Type[MediaDefiningClass], name: str, bases: Tuple, attrs: Any
) -> Type[Union[BaseModelAdmin, BaseForm, Widget]]: ...
def __new__(mcs, name: str, bases: Sequence[Any], attrs: Dict[str, Any]) -> type: ...
class Widget:
needs_multipart_form: bool = ...
@@ -61,10 +58,10 @@ class Widget:
self, base_attrs: Dict[str, Union[float, str]], extra_attrs: Optional[Dict[str, Union[bool, str]]] = ...
) -> Dict[str, Union[Decimal, float, str]]: ...
def value_from_datadict(
self, data: dict, files: Union[Dict[str, SimpleUploadedFile], MultiValueDict], name: str
self, data: dict, files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str
) -> Any: ...
def value_omitted_from_data(
self, data: Dict[str, Any], files: Union[Dict[str, SimpleUploadedFile], MultiValueDict], name: str
self, data: Dict[str, Any], files: Union[Dict[str, Iterable[Any]], MultiValueDict], name: str
) -> bool: ...
def id_for_label(self, id_: str) -> str: ...
def use_required_attribute(self, initial: Any) -> bool: ...
@@ -80,6 +77,7 @@ class URLInput(Input): ...
class PasswordInput(Input):
render_value: bool = ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., render_value: bool = ...): ...
class HiddenInput(Input):
choices: Iterable[Tuple[str, str]]
@@ -105,6 +103,7 @@ class DateTimeBaseInput(TextInput):
format_key: str = ...
supports_microseconds: bool = ...
format: Optional[str] = ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., format: Optional[str] = ...): ...
class DateInput(DateTimeBaseInput): ...
class DateTimeInput(DateTimeBaseInput): ...
@@ -112,7 +111,7 @@ class TimeInput(DateTimeBaseInput): ...
class CheckboxInput(Input):
check_test: Callable = ...
def __init__(self, attrs: Optional[Dict[str, str]] = ..., check_test: Optional[Callable] = ...) -> None: ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., check_test: Optional[Callable] = ...) -> None: ...
class ChoiceWidget(Widget):
allow_multiple_selected: bool = ...
@@ -123,17 +122,9 @@ class ChoiceWidget(Widget):
checked_attribute: Any = ...
option_inherits_attrs: bool = ...
choices: List[List[Union[int, str]]] = ...
def __init__(
self,
attrs: Optional[Dict[str, Union[bool, str]]] = ...,
choices: Union[
Iterator[Any], List[List[Union[int, str]]], List[Tuple[Union[time, int], int]], List[int], Tuple
] = ...,
) -> None: ...
def options(self, name: str, value: List[str], attrs: Dict[str, Union[bool, str]] = ...) -> None: ...
def optgroups(
self, name: str, value: List[str], attrs: Optional[Dict[str, Union[bool, str]]] = ...
) -> List[Tuple[Optional[str], List[Dict[str, Union[Dict[str, Union[bool, str]], time, int, str]]], int]]: ...
def __init__(self, attrs: Optional[_OptAttrs] = ..., choices: Sequence[Tuple[Any, Any]] = ...) -> None: ...
def options(self, name: str, value: List[str], attrs: Optional[_OptAttrs] = ...) -> None: ...
def optgroups(self, name: str, value: List[str], attrs: Optional[_OptAttrs] = ...) -> Any: ...
def create_option(
self,
name: str,
@@ -142,8 +133,8 @@ class ChoiceWidget(Widget):
selected: Union[Set[str], bool],
index: int,
subindex: Optional[int] = ...,
attrs: Optional[Dict[str, Union[bool, str]]] = ...,
) -> Dict[str, Union[Dict[str, Union[bool, str]], Dict[str, bool], Set[str], time, int, str]]: ...
attrs: Optional[_OptAttrs] = ...,
) -> Dict[str, Any]: ...
def id_for_label(self, id_: str, index: str = ...) -> str: ...
class Select(ChoiceWidget):
@@ -171,11 +162,7 @@ class CheckboxSelectMultiple(ChoiceWidget):
class MultiWidget(Widget):
template_name: str = ...
widgets: List[Widget] = ...
def __init__(
self,
widgets: Union[List[Type[DateTimeBaseInput]], Tuple[Union[Type[TextInput], Input]]],
attrs: Optional[Dict[str, str]] = ...,
) -> 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]: ...
@@ -218,8 +205,8 @@ class SelectDateWidget(Widget):
day_none_value: Any = ...
def __init__(
self,
attrs: None = ...,
years: Optional[Union[Tuple[Union[int, str]], range]] = ...,
months: None = ...,
empty_label: Optional[Union[Tuple[str, str], str]] = ...,
attrs: Optional[_OptAttrs] = ...,
years: Optional[Iterable[Union[int, str]]] = ...,
months: Optional[Dict[int, str]] = ...,
empty_label: Optional[Union[str, Sequence[str]]] = ...,
) -> None: ...

View File

@@ -1,4 +1,9 @@
from .request import HttpRequest as HttpRequest, QueryDict as QueryDict
from .request import (
HttpRequest as HttpRequest,
QueryDict as QueryDict,
RawPostDataException as RawPostDataException,
UnreadablePostError as UnreadablePostError,
)
from .response import (
BadHeaderError as BadHeaderError,

View File

@@ -1,4 +1,4 @@
from io import BytesIO
from io import BytesIO, StringIO
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
from django.http.request import QueryDict
@@ -11,7 +11,7 @@ class MultiPartParser:
def __init__(
self,
META: Dict[str, Any],
input_data: BytesIO,
input_data: Union[StringIO, BytesIO],
upload_handlers: Union[List[Any], ImmutableList],
encoding: Optional[str] = ...,
) -> None: ...
@@ -50,3 +50,5 @@ class BoundaryIter:
class Parser:
def __init__(self, stream: LazyStream, boundary: bytes) -> None: ...
def __iter__(self) -> Iterator[Tuple[str, Dict[str, Tuple[str, Dict[str, Union[bytes, str]]]], LazyStream]]: ...
def parse_header(line: bytes) -> Tuple[str, Dict[str, Any]]: ...

View File

@@ -1,16 +1,14 @@
# Stubs for django.http.request (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from io import BytesIO
from typing import Any, BinaryIO, Dict, Iterable, Iterator, List, Optional, overload, Pattern, Tuple, Union
from typing import Any, BinaryIO, Dict, Iterable, List, Mapping, Optional, Pattern, Tuple, Union, overload
from django.contrib.sessions.backends.base import SessionBase
from django.core.files import uploadhandler, uploadedfile
from django.utils.datastructures import MultiValueDict, ImmutableList
from django.utils.datastructures import ImmutableList, MultiValueDict
from django.core.files import uploadedfile, uploadhandler
from django.urls import ResolverMatch
RAISE_ERROR = ... # type: object
host_validation_re = ... # type: Pattern
RAISE_ERROR: object = ...
host_validation_re: Pattern = ...
class UnreadablePostError(IOError): ...
class RawPostDataException(Exception): ...
@@ -21,7 +19,7 @@ class HttpRequest(BytesIO):
GET: QueryDict = ...
POST: QueryDict = ...
COOKIES: Dict[str, str] = ...
META: Dict[str, str] = ...
META: Dict[str, Any] = ...
FILES: MultiValueDict[str, uploadedfile.UploadedFile] = ...
path: str = ...
path_info: str = ...
@@ -30,6 +28,8 @@ class HttpRequest(BytesIO):
content_type: Optional[str] = ...
content_params: Optional[Dict[str, str]] = ...
session: SessionBase
encoding: Optional[str] = ...
upload_handlers: UploadHandlerList = ...
def __init__(self) -> None: ...
def get_host(self) -> str: ...
def get_port(self) -> str: ...
@@ -44,38 +44,23 @@ class HttpRequest(BytesIO):
def scheme(self) -> Optional[str]: ...
def is_secure(self) -> bool: ...
def is_ajax(self) -> bool: ...
encoding = ... # type: Optional[str]
upload_handlers = ... # type: UploadHandlerList
def parse_file_upload(
self, META: Dict[str, str], post_data: BinaryIO
) -> Tuple["QueryDict", MultiValueDict[str, uploadedfile.UploadedFile]]: ...
self, META: Mapping[str, Any], post_data: BinaryIO
) -> Tuple[QueryDict, MultiValueDict[str, uploadedfile.UploadedFile]]: ...
@property
def body(self) -> bytes: ...
def close(self) -> None: ...
def read(self, *args: Any, **kwargs: Any) -> bytes: ...
def readline(self, *args: Any, **kwargs: Any) -> bytes: ...
def xreadlines(self) -> Iterator[bytes]: ...
def __iter__(self) -> Iterator[bytes]: ...
def readlines(self) -> List[bytes]: ... # type: ignore
def _load_post_and_files(self) -> None: ...
class QueryDict(MultiValueDict[str, str]):
encoding = str # type: Any
encoding: Any = ...
_mutable: bool = ...
def __init__(
self, query_string: Union[str, bytes, None] = None, mutable: bool = False, encoding: Optional[str] = None
self, query_string: Optional[Union[str, bytes]] = ..., mutable: bool = ..., encoding: Optional[str] = ...
) -> None: ...
def __setitem__(self, key: str, value: str) -> None: ...
def __delitem__(self, key: str) -> None: ...
def __copy__(self) -> "QueryDict": ...
def __deepcopy__(self, memo: Dict[int, object]) -> "QueryDict": ...
def setlist(self, key: str, list_: List[str]) -> None: ...
def setlistdefault(self, key: str, default_list: List[str] = None) -> List[str]: ...
def setlistdefault(self, key: str, default_list: Optional[List[str]] = ...) -> List[str]: ...
def appendlist(self, key: str, value: str) -> None: ...
def popitem(self) -> Tuple[str, str]: ...
def clear(self) -> None: ...
def setdefault(self, key: str, default: Optional[str] = None) -> str: ...
def copy(self) -> "QueryDict": ...
def urlencode(self, safe: Optional[str] = None) -> str: ...
def urlencode(self, safe: Optional[str] = ...) -> str: ...
@overload
def bytes_to_text(s: bytes, encoding: str) -> str: ...

View File

@@ -1,7 +1,7 @@
import datetime
from io import BytesIO
from json import JSONEncoder
from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type, Union, overload
from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type, Union, overload, AnyStr, IO
import six
from django.core.handlers.wsgi import WSGIRequest
@@ -13,12 +13,12 @@ from django.urls import ResolverMatch
class BadHeaderError(ValueError): ...
class HttpResponseBase(six.Iterator):
class HttpResponseBase(Iterable[AnyStr]):
status_code: int = ...
cookies: SimpleCookie = ...
closed: bool = ...
reason_phrase: str = ...
charset: str = ...
closed: bool = ...
def __init__(
self,
content_type: Optional[str] = ...,
@@ -27,15 +27,15 @@ class HttpResponseBase(six.Iterator):
charset: Optional[str] = ...,
) -> None: ...
def serialize_headers(self) -> bytes: ...
def __setitem__(self, header: str, value: Union[str, bytes]) -> None: ...
def __delitem__(self, header: str) -> None: ...
def __getitem__(self, header: str) -> str: ...
def __setitem__(self, header: Union[str, bytes], value: Union[str, bytes, int]) -> None: ...
def __delitem__(self, header: Union[str, bytes]) -> None: ...
def __getitem__(self, header: Union[str, bytes]) -> str: ...
def has_header(self, header: str) -> bool: ...
def items(self) -> Iterable[Tuple[str, str]]: ...
@overload
def get(self, header: str, alternate: str) -> str: ...
def get(self, header: Union[str, bytes], alternate: Optional[str]) -> str: ...
@overload
def get(self, header: str) -> Optional[str]: ...
def get(self, header: Union[str, bytes]) -> Optional[str]: ...
def set_cookie(
self,
key: str,
@@ -53,17 +53,17 @@ class HttpResponseBase(six.Iterator):
def delete_cookie(self, key: str, path: str = "", domain: str = None) -> None: ...
def make_bytes(self, value: object) -> bytes: ...
def close(self) -> None: ...
def write(self, content: object) -> None: ...
def write(self, content: Union[str, bytes]) -> None: ...
def flush(self) -> None: ...
def tell(self) -> int: ...
def readable(self) -> bool: ...
def seekable(self) -> bool: ...
def writable(self) -> bool: ...
def writelines(self, lines: Iterable[object]) -> None: ...
def writelines(self, lines: Iterable[object]): ...
def __iter__(self) -> Iterator[AnyStr]: ...
class HttpResponse(HttpResponseBase):
client: Client
closed: bool
context: Optional[Context]
csrf_cookie_set: bool
redirect_chain: List[Tuple[str, int]]
@@ -80,29 +80,25 @@ class HttpResponse(HttpResponseBase):
def __init__(self, content: object = ..., *args: Any, **kwargs: Any) -> None: ...
def serialize(self) -> bytes: ...
@property
def content(self) -> bytes: ...
def content(self) -> Any: ...
@content.setter
def content(self, value: Any) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def tell(self) -> int: ...
def getvalue(self) -> bytes: ...
def writable(self) -> bool: ...
@property
def url(self) -> str: ...
def json(self) -> Dict[str, Any]: ...
class StreamingHttpResponse(HttpResponseBase):
def __init__(self, streaming_content: Iterable[bytes] = ..., *args: Any, **kwargs: Any) -> None: ...
def __init__(self, streaming_content: Iterable[AnyStr] = ..., *args: Any, **kwargs: Any) -> None: ...
@property
def content(self) -> bytes: ...
def content(self) -> AnyStr: ...
@content.setter
def content(self, value: Any) -> None: ...
def content(self, value: AnyStr) -> None: ...
@property
def streaming_content(self) -> Iterator[bytes]: ...
def streaming_content(self) -> Iterator[AnyStr]: ...
@streaming_content.setter
def streaming_content(self, value: Iterable[bytes]) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def getvalue(self) -> bytes: ...
def streaming_content(self, value: Iterable[AnyStr]) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def getvalue(self) -> AnyStr: ...
class FileResponse(StreamingHttpResponse):
client: Client

View File

@@ -1,18 +1,17 @@
from typing import Any, Optional, Callable
from typing import Any, Optional
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase, HttpResponseNotFound, HttpResponsePermanentRedirect
from django.http.response import HttpResponseBase, HttpResponsePermanentRedirect
from django.utils.deprecation import MiddlewareMixin
class CommonMiddleware(MiddlewareMixin):
response_redirect_class: Any = ...
def process_request(self, request: WSGIRequest) -> Optional[HttpResponsePermanentRedirect]: ...
def should_redirect_with_slash(self, request: WSGIRequest) -> bool: ...
def get_full_path_with_slash(self, request: WSGIRequest) -> str: ...
def process_request(self, request: HttpRequest) -> Optional[HttpResponsePermanentRedirect]: ...
def should_redirect_with_slash(self, request: HttpRequest) -> bool: ...
def get_full_path_with_slash(self, request: HttpRequest) -> str: ...
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
class BrokenLinkEmailsMiddleware(MiddlewareMixin):
def process_response(self, request: WSGIRequest, response: HttpResponseNotFound) -> HttpResponseNotFound: ...
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
def is_internal_request(self, domain: str, referer: str) -> bool: ...
def is_ignorable_request(self, request: WSGIRequest, uri: str, domain: str, referer: str) -> bool: ...
def is_ignorable_request(self, request: HttpRequest, uri: str, domain: str, referer: str) -> bool: ...

View File

@@ -27,3 +27,7 @@ class CsrfViewMiddleware(MiddlewareMixin):
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
def _compare_salted_tokens(request_csrf_token: str, csrf_token: str) -> bool: ...
def _get_new_csrf_string() -> str: ...
def _salt_cipher_secret(secret: str) -> str: ...
def _unsalt_cipher_token(token: str) -> str: ...
def _get_new_csrf_token() -> str: ...

View File

@@ -1,13 +1,13 @@
from typing import Any, Callable, Dict, List, Optional, Type, Union, Sequence
from typing import Any, Callable, Dict, List, Optional, Protocol, Sequence, Type, TypeVar, Union
from django.db.models.base import Model
from django.http.response import HttpResponse as HttpResponse, HttpResponseRedirect as HttpResponseRedirect
from django.db.models import Manager, QuerySet
from django.db.models.base import Model
from django.http.response import HttpResponse, HttpResponseRedirect
from django.http import HttpRequest
def render_to_response(
template_name: str,
template_name: Union[str, Sequence[str]],
context: Optional[Dict[str, Any]] = ...,
content_type: Optional[str] = ...,
status: Optional[int] = ...,
@@ -21,7 +21,16 @@ def render(
status: Optional[int] = ...,
using: Optional[str] = ...,
) -> HttpResponse: ...
def redirect(to: Union[Callable, str], *args: Any, permanent: bool = ..., **kwargs: Any) -> HttpResponseRedirect: ...
def get_object_or_404(klass: Union[Type[Model], Manager, QuerySet], *args: Any, **kwargs: Any) -> Model: ...
def get_list_or_404(klass: Union[Type[Model], Manager, QuerySet], *args: Any, **kwargs: Any) -> List[Model]: ...
class SupportsGetAbsoluteUrl(Protocol):
pass
def redirect(
to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: bool = ..., **kwargs: Any
) -> HttpResponseRedirect: ...
_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_list_or_404(klass: Union[Type[_T], Manager[_T], QuerySet[_T]], *args: Any, **kwargs: Any) -> List[_T]: ...
def resolve_url(to: Union[Callable, Model, str], *args: Any, **kwargs: Any) -> str: ...

View File

@@ -1,4 +1,6 @@
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
from typing import Any, Dict, Iterator, List, Tuple, Union
from django.template.base import Template
class BaseEngine:
name: Any = ...
@@ -7,7 +9,7 @@ class BaseEngine:
def __init__(self, params: Dict[str, Union[List[str], bool, str]]) -> None: ...
@property
def app_dirname(self) -> None: ...
def from_string(self, template_code: Any) -> None: ...
def from_string(self, template_code: Any) -> Template: ...
def get_template(self, template_name: Any) -> None: ...
def template_dirs(self) -> Tuple[str]: ...
def iter_template_filenames(self, template_name: str) -> Iterator[str]: ...

View File

@@ -1,7 +1,8 @@
from enum import Enum
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, Iterator, List, Mapping, Optional, Tuple, Type, Union
from django.template.context import Context
from django.http.request import HttpRequest
from django.template.context import Context as Context
from django.template.engine import Engine
from django.template.library import Library
from django.template.loaders.base import Loader
@@ -52,17 +53,15 @@ class Template:
nodelist: NodeList = ...
def __init__(
self,
template_string: str,
template_string: Union[Template, str],
origin: Optional[Origin] = ...,
name: Optional[str] = ...,
engine: Optional[Engine] = ...,
) -> None: ...
def __iter__(self) -> None: ...
def render(self, context: Context) -> Any: ...
def render(self, context: Union[Context, Dict[str, Any]], request: Optional[HttpRequest] = ...) -> Any: ...
def compile_nodelist(self) -> NodeList: ...
def get_exception_info(
self, exception: Exception, token: Token
) -> Dict[str, Union[List[Tuple[int, SafeText]], int, str]]: ...
def get_exception_info(self, exception: Exception, token: Token) -> Dict[str, Any]: ...
def linebreak_iter(template_source: str) -> Iterator[int]: ...
@@ -141,7 +140,7 @@ class Variable:
translate: bool = ...
message_context: Optional[str] = ...
def __init__(self, var: Union[Dict[Any, Any], str]) -> None: ...
def resolve(self, context: Union[Dict[str, Dict[str, Union[int, str]]], Context, int, str]) -> Any: ...
def resolve(self, context: Union[Mapping[str, Mapping[str, Any]], Context, int, str]) -> Any: ...
class Node:
must_be_first: bool = ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, Union
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, Union, Iterable
from django.http.request import HttpRequest
from django.template.base import Node, Origin, Template
@@ -15,10 +15,10 @@ class ContextDict(dict):
def __enter__(self) -> ContextDict: ...
def __exit__(self, *args: Any, **kwargs: Any) -> None: ...
class BaseContext:
class BaseContext(Iterable[Any]):
def __init__(self, dict_: Any = ...) -> None: ...
def __copy__(self) -> BaseContext: ...
def __iter__(self) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
def push(self, *args: Any, **kwargs: Any) -> ContextDict: ...
def pop(self) -> ContextDict: ...
def __setitem__(self, key: Union[Node, str], value: Any) -> None: ...
@@ -50,7 +50,6 @@ class Context(BaseContext):
class RenderContext(BaseContext):
dicts: List[Dict[Union[IncludeNode, str], str]]
template: Optional[Template] = ...
def __iter__(self) -> None: ...
def push_state(self, template: Template, isolated_context: bool = ...) -> Iterator[None]: ...
class RequestContext(Context):

View File

@@ -1,11 +1,8 @@
from datetime import _date, datetime, timedelta
from decimal import Decimal
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
from datetime import date as _date, datetime, time as _time
from typing import Any, Callable, Dict, List, Optional, Union
from django.utils.safestring import SafeText
from .base import Variable as Variable, VariableDoesNotExist as VariableDoesNotExist
from .library import Library as Library
from django.utils.html import escape as escape
register: Any
@@ -14,7 +11,7 @@ def addslashes(value: str) -> str: ...
def capfirst(value: str) -> str: ...
def escapejs_filter(value: str) -> SafeText: ...
def json_script(value: Dict[str, str], element_id: SafeText) -> SafeText: ...
def floatformat(text: Optional[Union[Decimal, float, str]], arg: Union[int, str] = ...) -> str: ...
def floatformat(text: Optional[Any], arg: Union[int, str] = ...) -> str: ...
def iriencode(value: str) -> str: ...
def linenumbers(value: str, autoescape: bool = ...) -> SafeText: ...
def lower(value: str) -> str: ...
@@ -43,41 +40,20 @@ def linebreaksbr(value: str, autoescape: bool = ...) -> SafeText: ...
def safe(value: str) -> SafeText: ...
def safeseq(value: List[str]) -> List[SafeText]: ...
def striptags(value: str) -> str: ...
def dictsort(
value: Union[
Dict[str, int],
List[Dict[str, Dict[str, Union[int, str]]]],
List[Dict[str, str]],
List[Tuple[str, str]],
List[int],
int,
str,
],
arg: Union[int, str],
) -> Union[List[Dict[str, Dict[str, Union[int, str]]]], List[Dict[str, str]], List[Tuple[str, str]], str]: ...
def dictsortreversed(
value: Union[Dict[str, int], List[Dict[str, Union[int, str]]], List[Tuple[str, str]], List[int], int, str],
arg: Union[int, str],
) -> Union[List[Dict[str, Union[int, str]]], List[Tuple[str, str]], str]: ...
def first(value: Union[List[int], List[str], str]) -> Union[int, str]: ...
def dictsort(value: Any, arg: Union[int, str]) -> Any: ...
def dictsortreversed(value: Any, arg: Union[int, str]) -> Any: ...
def first(value: Any) -> Any: ...
def join(value: Any, arg: str, autoescape: bool = ...) -> Any: ...
def last(value: List[str]) -> str: ...
def length(value: Any) -> int: ...
def length_is(
value: Optional[Union[List[Callable], Tuple[str, str], int, str]], arg: Union[SafeText, int]
) -> Union[bool, str]: ...
def length_is(value: Optional[Any], arg: Union[SafeText, int]) -> Union[bool, str]: ...
def random(value: List[str]) -> str: ...
def slice_filter(value: Any, arg: str) -> Any: ...
def unordered_list(
value: Union[Iterator[Any], List[Union[List[Union[List[Union[List[str], str]], str]], str]]], autoescape: bool = ...
) -> SafeText: ...
def add(
value: Union[List[int], Tuple[int, int], _date, int, str],
arg: Union[List[int], Tuple[int, int], timedelta, int, str],
) -> Union[List[int], Tuple[int, int, int, int], _date, int, str]: ...
def get_digit(value: Union[int, str], arg: int) -> Union[int, str]: ...
def unordered_list(value: Any, autoescape: bool = ...) -> Any: ...
def add(value: Any, arg: Any) -> Any: ...
def get_digit(value: Any, arg: int) -> Any: ...
def date(value: Optional[Union[_date, datetime, str]], arg: Optional[str] = ...) -> str: ...
def time(value: Optional[Union[datetime, str]], arg: Optional[str] = ...) -> str: ...
def time(value: Optional[Union[datetime, _time, str]], arg: Optional[str] = ...) -> str: ...
def timesince_filter(value: Optional[_date], arg: Optional[_date] = ...) -> str: ...
def timeuntil_filter(value: Optional[_date], arg: Optional[_date] = ...) -> str: ...
def default(value: Optional[Union[int, str]], arg: Union[int, str]) -> Union[int, str]: ...

View File

@@ -1,9 +1,9 @@
from collections import namedtuple
from datetime import date
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
from django.template.base import FilterExpression, Parser, Token
from django.template.context import RequestContext, Context
from django.template.context import Context
from django.utils.safestring import SafeText
from .base import Node, NodeList
@@ -153,9 +153,13 @@ class WidthRatioNode(Node):
class WithNode(Node):
nodelist: NodeList = ...
extra_context: Dict[str, Union[FilterExpression, str]] = ...
extra_context: Dict[str, Any] = ...
def __init__(
self, var: Optional[str], name: Optional[str], nodelist: NodeList, extra_context: Optional[Dict[str, Any]] = ...
self,
var: Optional[str],
name: Optional[str],
nodelist: Union[NodeList, Sequence[Node]],
extra_context: Optional[Dict[str, Any]] = ...,
) -> None: ...
def autoescape(parser: Parser, token: Token) -> AutoEscapeControlNode: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence
from django.template.base import Origin
from django.template.library import Library
@@ -7,6 +7,8 @@ from django.utils.safestring import SafeText
from .base import Template
_Loader = Any
class Engine:
template_context_processors: Tuple[Callable]
template_loaders: List[Loader]
@@ -16,7 +18,7 @@ class Engine:
autoescape: bool = ...
context_processors: Union[List[str], Tuple[str]] = ...
debug: bool = ...
loaders: Union[List[List[Union[Dict[str, str], str]]], List[Tuple[str, List[str]]], List[str]] = ...
loaders: Sequence[_Loader] = ...
string_if_invalid: str = ...
file_charset: str = ...
libraries: Dict[str, str] = ...
@@ -29,7 +31,7 @@ class Engine:
app_dirs: bool = ...,
context_processors: Optional[Union[List[str], Tuple[str]]] = ...,
debug: bool = ...,
loaders: Optional[Union[List[List[Union[Dict[str, str], str]]], List[Tuple[str, List[str]]], List[str]]] = ...,
loaders: Optional[Sequence[_Loader]] = ...,
string_if_invalid: str = ...,
file_charset: str = ...,
libraries: Optional[Dict[str, str]] = ...,
@@ -40,12 +42,8 @@ class Engine:
def get_default() -> Engine: ...
def get_template_builtins(self, builtins: List[str]) -> List[Library]: ...
def get_template_libraries(self, libraries: Dict[str, str]) -> Dict[str, Library]: ...
def get_template_loaders(
self, template_loaders: Union[List[List[Union[Dict[str, str], str]]], List[Tuple[str, List[str]]], List[str]]
) -> List[Loader]: ...
def find_template_loader(
self, loader: Union[List[Union[Dict[str, str], str]], Tuple[str, List[str]], str]
) -> Loader: ...
def get_template_loaders(self, template_loaders: Sequence[_Loader]) -> List[Loader]: ...
def find_template_loader(self, loader: _Loader) -> Loader: ...
def find_template(
self, name: str, dirs: None = ..., skip: Optional[List[Origin]] = ...
) -> Tuple[Template, Origin]: ...

View File

@@ -1,12 +1,14 @@
from typing import Dict, List, Optional, Union, Any
from typing import Any, Dict, List, Optional, Union
from . import engines as engines
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist
def get_template(template_name: str, using: Optional[str] = ...) -> Any: ...
def select_template(template_name_list: Union[List[str], str], using: Optional[str] = ...) -> Any: ...
def render_to_string(
template_name: Union[List[str], str],
context: Optional[Dict[str, Any]] = ...,
request: Optional[WSGIRequest] = ...,
request: Optional[HttpRequest] = ...,
using: Optional[str] = ...,
) -> str: ...

View File

@@ -1,10 +1,11 @@
from typing import Any, List, Optional
from typing import Any, List, Optional, Dict
from django.template.base import Origin, Template
from django.template.engine import Engine
class Loader:
engine: Any = ...
get_template_cache: Dict[str, Any] = ...
def __init__(self, engine: Engine) -> None: ...
def get_template(self, template_name: str, skip: Optional[List[Origin]] = ...) -> Template: ...
def get_template_sources(self, template_name: Any) -> None: ...

View File

@@ -1,13 +1,20 @@
from io import BytesIO
from typing import Any, Dict, List, Optional, Union, Tuple, Type
from typing import Any, Dict, List, Optional, Pattern, Tuple, Type, Union
from django.contrib.auth.models import User
from django.contrib.sessions.backends.base import SessionBase
from django.core.handlers.base import BaseHandler
from django.core.handlers.wsgi import WSGIRequest
from django.core.serializers.json import DjangoJSONEncoder
from django.http.cookie import SimpleCookie
from django.http.response import HttpResponseBase
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase
from django.core.handlers.wsgi import WSGIRequest
BOUNDARY: str = ...
MULTIPART_CONTENT: str = ...
CONTENT_TYPE_RE: Pattern = ...
JSON_CONTENT_TYPE_RE: Pattern = ...
class RedirectCycleError(Exception):
last_response: HttpResponseBase = ...
@@ -69,17 +76,52 @@ class RequestFactory:
**extra: Any
) -> WSGIRequest: ...
class Client(RequestFactory):
defaults: Dict[str, str]
errors: BytesIO
json_encoder: Type[DjangoJSONEncoder]
class Client:
json_encoder: Type[DjangoJSONEncoder] = ...
defaults: Dict[str, str] = ...
cookies: SimpleCookie = ...
errors: BytesIO = ...
handler: ClientHandler = ...
exc_info: None = ...
def __init__(self, enforce_csrf_checks: bool = ..., **defaults: Any) -> None: ...
def request(self, **request: Any) -> HttpResponse: ...
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponse: ...
def post(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponse: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> HttpResponse: ...
def options(
self,
path: str,
data: Union[Dict[str, str], str] = ...,
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def put(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def patch(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def delete(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def generic(
self,
method: str,
path: str,
data: Any = ...,
content_type: Optional[str] = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def store_exc_info(self, **kwargs: Any) -> None: ...
@property
def session(self) -> SessionBase: ...
def login(self, **credentials: Any) -> bool: ...
def force_login(self, user: User, backend: Optional[str] = ...) -> None: ...
cookies: SimpleCookie = ...
def logout(self) -> None: ...
def conditional_content_removal(request: HttpRequest, response: HttpResponseBase) -> HttpResponse: ...

View File

@@ -1,5 +1,5 @@
from html.parser import HTMLParser
from typing import Any, List, Optional, Tuple, Union, TypeVar
from typing import Any, List, Optional, Tuple, Union, TypeVar, Iterable, Sequence
_Self = TypeVar("_Self")
@@ -7,20 +7,20 @@ WHITESPACE: Any
def normalize_whitespace(string: str) -> str: ...
_ElementAttribute = Tuple[str, Optional[str]]
class Element:
name: Optional[str] = ...
attributes: List[Tuple[str, Optional[str]]] = ...
children: List[Union[Element, str]] = ...
def __init__(self, name: Optional[str], attributes: Union[List[Tuple[str, Optional[str]]], Tuple]) -> None: ...
attributes: List[_ElementAttribute] = ...
children: List[Any] = ...
def __init__(self, name: Optional[str], attributes: Sequence[_ElementAttribute]) -> None: ...
def append(self, element: Union[Element, str]) -> None: ...
def finalize(self) -> None: ...
def __contains__(self, element: Union[Element, str]) -> bool: ...
def count(self, element: Union[Element, str]) -> int: ...
def __getitem__(self, key: int) -> Union[Element, str]: ...
def __getitem__(self, key: int) -> Any: ...
class RootElement(Element):
attributes: List[Any]
children: List[Union[Element, str]]
def __init__(self) -> None: ...
class HTMLParseError(Exception): ...

View File

@@ -1,7 +1,7 @@
import logging
from argparse import ArgumentParser
from io import StringIO
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union, Sequence
from unittest import TestCase, TextTestResult, TestSuite
from django.db.backends.base.base import BaseDatabaseWrapper
@@ -38,6 +38,7 @@ class RemoteTestResult:
@property
def test_index(self): ...
def check_picklable(self, test: Any, err: Any) -> None: ...
def _confirm_picklable(self, obj: Any) -> None: ...
def check_subtest_picklable(self, test: Any, subtest: Any) -> None: ...
def stop_if_failfast(self) -> None: ...
def stop(self) -> None: ...
@@ -109,10 +110,7 @@ class DiscoverRunner:
def add_arguments(cls, parser: ArgumentParser) -> None: ...
def setup_test_environment(self, **kwargs: Any) -> None: ...
def build_suite(
self,
test_labels: Union[List[str], Tuple[str, str]] = ...,
extra_tests: Optional[List[Any]] = ...,
**kwargs: Any
self, test_labels: Sequence[str] = ..., extra_tests: Optional[List[Any]] = ..., **kwargs: Any
) -> TestSuite: ...
def setup_databases(self, **kwargs: Any) -> List[Tuple[BaseDatabaseWrapper, str, bool]]: ...
def get_resultclass(self) -> Optional[Type[DebugSQLTextTestResult]]: ...

View File

@@ -5,15 +5,17 @@ from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Ty
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import WSGIHandler
from django.core.servers.basehttp import WSGIRequestHandler, ThreadedWSGIServer
from django.core.servers.basehttp import ThreadedWSGIServer, WSGIRequestHandler
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.base import Model
from django.db.models.query import QuerySet, RawQuerySet
from django.forms.fields import EmailField
from django.http.response import HttpResponse, HttpResponseBase
from django.template.base import Template
from django.test.utils import CaptureQueriesContext, modify_settings, override_settings, ContextList
from django.test.client import Client
from django.test.utils import CaptureQueriesContext, ContextList
from django.utils.safestring import SafeText
from django.db import connections as connections
class _AssertNumQueriesContext(CaptureQueriesContext):
connection: Any
@@ -55,6 +57,7 @@ class _CursorFailure:
class SimpleTestCase(unittest.TestCase):
client_class: Any = ...
client: Client
allow_database_queries: bool = ...
@classmethod
def setUpClass(cls) -> None: ...
@@ -233,3 +236,5 @@ class SerializeMixin:
def setUpClass(cls) -> None: ...
@classmethod
def tearDownClass(cls) -> None: ...
def connections_support_transactions() -> bool: ...

View File

@@ -3,7 +3,7 @@ import warnings
from io import StringIO
from contextlib import contextmanager
from decimal import Decimal
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, IO
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, IO, Iterable, Mapping
from django.apps.registry import Apps
from django.core.checks.registry import CheckRegistry
@@ -118,3 +118,15 @@ def captured_stderr() -> Iterator[StringIO]: ...
@contextmanager
def freeze_time(t: float) -> Iterator[None]: ...
def tag(*tags: str): ...
_Signature = str
_TestDatabase = Tuple[str, List[str]]
def dependency_ordered(
test_databases: Iterable[Tuple[_Signature, _TestDatabase]], dependencies: Mapping[str, List[str]]
) -> List[Tuple[_Signature, _TestDatabase]]: ...
def get_unique_databases_and_mirrors() -> Tuple[Dict[_Signature, _TestDatabase], Dict[str, Any]]: ...
def teardown_databases(
old_config: Iterable[Tuple[Any, str, bool]], verbosity: int, parallel: int = ..., keepdb: bool = ...
) -> None: ...
def require_jinja2(test_func: Callable) -> Callable: ...

View File

@@ -23,6 +23,8 @@ class ResolverMatch:
namespaces: Optional[List[Optional[str]]] = ...,
) -> None: ...
def __getitem__(self, index: int) -> Any: ...
# for tuple unpacking
def __iter__(self) -> Any: ...
def get_resolver(urlconf: Optional[str] = ...) -> URLResolver: ...
def get_ns_resolver(ns_pattern: str, resolver: URLResolver, converters: Tuple) -> URLResolver: ...
@@ -84,6 +86,8 @@ class URLResolver:
default_kwargs: Dict[str, Any] = ...
namespace: Optional[str] = ...
app_name: Optional[str] = ...
_local: Any
_reverse_dict: MultiValueDict
def __init__(
self,
pattern: Any,
@@ -101,3 +105,5 @@ class URLResolver:
def resolve(self, path: str) -> ResolverMatch: ...
def resolve_error_handler(self, view_type: int) -> Tuple[Callable, Dict[str, Any]]: ...
def reverse(self, lookup_view: str, *args: Any, **kwargs: Any) -> str: ...
def _is_callback(self, name: str) -> bool: ...
def _populate(self) -> None: ...

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