mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 22:11:54 +08:00
Compare commits
115 Commits
readme-fix
...
jedi-v1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd057010f6 | ||
|
|
3d2534ea8d | ||
|
|
54f5f63e71 | ||
|
|
4c5723d368 | ||
|
|
7e0e43135d | ||
|
|
e05b84e32d | ||
|
|
71751d3795 | ||
|
|
25f92e8e56 | ||
|
|
28d47c7e93 | ||
|
|
197cb4058e | ||
|
|
dac2b31fb2 | ||
|
|
8d2600136a | ||
|
|
570772f973 | ||
|
|
d5c1bfb12a | ||
|
|
64cbb0f70e | ||
|
|
6f5a39625e | ||
|
|
bf604a0398 | ||
|
|
92c8dfc93f | ||
|
|
c10c55052c | ||
|
|
96914e466b | ||
|
|
90ed7f332d | ||
|
|
a801501151 | ||
|
|
8ea59985df | ||
|
|
2964ed53d7 | ||
|
|
1b9176f994 | ||
|
|
54d0d018c6 | ||
|
|
1af3a12f2c | ||
|
|
7af89ee6a6 | ||
|
|
afa16bfb74 | ||
|
|
f77073157b | ||
|
|
fe3b95c611 | ||
|
|
d0f9730c53 | ||
|
|
0fdd678d65 | ||
|
|
2397065fa6 | ||
|
|
04023a9f31 | ||
|
|
95e6c94319 | ||
|
|
d96aee7a8b | ||
|
|
2489bb9b04 | ||
|
|
3a8f278c88 | ||
|
|
85b65b4578 | ||
|
|
150e8e862a | ||
|
|
5b3088a17a | ||
|
|
f89a0fbbaa | ||
|
|
438f8b5829 | ||
|
|
836d5acd8f | ||
|
|
bfae51e64c | ||
|
|
e3801918e3 | ||
|
|
6f296b0a91 | ||
|
|
7ba578f6b2 | ||
|
|
cb123de105 | ||
|
|
38135f2d1f | ||
|
|
998b659749 | ||
|
|
72f69e1c5e | ||
|
|
d666ecd36f | ||
|
|
c1af26c027 | ||
|
|
3c3dfcbc9f | ||
|
|
1196336e3b | ||
|
|
665f4d8ea1 | ||
|
|
b3ed9e4827 | ||
|
|
fb1593630a | ||
|
|
031d42a75d | ||
|
|
f7e1cfc6c7 | ||
|
|
d0c25e3bce | ||
|
|
1c31e71ffc | ||
|
|
6b3b6be3c1 | ||
|
|
5832605053 | ||
|
|
31e795016f | ||
|
|
0cba3f9fd6 | ||
|
|
f02050911f | ||
|
|
e8e6fca78c | ||
|
|
ade48b6546 | ||
|
|
b8f29027d8 | ||
|
|
eba3f6cb15 | ||
|
|
5a45544e76 | ||
|
|
8c2de7da56 | ||
|
|
d43c6dc7e2 | ||
|
|
f7e2109e06 | ||
|
|
cea62abf5a | ||
|
|
3b69ec6a72 | ||
|
|
7e794534c0 | ||
|
|
f5f33b061d | ||
|
|
58b26fdbd3 | ||
|
|
9ca79c24a2 | ||
|
|
540e28f4c6 | ||
|
|
4ac43c6ed6 | ||
|
|
cadd6c963b | ||
|
|
041754f817 | ||
|
|
c0c5d1e588 | ||
|
|
f824003cc4 | ||
|
|
58f1833cab | ||
|
|
cbb6a7a9ac | ||
|
|
2c4827bbaf | ||
|
|
5a151bf851 | ||
|
|
cbc7159995 | ||
|
|
df4c17a947 | ||
|
|
445abc046c | ||
|
|
557b7a4fa3 | ||
|
|
8343d76895 | ||
|
|
8d986a0f43 | ||
|
|
e9a90ebff0 | ||
|
|
7b74a6944a | ||
|
|
83f11a0fc6 | ||
|
|
2829faf1af | ||
|
|
d061e84cc7 | ||
|
|
3a9263dc62 | ||
|
|
14aea2b4d4 | ||
|
|
287c64d6fb | ||
|
|
6601121db2 | ||
|
|
87d59c7c1a | ||
|
|
8402e7c53e | ||
|
|
dceb075152 | ||
|
|
7e3f4bfa02 | ||
|
|
db9ff6aaf6 | ||
|
|
717be5940f | ||
|
|
b939bc96b7 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,3 +9,6 @@ build/
|
||||
dist/
|
||||
pip-wheel-metadata/
|
||||
.pytest_cache/
|
||||
/.envrc
|
||||
/.direnv
|
||||
django-sources/
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
||||
[submodule "django-sources"]
|
||||
path = django-sources
|
||||
url = https://github.com/django/django.git
|
||||
branch = stable/2.2.x
|
||||
31
.travis.yml
31
.travis.yml
@@ -4,17 +4,33 @@ dist: xenial
|
||||
sudo: required
|
||||
jobs:
|
||||
include:
|
||||
- name: Run plugin test suite with python 3.8
|
||||
python: 3.8
|
||||
script: 'pytest'
|
||||
|
||||
- name: Run plugin test suite with python 3.7
|
||||
python: 3.7
|
||||
script: 'pytest'
|
||||
|
||||
- name: Typecheck Django test suite with python 3.7
|
||||
python: 3.7
|
||||
script: 'python ./scripts/typecheck_tests.py'
|
||||
- name: Typecheck Django 3.0 test suite with python 3.8
|
||||
python: 3.8
|
||||
script: |
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
|
||||
- name: Typecheck Django test suite with python 3.6
|
||||
- name: Typecheck Django 3.0 test suite with python 3.7
|
||||
python: 3.7
|
||||
script: |
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
|
||||
- name: Typecheck Django 3.0 test suite with python 3.6
|
||||
python: 3.6
|
||||
script: 'python ./scripts/typecheck_tests.py'
|
||||
script: |
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
|
||||
- name: Typecheck Django 2.2 test suite with python 3.7
|
||||
python: 3.7
|
||||
script: |
|
||||
python ./scripts/typecheck_tests.py --django_version=2.2
|
||||
|
||||
- name: Mypy for plugin code
|
||||
python: 3.7
|
||||
@@ -37,8 +53,9 @@ jobs:
|
||||
script: 'isort --check --diff'
|
||||
|
||||
before_install: |
|
||||
sudo apt update
|
||||
sudo apt install binutils libproj-dev gdal-bin
|
||||
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils libproj-dev gdal-bin
|
||||
pip install -U pip setuptools wheel
|
||||
install: |
|
||||
pip install -r ./dev-requirements.txt
|
||||
|
||||
111
CONTRIBUTING.md
Normal file
111
CONTRIBUTING.md
Normal file
@@ -0,0 +1,111 @@
|
||||
# How to contribute
|
||||
|
||||
## Tutorials
|
||||
|
||||
If you want to start working on this project,
|
||||
you will need to get familiar with these projects:
|
||||
|
||||
- [Django docs](https://docs.djangoproject.com/en/dev/)
|
||||
- [Typing in Python](https://inventwithpython.com/blog/2019/11/24/type-hints-for-busy-python-programmers/)
|
||||
- [How to write custom mypy plugins](https://mypy.readthedocs.io/en/stable/extending_mypy.html)
|
||||
- [Typechecking Django and DRF](https://sobolevn.me/2019/08/typechecking-django-and-drf) guide
|
||||
- [Testing mypy stubs, plugins, and types](https://sobolevn.me/2019/08/testing-mypy-types) guide
|
||||
|
||||
It is also recommended to take a look at these resources:
|
||||
|
||||
- [Awesome Python Typing](https://github.com/typeddjango/awesome-python-typing)
|
||||
|
||||
|
||||
## Dev documentation
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
We use `pip` to manage the dependencies.
|
||||
|
||||
To install them you would need to activate your `virtualenv` and run `install` command:
|
||||
|
||||
```bash
|
||||
pip install -r ./dev-requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## Tests and linters
|
||||
|
||||
We use `mypy`, `pytest`, `flake8`, and `black` for quality control.
|
||||
Here's [how we run our CI](https://github.com/typeddjango/django-stubs/blob/master/.travis.yml).
|
||||
|
||||
### Typechecking
|
||||
|
||||
To run typechecking use:
|
||||
|
||||
```bash
|
||||
mypy ./mypy_django_plugin
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
There are unit tests and type-related tests.
|
||||
|
||||
To run unit tests:
|
||||
|
||||
```bash
|
||||
pytest
|
||||
```
|
||||
|
||||
Type-related tests ensure that different Django versions do work correctly.
|
||||
To run type-related tests:
|
||||
|
||||
```bash
|
||||
python ./scripts/typecheck_tests.py --django_version=2.2
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
```
|
||||
|
||||
Currently we only support two Django versions.
|
||||
|
||||
### Linting
|
||||
|
||||
To run auto-formatting:
|
||||
|
||||
```bash
|
||||
isort -rc .
|
||||
black django-stubs/
|
||||
```
|
||||
|
||||
To run linting:
|
||||
|
||||
```bash
|
||||
flake8
|
||||
flake8 --config flake8-pyi.ini
|
||||
```
|
||||
|
||||
|
||||
## Submitting your code
|
||||
|
||||
We use [trunk based](https://trunkbaseddevelopment.com/)
|
||||
development (we also sometimes call it `wemake-git-flow`).
|
||||
|
||||
What the point of this method?
|
||||
|
||||
1. We use protected `master` branch,
|
||||
so the only way to push your code is via pull request
|
||||
2. We use issue branches: to implement a new feature or to fix a bug
|
||||
create a new branch named `issue-$TASKNUMBER`
|
||||
3. Then create a pull request to `master` branch
|
||||
4. We use `git tag`s to make releases, so we can track what has changed
|
||||
since the latest release
|
||||
|
||||
So, this way we achieve an easy and scalable development process
|
||||
which frees us from merging hell and long-living branches.
|
||||
|
||||
In this method, the latest version of the app is always in the `master` branch.
|
||||
|
||||
|
||||
## Other help
|
||||
|
||||
You can contribute by spreading a word about this library.
|
||||
It would also be a huge contribution to write
|
||||
a short article on how you are using this project.
|
||||
You can also share your best practices with us.
|
||||
120
README.md
120
README.md
@@ -1,14 +1,12 @@
|
||||
<img src="http://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/>
|
||||
|
||||
# pep484 stubs for Django framework
|
||||
# Typesafe Django Framework
|
||||
|
||||
[](https://travis-ci.org/typeddjango/django-stubs)
|
||||
[](https://travis-ci.com/typeddjango/django-stubs)
|
||||
[](http://mypy-lang.org/)
|
||||
[](https://gitter.im/mypy-django/Lobby)
|
||||
|
||||
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.
|
||||
|
||||
Could be run on earlier versions of Django, but expect some missing imports warnings.
|
||||
This package contains [type stubs](https://www.python.org/dev/peps/pep-0561/) and a custom 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 this project. The final goal is to be able to get precise types for most common patterns.
|
||||
|
||||
|
||||
## Installation
|
||||
@@ -17,74 +15,106 @@ Could be run on earlier versions of Django, but expect some missing imports warn
|
||||
pip install django-stubs
|
||||
```
|
||||
|
||||
|
||||
## Mypy compatibility
|
||||
|
||||
| django-stubs | mypy version | django version | python version
|
||||
| ------------ | ---- | ---- | ---- |
|
||||
| 1.2.0 | 0.730 | 2.2.x | ^3.6
|
||||
| 1.1.0 | 0.720 | 2.2.x | ^3.6
|
||||
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
|
||||
See [Configuration](#configuration) section to get started.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
To make mypy aware of the plugin, you need to add
|
||||
To make `mypy` happy, you will need to add:
|
||||
|
||||
```ini
|
||||
[mypy]
|
||||
plugins =
|
||||
mypy_django_plugin.main
|
||||
|
||||
[mypy.plugins.django-stubs]
|
||||
django_settings_module = "myproject.settings"
|
||||
```
|
||||
|
||||
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
|
||||
|
||||
Plugin also requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified.
|
||||
Two things happeining here:
|
||||
|
||||
```ini
|
||||
[mypy]
|
||||
strict_optional = True
|
||||
|
||||
# This one is new:
|
||||
[mypy.plugins.django-stubs]
|
||||
django_settings_module = mysettings
|
||||
```
|
||||
|
||||
Where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes)
|
||||
|
||||
You might also need to explicitly tweak your `PYTHONPATH` the very same way `django` does it internally in case you have troubles with mypy / django plugin not finding your settings module. Try adding the root path of your project to your `PYTHONPATH` environment variable like so:
|
||||
|
||||
```bash
|
||||
PYTHONPATH=${PYTHONPATH}:${PWD}
|
||||
```
|
||||
|
||||
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
|
||||
|
||||
In other words, if your `manage.py runserver` crashes, mypy will crash too.
|
||||
1. We need to explicitly list our plugin to be loaded by `mypy`
|
||||
2. Our plugin also requires `django` settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified
|
||||
|
||||
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
|
||||
|
||||
|
||||
## Notes
|
||||
## Version compatibility
|
||||
|
||||
Type implementation monkey-patches Django to add `__class_getitem__` to the `Manager` class.
|
||||
If you would use Python3.7 and do that too in your code, you can make things like
|
||||
We rely on different `django` and `mypy` versions:
|
||||
|
||||
| django-stubs | mypy version | django version | python version
|
||||
| ------------ | ---- | ---- | ---- |
|
||||
| 1.5.0 | 0.780 | 2.2.x \|\| 3.x | ^3.6
|
||||
| 1.4.0 | 0.770 | 2.2.x \|\| 3.x | ^3.6
|
||||
| 1.3.0 | 0.750 | 2.2.x \|\| 3.x | ^3.6
|
||||
| 1.2.0 | 0.730 | 2.2.x | ^3.6
|
||||
| 1.1.0 | 0.720 | 2.2.x | ^3.6
|
||||
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
### Is this an official Django project?
|
||||
|
||||
No, it is not. We are indendepent from Django at the moment.
|
||||
There's a [proposal](https://github.com/django/deps/pull/65) to merge our project into the Django itself.
|
||||
You show your support by linking the PR.
|
||||
|
||||
### Is it safe to use this in production?
|
||||
|
||||
Yes, it is! This project does not affect your runtime at all.
|
||||
It only affects `mypy` type checking process.
|
||||
|
||||
But, it does not make any sense to use this project without `mypy`.
|
||||
|
||||
### mypy crashes when I run it with this plugin installed
|
||||
|
||||
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps or `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
|
||||
|
||||
In other words, if your `manage.py runserver` crashes, mypy will crash too.
|
||||
You can also run `mypy` with [`--tb`](https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-show-traceback)
|
||||
option to get extra information about the error.
|
||||
|
||||
### I cannot use QuerySet or Manager with type annotations
|
||||
|
||||
You can get a `TypeError: 'type' object is not subscriptable`
|
||||
when you will try to use `QuerySet[MyModel]` or `Manager[MyModel]`.
|
||||
|
||||
This happens because Django classes do not support [`__class_getitem__`](https://www.python.org/dev/peps/pep-0560/#class-getitem) magic method.
|
||||
|
||||
You can use strings instead: `'QuerySet[MyModel]'` and `'Manager[MyModel]'`, this way it will work as a type for `mypy` and as a regular `str` in runtime.
|
||||
|
||||
Currently we [are working](https://github.com/django/django/pull/12405) on providing `__class_getitem__` to the classes where we need them.
|
||||
|
||||
### How can I use HttpRequest with custom user model?
|
||||
|
||||
You can subclass standard request like so:
|
||||
|
||||
```python
|
||||
class MyUserManager(models.Manager['MyUser']):
|
||||
pass
|
||||
from django.http import HttpRequest
|
||||
from my_user_app.models import MyUser
|
||||
|
||||
class MyUser(models.Model):
|
||||
objects = UserManager()
|
||||
class MyRequest(HttpRequest):
|
||||
user: MyUser
|
||||
```
|
||||
|
||||
work, which should make a error messages a bit better.
|
||||
And then use `MyRequest` instead of standard `HttpRequest` inside your project.
|
||||
|
||||
|
||||
## Related projects
|
||||
|
||||
- [`awesome-python-typing`](https://github.com/typeddjango/awesome-python-typing) - Awesome list of all typing-related things in Python.
|
||||
- [`djangorestframework-stubs`](https://github.com/typeddjango/djangorestframework-stubs) - Stubs for Django REST Framework.
|
||||
- [`pytest-mypy-plugins`](https://github.com/typeddjango/pytest-mypy-plugins) - `pytest` plugin that we use for testing `mypy` stubs and plugins.
|
||||
- [`wemake-django-template`](https://github.com/wemake-services/wemake-django-template) - Create new typed Django projects in seconds.
|
||||
|
||||
Otherwise, custom type will be created in mypy, named `MyUser__MyUserManager`, which will rewrite base manager as `models.Manager[User]` to make methods like `get_queryset()` and others return properly typed `QuerySet`.
|
||||
|
||||
|
||||
## To get help
|
||||
|
||||
We have Gitter here: <https://gitter.im/mypy-django/Lobby>
|
||||
|
||||
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.
|
||||
If you think you have more generic typing issue, please refer to <https://github.com/python/mypy> and their Gitter.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
black
|
||||
pytest-mypy-plugins==1.1.0
|
||||
pytest-mypy-plugins==1.3.0
|
||||
psycopg2
|
||||
flake8==3.7.8
|
||||
flake8==3.7.9
|
||||
flake8-pyi==19.3.0
|
||||
isort==4.3.21
|
||||
gitpython==3.1.0
|
||||
-e .
|
||||
|
||||
Submodule django-sources deleted from f452d4232e
@@ -1,5 +1,6 @@
|
||||
from typing import Any, Iterator, Type, Optional, Dict
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.db.models.base import Model
|
||||
|
||||
MODELS_MODULE_NAME: str
|
||||
@@ -7,11 +8,11 @@ MODELS_MODULE_NAME: str
|
||||
class AppConfig:
|
||||
name: str = ...
|
||||
module: Optional[Any] = ...
|
||||
apps: None = ...
|
||||
apps: Optional[Apps] = ...
|
||||
label: str = ...
|
||||
verbose_name: str = ...
|
||||
path: str = ...
|
||||
models_module: None = ...
|
||||
models_module: Optional[str] = ...
|
||||
models: Dict[str, Type[Model]] = ...
|
||||
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
|
||||
@classmethod
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
import threading
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, DefaultDict, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.db.migrations.state import AppConfigStub
|
||||
from django.db.models.base import Model
|
||||
|
||||
from .config import AppConfig
|
||||
|
||||
class Apps:
|
||||
all_models: Dict[str, OrderedDict[str, Type[Model]]] = ...
|
||||
app_configs: OrderedDict[str, AppConfig] = ...
|
||||
all_models: Dict[str, Dict[str, Type[Model]]] = ...
|
||||
app_configs: Dict[str, AppConfig] = ...
|
||||
stored_app_configs: List[Any] = ...
|
||||
apps_ready: bool = ...
|
||||
ready_event: threading.Event = ...
|
||||
loading: bool = ...
|
||||
_pending_operations: DefaultDict[Tuple[str, str], List]
|
||||
_pending_operations: Dict[Tuple[str, str], List]
|
||||
models_ready: bool = ...
|
||||
ready: bool = ...
|
||||
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
|
||||
def populate(self, installed_apps: Union[List[AppConfigStub], List[str], Tuple] = ...) -> None: ...
|
||||
def __init__(self, installed_apps: Optional[Iterable[Union[AppConfig, str]]] = ...) -> None: ...
|
||||
def populate(self, installed_apps: Iterable[Union[AppConfig, str]] = ...) -> None: ...
|
||||
def check_apps_ready(self) -> None: ...
|
||||
def check_models_ready(self) -> None: ...
|
||||
def get_app_configs(self) -> Iterable[AppConfig]: ...
|
||||
@@ -31,9 +29,9 @@ class Apps:
|
||||
def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ...
|
||||
def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ...
|
||||
def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ...
|
||||
def set_available_apps(self, available: List[str]) -> None: ...
|
||||
def set_available_apps(self, available: Iterable[str]) -> None: ...
|
||||
def unset_available_apps(self) -> None: ...
|
||||
def set_installed_apps(self, installed: Union[List[str], Tuple[str]]) -> None: ...
|
||||
def set_installed_apps(self, installed: Iterable[str]) -> None: ...
|
||||
def unset_installed_apps(self) -> None: ...
|
||||
def clear_cache(self) -> None: ...
|
||||
def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ...
|
||||
|
||||
@@ -345,7 +345,7 @@ SESSION_COOKIE_PATH = "/"
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
# Whether to set the flag restricting cookie leaks on cross-site requests.
|
||||
# This can be 'Lax', 'Strict', or None to disable the flag.
|
||||
SESSION_COOKIE_SAMESITE = "Lax"
|
||||
SESSION_COOKIE_SAMESITE: Optional[str] = ...
|
||||
# Whether to save the session data on every request.
|
||||
SESSION_SAVE_EVERY_REQUEST = False
|
||||
# Whether a user's session cookie expires when the Web browser is closed.
|
||||
@@ -413,7 +413,7 @@ CSRF_COOKIE_DOMAIN = None
|
||||
CSRF_COOKIE_PATH = "/"
|
||||
CSRF_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
CSRF_COOKIE_SAMESITE = "Lax"
|
||||
CSRF_COOKIE_SAMESITE: Optional[str] = ...
|
||||
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
|
||||
CSRF_TRUSTED_ORIGINS: List[str] = ...
|
||||
CSRF_USE_SESSIONS = False
|
||||
|
||||
@@ -5,10 +5,10 @@ from django.http.response import HttpResponse, HttpResponseBase
|
||||
|
||||
from django.urls import URLResolver, URLPattern
|
||||
|
||||
handler400: Callable[..., HttpResponse] = ...
|
||||
handler403: Callable[..., HttpResponse] = ...
|
||||
handler404: Callable[..., HttpResponse] = ...
|
||||
handler500: Callable[..., HttpResponse] = ...
|
||||
handler400: Union[str, Callable[..., HttpResponse]] = ...
|
||||
handler403: Union[str, Callable[..., HttpResponse]] = ...
|
||||
handler404: Union[str, Callable[..., HttpResponse]] = ...
|
||||
handler500: Union[str, Callable[..., HttpResponse]] = ...
|
||||
|
||||
IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]]
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from typing import Any, List, Union
|
||||
from typing import Any, List, Union, Iterable, Optional
|
||||
|
||||
from django.contrib.admin.options import BaseModelAdmin
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
_CheckError = Union[str, Error]
|
||||
|
||||
def check_admin_app(app_configs: None, **kwargs: Any) -> List[_CheckError]: ...
|
||||
def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[_CheckError]: ...
|
||||
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
||||
|
||||
class BaseModelAdminChecks:
|
||||
|
||||
@@ -24,7 +24,7 @@ class SimpleListFilter(ListFilter):
|
||||
parameter_name: Any = ...
|
||||
lookup_choices: Any = ...
|
||||
def value(self) -> Optional[str]: ...
|
||||
def lookups(self, request: Any, model_admin: Any) -> None: ...
|
||||
def lookups(self, request: Any, model_admin: Any) -> List[Tuple[Any, str]]: ...
|
||||
|
||||
class FieldListFilter(ListFilter):
|
||||
field: Field = ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Iterable
|
||||
|
||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||
from django.forms.boundfield import BoundField
|
||||
from django.forms.forms import BaseForm
|
||||
from django.forms.utils import ErrorDict
|
||||
from django.forms.widgets import Media, Widget
|
||||
from django.utils.safestring import SafeText
|
||||
@@ -23,7 +23,7 @@ class AdminForm:
|
||||
readonly_fields: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
form: AdminPasswordChangeForm,
|
||||
form: BaseForm,
|
||||
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
||||
prepopulated_fields: Dict[Any, Any],
|
||||
readonly_fields: Optional[Iterable[Any]] = ...,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union, Mapping, TypeVar
|
||||
|
||||
from django.forms.forms import BaseForm
|
||||
from django.forms.formsets import BaseFormSet
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
from django.contrib.admin.filters import ListFilter
|
||||
from django.contrib.admin.models import LogEntry
|
||||
@@ -26,8 +30,10 @@ from django.db.models.fields import Field
|
||||
|
||||
IS_POPUP_VAR: str
|
||||
TO_FIELD_VAR: str
|
||||
HORIZONTAL: Any
|
||||
VERTICAL: Any
|
||||
HORIZONTAL: Literal[1] = ...
|
||||
VERTICAL: Literal[2] = ...
|
||||
|
||||
_Direction = Union[Literal[1], Literal[2]]
|
||||
|
||||
def get_content_type_for_model(obj: Union[Type[Model], Model]) -> ContentType: ...
|
||||
def get_ul_class(radio_style: int) -> str: ...
|
||||
@@ -37,21 +43,35 @@ class IncorrectLookupParameters(Exception): ...
|
||||
FORMFIELD_FOR_DBFIELD_DEFAULTS: Any
|
||||
csrf_protect_m: Any
|
||||
|
||||
class _OptionalFieldOpts(TypedDict, total=False):
|
||||
classes: Sequence[str]
|
||||
description: str
|
||||
|
||||
class _FieldOpts(_OptionalFieldOpts, total=True):
|
||||
fields: Sequence[Union[str, Sequence[str]]]
|
||||
|
||||
# Workaround for mypy issue, a Sequence type should be preferred here.
|
||||
# https://github.com/python/mypy/issues/8921
|
||||
# _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]]
|
||||
_T = TypeVar("_T")
|
||||
_ListOrTuple = Union[Tuple[_T, ...], List[_T]]
|
||||
_FieldsetSpec = _ListOrTuple[Tuple[Optional[str], _FieldOpts]]
|
||||
|
||||
class BaseModelAdmin:
|
||||
autocomplete_fields: Any = ...
|
||||
raw_id_fields: Any = ...
|
||||
fields: Any = ...
|
||||
exclude: Any = ...
|
||||
fieldsets: Any = ...
|
||||
form: Any = ...
|
||||
filter_vertical: Any = ...
|
||||
filter_horizontal: Any = ...
|
||||
radio_fields: Any = ...
|
||||
prepopulated_fields: Any = ...
|
||||
formfield_overrides: Any = ...
|
||||
readonly_fields: Any = ...
|
||||
ordering: Any = ...
|
||||
sortable_by: Any = ...
|
||||
autocomplete_fields: Sequence[str] = ...
|
||||
raw_id_fields: Sequence[str] = ...
|
||||
fields: Sequence[Union[str, Sequence[str]]] = ...
|
||||
exclude: Sequence[str] = ...
|
||||
fieldsets: _FieldsetSpec = ...
|
||||
form: Type[BaseForm] = ...
|
||||
filter_vertical: Sequence[str] = ...
|
||||
filter_horizontal: Sequence[str] = ...
|
||||
radio_fields: Mapping[str, _Direction] = ...
|
||||
prepopulated_fields: Mapping[str, Sequence[str]] = ...
|
||||
formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] = ...
|
||||
readonly_fields: Sequence[Union[str, Callable[[Model], Any]]] = ...
|
||||
ordering: Sequence[str] = ...
|
||||
sortable_by: Sequence[str] = ...
|
||||
view_on_site: bool = ...
|
||||
show_full_result_count: bool = ...
|
||||
checks_class: Any = ...
|
||||
@@ -86,14 +106,14 @@ class BaseModelAdmin:
|
||||
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
|
||||
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
|
||||
def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ...
|
||||
def has_add_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
||||
def has_add_permission(self, request: HttpRequest) -> bool: ...
|
||||
def has_change_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
||||
def has_delete_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
||||
def has_view_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
||||
def has_module_permission(self, request: HttpRequest) -> bool: ...
|
||||
|
||||
class ModelAdmin(BaseModelAdmin):
|
||||
list_display: Sequence[Union[str, Callable]] = ...
|
||||
list_display: Sequence[Union[str, Callable[[Model], Any]]] = ...
|
||||
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]] = ...
|
||||
@@ -101,21 +121,21 @@ class ModelAdmin(BaseModelAdmin):
|
||||
list_max_show_all: int = ...
|
||||
list_editable: Sequence[str] = ...
|
||||
search_fields: Sequence[str] = ...
|
||||
date_hierarchy: Optional[Any] = ...
|
||||
date_hierarchy: Optional[str] = ...
|
||||
save_as: bool = ...
|
||||
save_as_continue: bool = ...
|
||||
save_on_top: bool = ...
|
||||
paginator: Any = ...
|
||||
paginator: Type = ...
|
||||
preserve_filters: bool = ...
|
||||
inlines: Sequence[Type[InlineModelAdmin]] = ...
|
||||
add_form_template: Any = ...
|
||||
change_form_template: Any = ...
|
||||
change_list_template: Any = ...
|
||||
delete_confirmation_template: Any = ...
|
||||
delete_selected_confirmation_template: Any = ...
|
||||
object_history_template: Any = ...
|
||||
popup_response_template: Any = ...
|
||||
actions: Any = ...
|
||||
add_form_template: str = ...
|
||||
change_form_template: str = ...
|
||||
change_list_template: str = ...
|
||||
delete_confirmation_template: str = ...
|
||||
delete_selected_confirmation_template: str = ...
|
||||
object_history_template: str = ...
|
||||
popup_response_template: str = ...
|
||||
actions: Sequence[Callable[[ModelAdmin, HttpRequest, QuerySet], None]] = ...
|
||||
action_form: Any = ...
|
||||
actions_on_top: bool = ...
|
||||
actions_on_bottom: bool = ...
|
||||
@@ -227,9 +247,9 @@ class ModelAdmin(BaseModelAdmin):
|
||||
def history_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
|
||||
|
||||
class InlineModelAdmin(BaseModelAdmin):
|
||||
model: Any = ...
|
||||
fk_name: Any = ...
|
||||
formset: Any = ...
|
||||
model: Type[Model] = ...
|
||||
fk_name: str = ...
|
||||
formset: BaseFormSet = ...
|
||||
extra: int = ...
|
||||
min_num: Optional[int] = ...
|
||||
max_num: Optional[int] = ...
|
||||
@@ -238,8 +258,8 @@ class InlineModelAdmin(BaseModelAdmin):
|
||||
verbose_name_plural: Optional[str] = ...
|
||||
can_delete: bool = ...
|
||||
show_change_link: bool = ...
|
||||
classes: Any = ...
|
||||
admin_site: Any = ...
|
||||
classes: Optional[Sequence[str]] = ...
|
||||
admin_site: AdminSite = ...
|
||||
parent_model: Any = ...
|
||||
opts: Any = ...
|
||||
has_registered_model: Any = ...
|
||||
|
||||
@@ -8,6 +8,8 @@ from django.template.response import TemplateResponse
|
||||
from django.urls.resolvers import URLResolver
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
all_sites: Any
|
||||
|
||||
class AlreadyRegistered(Exception): ...
|
||||
@@ -28,7 +30,7 @@ class AdminSite:
|
||||
name: str = ...
|
||||
_registry: Dict[Type[Model], ModelAdmin]
|
||||
def __init__(self, name: str = ...) -> None: ...
|
||||
def check(self, app_configs: None) -> List[Any]: ...
|
||||
def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[Any]: ...
|
||||
def register(
|
||||
self,
|
||||
model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
|
||||
@@ -37,7 +39,7 @@ class AdminSite:
|
||||
) -> None: ...
|
||||
def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
|
||||
def is_registered(self, model: Type[Model]) -> bool: ...
|
||||
def add_action(self, action: Callable, name: None = ...) -> None: ...
|
||||
def add_action(self, action: Callable, name: Optional[str] = ...) -> None: ...
|
||||
def disable_action(self, name: str) -> None: ...
|
||||
def get_action(self, name: str) -> Callable: ...
|
||||
@property
|
||||
@@ -52,14 +54,21 @@ class AdminSite:
|
||||
@property
|
||||
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
|
||||
def each_context(self, request: Any): ...
|
||||
def password_change(self, request: WSGIRequest, extra_context: Dict[str, str] = ...) -> TemplateResponse: ...
|
||||
def password_change_done(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...
|
||||
def password_change(
|
||||
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
||||
) -> TemplateResponse: ...
|
||||
def password_change_done(
|
||||
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
||||
) -> TemplateResponse: ...
|
||||
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[Any, Any]] = ...) -> HttpResponse: ...
|
||||
def logout(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...
|
||||
def login(self, request: WSGIRequest, extra_context: None = ...) -> HttpResponse: ...
|
||||
def logout(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
||||
def login(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
|
||||
def _build_app_dict(self, request: WSGIRequest, label: Optional[str] = ...) -> Dict[str, Any]: ...
|
||||
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
|
||||
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, str]] = ...) -> TemplateResponse: ...
|
||||
def app_index(self, request: WSGIRequest, app_label: str, extra_context: None = ...) -> TemplateResponse: ...
|
||||
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
||||
def app_index(
|
||||
self, request: WSGIRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ...
|
||||
) -> TemplateResponse: ...
|
||||
|
||||
class DefaultAdminSite(LazyObject): ...
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ResultList(list):
|
||||
def results(cl: ChangeList) -> Iterator[ResultList]: ...
|
||||
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
|
||||
def result_list(
|
||||
cl: ChangeList
|
||||
cl: ChangeList,
|
||||
) -> Dict[
|
||||
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
|
||||
]: ...
|
||||
|
||||
@@ -9,12 +9,10 @@ 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.mixins import FieldCacheMixin
|
||||
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
|
||||
|
||||
@@ -27,7 +25,7 @@ def unquote(s: str) -> str: ...
|
||||
def flatten(fields: Any) -> List[Union[Callable, str]]: ...
|
||||
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
|
||||
def get_deleted_objects(
|
||||
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite
|
||||
objs: Sequence[Optional[Model]], request: WSGIRequest, admin_site: AdminSite
|
||||
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
|
||||
|
||||
class NestedObjects(Collector):
|
||||
@@ -41,22 +39,14 @@ class NestedObjects(Collector):
|
||||
model_objs: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
|
||||
def collect(
|
||||
self,
|
||||
objs: Union[Sequence[Optional[Model]], QuerySet],
|
||||
source: Optional[Type[Model]] = ...,
|
||||
source_attr: Optional[str] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def related_objects(self, related: ManyToOneRel, objs: List[Model]) -> QuerySet: ...
|
||||
def nested(self, format_callback: Callable = ...) -> Union[List[SafeText], List[int]]: ...
|
||||
def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ...
|
||||
def related_objects(self, related: ManyToOneRel, objs: Sequence[Optional[Model]]) -> QuerySet: ...
|
||||
def nested(self, format_callback: Callable = ...) -> List[Any]: ...
|
||||
|
||||
def model_format_dict(obj: Any): ...
|
||||
def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ...
|
||||
def lookup_field(
|
||||
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
|
||||
) -> Tuple[Optional[Field], Callable, Callable]: ...
|
||||
) -> Tuple[Optional[Field], Any, Any]: ...
|
||||
def label_for_field(
|
||||
name: Union[Callable, str],
|
||||
model: Type[Model],
|
||||
@@ -65,16 +55,14 @@ def label_for_field(
|
||||
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(
|
||||
value: Any, field: Union[Field, reverse_related.OneToOneRel], empty_value_display: str
|
||||
) -> str: ...
|
||||
def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ...
|
||||
def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ...
|
||||
|
||||
class NotRelationField(Exception): ...
|
||||
|
||||
def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel]) -> Type[Model]: ...
|
||||
def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ...
|
||||
def get_fields_from_path(model: Type[Model], path: str) -> List[Union[Field, FieldCacheMixin]]: ...
|
||||
def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ...
|
||||
def construct_change_message(
|
||||
form: AdminPasswordChangeForm, formsets: None, add: bool
|
||||
) -> List[Dict[str, Dict[str, List[str]]]]: ...
|
||||
|
||||
@@ -81,9 +81,7 @@ class ChangeList:
|
||||
paginator: Any = ...
|
||||
def get_results(self, request: WSGIRequest) -> None: ...
|
||||
def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[CombinedExpression, str]]: ...
|
||||
def get_ordering(
|
||||
self, request: WSGIRequest, queryset: QuerySet
|
||||
) -> Union[List[Union[Combinable, str]], List[Union[OrderBy, str]]]: ...
|
||||
def get_ordering(self, request: WSGIRequest, queryset: QuerySet) -> List[Union[OrderBy, Combinable, str]]: ...
|
||||
def get_ordering_field_columns(self) -> OrderedDict: ...
|
||||
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
|
||||
def apply_select_related(self, qs: QuerySet) -> QuerySet: ...
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
from typing import Any, Optional, Set, Union
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.contrib.auth.models import AnonymousUser, User, Permission
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
_AnyUser = Union[Model, AnonymousUser]
|
||||
|
||||
UserModel: Any
|
||||
|
||||
class ModelBackend:
|
||||
class BaseBackend:
|
||||
def authenticate(
|
||||
self, request: Any, username: Optional[Union[int, str]] = ..., password: Optional[str] = ..., **kwargs: Any
|
||||
self, request: Any, username: Optional[str] = ..., password: Optional[str] = ..., **kwargs: Any
|
||||
) -> Optional[AbstractBaseUser]: ...
|
||||
def user_can_authenticate(self, user: Optional[AbstractBaseUser]) -> bool: ...
|
||||
def get_user_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, user_obj: AbstractBaseUser, obj: Optional[str] = ...) -> Set[str]: ...
|
||||
def has_perm(
|
||||
self, user_obj: Union[AbstractBaseUser, AnonymousUser], perm: str, obj: Optional[str] = ...
|
||||
) -> bool: ...
|
||||
def has_module_perms(self, user_obj: Union[AbstractBaseUser, AnonymousUser], app_label: str) -> bool: ...
|
||||
def get_user(self, user_id: int) -> AbstractBaseUser: ...
|
||||
def get_user(self, user_id: int) -> Optional[AbstractBaseUser]: ...
|
||||
def get_user_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||
def has_perm(self, user_obj: _AnyUser, perm: str, obj: Optional[Model] = ...) -> bool: ...
|
||||
|
||||
class ModelBackend(BaseBackend):
|
||||
def has_module_perms(self, user_obj: _AnyUser, app_label: str) -> bool: ...
|
||||
def user_can_authenticate(self, user: Optional[_AnyUser]) -> bool: ...
|
||||
def with_perm(
|
||||
self,
|
||||
perm: Union[str, Permission],
|
||||
is_active: bool = ...,
|
||||
include_superusers: bool = ...,
|
||||
obj: Optional[Model] = ...,
|
||||
): ...
|
||||
|
||||
class AllowAllUsersModelBackend(ModelBackend): ...
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import sys
|
||||
from typing import Any, Optional, Tuple, List, overload, TypeVar
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
from django.db import models
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
from typing_extensions import Literal
|
||||
else:
|
||||
from typing import Literal
|
||||
|
||||
_T = TypeVar("_T", bound=Model)
|
||||
|
||||
class BaseUserManager(models.Manager[_T]):
|
||||
@@ -13,17 +19,16 @@ class BaseUserManager(models.Manager[_T]):
|
||||
def get_by_natural_key(self, username: Optional[str]) -> _T: ...
|
||||
|
||||
class AbstractBaseUser(models.Model):
|
||||
REQUIRED_FIELDS: List[str] = ...
|
||||
|
||||
password = models.CharField(max_length=128)
|
||||
last_login = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
REQUIRED_FIELDS: List[str] = ...
|
||||
class Meta: ...
|
||||
def get_username(self) -> str: ...
|
||||
def natural_key(self) -> Tuple[str]: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
def is_anonymous(self) -> Literal[False]: ...
|
||||
@property
|
||||
def is_authenticated(self) -> bool: ...
|
||||
def is_authenticated(self) -> Literal[True]: ...
|
||||
def set_password(self, raw_password: Optional[str]) -> None: ...
|
||||
def check_password(self, raw_password: str) -> bool: ...
|
||||
def set_unusable_password(self) -> None: ...
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import CheckMessage
|
||||
|
||||
def check_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_user_model(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_models_permissions(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
from typing import Callable, List, Optional, Set, Union
|
||||
from typing import Callable, List, Optional, Set, Union, TypeVar, overload
|
||||
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
|
||||
from django.http.response import HttpResponseBase
|
||||
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
|
||||
_VIEW = TypeVar("_VIEW", bound=Callable[..., HttpResponseBase])
|
||||
|
||||
def user_passes_test(
|
||||
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
|
||||
) -> Callable: ...
|
||||
def login_required(
|
||||
function: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: Optional[str] = ...
|
||||
) -> Callable: ...
|
||||
test_func: Callable[[AbstractUser], bool], login_url: Optional[str] = ..., redirect_field_name: str = ...
|
||||
) -> Callable[[_VIEW], _VIEW]: ...
|
||||
|
||||
# There are two ways of calling @login_required: @with(arguments) and @bare
|
||||
@overload
|
||||
def login_required(redirect_field_name: str = ..., login_url: Optional[str] = ...) -> Callable[[_VIEW], _VIEW]: ...
|
||||
@overload
|
||||
def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: Optional[str] = ...) -> _VIEW: ...
|
||||
def permission_required(
|
||||
perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ...
|
||||
) -> Callable: ...
|
||||
) -> Callable[[_VIEW], _VIEW]: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, List
|
||||
from typing import Any, Callable, List, Optional
|
||||
|
||||
from django import http
|
||||
from django.http.response import HttpResponse, HttpResponseRedirect
|
||||
@@ -23,6 +23,6 @@ class PermissionRequiredMixin(AccessMixin):
|
||||
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
|
||||
class UserPassesTestMixin(AccessMixin):
|
||||
def test_func(self) -> None: ...
|
||||
def test_func(self) -> Optional[bool]: ...
|
||||
def get_test_func(self) -> Callable: ...
|
||||
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar
|
||||
import sys
|
||||
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
|
||||
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
|
||||
from django.contrib.auth.validators import UnicodeUsernameValidator
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
@@ -8,22 +10,33 @@ from django.db.models.manager import EmptyManager
|
||||
|
||||
from django.db import models
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
from typing_extensions import Literal
|
||||
else:
|
||||
from typing import Literal
|
||||
|
||||
_AnyUser = Union[Model, "AnonymousUser"]
|
||||
|
||||
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
|
||||
|
||||
class PermissionManager(models.Manager):
|
||||
class PermissionManager(models.Manager["Permission"]):
|
||||
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
|
||||
|
||||
class Permission(models.Model):
|
||||
content_type_id: int
|
||||
objects: PermissionManager
|
||||
|
||||
name = models.CharField(max_length=255)
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
codename = models.CharField(max_length=100)
|
||||
def natural_key(self) -> Tuple[str, str, str]: ...
|
||||
|
||||
class GroupManager(models.Manager):
|
||||
class GroupManager(models.Manager["Group"]):
|
||||
def get_by_natural_key(self, name: str) -> Group: ...
|
||||
|
||||
class Group(models.Model):
|
||||
objects: GroupManager
|
||||
|
||||
name = models.CharField(max_length=150)
|
||||
permissions = models.ManyToManyField(Permission)
|
||||
def natural_key(self): ...
|
||||
@@ -37,15 +50,24 @@ class UserManager(BaseUserManager[_T]):
|
||||
def create_superuser(
|
||||
self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any
|
||||
) -> _T: ...
|
||||
def with_perm(
|
||||
self,
|
||||
perm: Union[str, Permission],
|
||||
is_active: bool = ...,
|
||||
include_superusers: bool = ...,
|
||||
backend: Optional[Union[Type[ModelBackend], str]] = ...,
|
||||
obj: Optional[Model] = ...,
|
||||
): ...
|
||||
|
||||
class PermissionsMixin(models.Model):
|
||||
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: str, obj: Optional[str] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: None = ...) -> bool: ...
|
||||
groups = models.ManyToManyField(Group)
|
||||
user_permissions = models.ManyToManyField(Permission)
|
||||
def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_module_perms(self, app_label: str) -> bool: ...
|
||||
|
||||
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
|
||||
@@ -82,13 +104,14 @@ class AnonymousUser:
|
||||
def groups(self) -> EmptyManager: ...
|
||||
@property
|
||||
def user_permissions(self) -> EmptyManager: ...
|
||||
def get_group_permissions(self, obj: None = ...) -> Set[Any]: ...
|
||||
def get_all_permissions(self, obj: Any = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: str, obj: None = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: None = ...) -> bool: ...
|
||||
def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[Any]: ...
|
||||
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_module_perms(self, module: str) -> bool: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
def is_anonymous(self) -> Literal[True]: ...
|
||||
@property
|
||||
def is_authenticated(self) -> bool: ...
|
||||
def is_authenticated(self) -> Literal[False]: ...
|
||||
def get_username(self) -> str: ...
|
||||
|
||||
@@ -55,6 +55,7 @@ class PasswordResetDoneView(PasswordContextMixin, TemplateView):
|
||||
class PasswordResetConfirmView(PasswordContextMixin, FormView):
|
||||
post_reset_login: bool = ...
|
||||
post_reset_login_backend: Any = ...
|
||||
reset_url_token: str = ...
|
||||
title: Any = ...
|
||||
token_generator: Any = ...
|
||||
validlink: bool = ...
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_generic_foreign_keys(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
def check_model_name_lengths(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
from datetime import date, datetime as datetime
|
||||
from decimal import Decimal
|
||||
from typing import Any, Optional, Union
|
||||
from typing import Any, Optional, SupportsInt, Union
|
||||
|
||||
register: Any
|
||||
|
||||
def ordinal(value: Optional[str]) -> Optional[str]: ...
|
||||
def intcomma(value: Optional[Union[Decimal, float, str]], use_l10n: bool = ...) -> str: ...
|
||||
def ordinal(value: Optional[Union[str, SupportsInt]]) -> Optional[str]: ...
|
||||
def intcomma(value: Optional[Union[str, SupportsInt]], use_l10n: bool = ...) -> str: ...
|
||||
|
||||
intword_converters: Any
|
||||
|
||||
def intword(value: Optional[str]) -> Optional[Union[int, str]]: ...
|
||||
def apnumber(value: Optional[str]) -> Optional[Union[int, str]]: ...
|
||||
def intword(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
||||
def apnumber(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
||||
def naturalday(value: Optional[Union[date, str]], arg: None = ...) -> Optional[str]: ...
|
||||
def naturaltime(value: datetime) -> str: ...
|
||||
|
||||
18
django-stubs/contrib/postgres/constraints.pyi
Normal file
18
django-stubs/contrib/postgres/constraints.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Optional, Sequence, Tuple, Union
|
||||
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.db.models.expressions import Combinable
|
||||
from django.db.models.query_utils import Q
|
||||
|
||||
class ExclusionConstraint(BaseConstraint):
|
||||
expressions: Sequence[Tuple[Union[str, Combinable], str]]
|
||||
index_type: str
|
||||
condition: Optional[Q]
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
expressions: Sequence[Tuple[Union[str, Combinable], str]],
|
||||
condition: Optional[Q] = ...,
|
||||
index_type: Optional[str] = ...,
|
||||
): ...
|
||||
@@ -8,6 +8,8 @@ from .ranges import (
|
||||
FloatRangeField as FloatRangeField,
|
||||
DateRangeField as DateRangeField,
|
||||
DateTimeRangeField as DateTimeRangeField,
|
||||
RangeOperators as RangeOperators,
|
||||
RangeBoundary as RangeBoundary,
|
||||
)
|
||||
from .hstore import HStoreField as HStoreField
|
||||
from .citext import (
|
||||
|
||||
@@ -29,3 +29,20 @@ class DateTimeRangeField(RangeField):
|
||||
|
||||
class DateRangeField(RangeField):
|
||||
def __get__(self, instance, owner) -> DateRange: ...
|
||||
|
||||
class RangeOperators:
|
||||
EQUAL: str
|
||||
NOT_EQUAL: str
|
||||
CONTAINS: str
|
||||
CONTAINED_BY: str
|
||||
OVERLAPS: str
|
||||
FULLY_LT: str
|
||||
FULLY_GT: str
|
||||
NOT_LT: str
|
||||
NOT_GT: str
|
||||
ADJACENT_TO: str
|
||||
|
||||
class RangeBoundary(models.Expression):
|
||||
lower: str
|
||||
upper: str
|
||||
def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...): ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any, Dict, List, Optional, Union, Protocol
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
from django.contrib.sites.requests import RequestSite
|
||||
@@ -13,10 +13,19 @@ class SitemapNotFound(Exception): ...
|
||||
|
||||
def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None: ...
|
||||
|
||||
class _SupportsLen(Protocol):
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
class _SupportsCount(Protocol):
|
||||
def count(self) -> int: ...
|
||||
|
||||
class _SupportsOrdered(Protocol):
|
||||
ordered: bool = ...
|
||||
|
||||
class Sitemap:
|
||||
limit: int = ...
|
||||
protocol: Optional[str] = ...
|
||||
def items(self) -> List[Any]: ...
|
||||
def items(self) -> Union[_SupportsLen, _SupportsCount, _SupportsOrdered]: ...
|
||||
def location(self, obj: Model) -> str: ...
|
||||
@property
|
||||
def paginator(self) -> Paginator: ...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from typing import Any
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.apps.registry import Apps
|
||||
from django.contrib.sites.apps import SitesConfig
|
||||
|
||||
def create_default_site(
|
||||
app_config: SitesConfig,
|
||||
app_config: AppConfig,
|
||||
verbosity: int = ...,
|
||||
interactive: bool = ...,
|
||||
using: str = ...,
|
||||
|
||||
@@ -6,15 +6,16 @@ from django.db import models
|
||||
|
||||
SITE_CACHE: Any
|
||||
|
||||
class SiteManager(models.Manager):
|
||||
class SiteManager(models.Manager["Site"]):
|
||||
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):
|
||||
domain: models.CharField = ...
|
||||
name: models.CharField = ...
|
||||
objects: SiteManager = ...
|
||||
objects: SiteManager
|
||||
|
||||
domain = models.CharField(max_length=100)
|
||||
name = models.CharField(max_length=50)
|
||||
def natural_key(self) -> Tuple[str]: ...
|
||||
|
||||
def clear_site_cache(sender: Type[Site], **kwargs: Any) -> None: ...
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
def check_finders(app_configs: None = ..., **kwargs: Any) -> List[Error]: ...
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_finders(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...
|
||||
|
||||
@@ -37,7 +37,7 @@ def get_finders() -> Iterator[BaseFinder]: ...
|
||||
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
|
||||
@overload
|
||||
def get_finder(
|
||||
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"]
|
||||
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"],
|
||||
) -> AppDirectoriesFinder: ...
|
||||
@overload
|
||||
def get_finder(import_path: str) -> BaseFinder: ...
|
||||
|
||||
6
django-stubs/core/cache/backends/base.pyi
vendored
6
django-stubs/core/cache/backends/base.pyi
vendored
@@ -19,16 +19,16 @@ class BaseCache:
|
||||
def __init__(self, params: Dict[str, Any]) -> None: ...
|
||||
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
|
||||
def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ...
|
||||
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> bool: ...
|
||||
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
|
||||
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> bool: ...
|
||||
def delete(self, key: Any, version: Optional[Any] = ...) -> None: ...
|
||||
def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ...
|
||||
def get_or_set(
|
||||
self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> Optional[Any]: ...
|
||||
def has_key(self, key: Any, version: Optional[Any] = ...): ...
|
||||
def has_key(self, key: Any, version: Optional[Any] = ...) -> bool: ...
|
||||
def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
from .messages import Warning as Warning, Info as Info, Debug as Debug, Error as Error, Critical as Critical
|
||||
from .messages import (
|
||||
CheckMessage as CheckMessage,
|
||||
Debug as Debug,
|
||||
Info as Info,
|
||||
Warning as Warning,
|
||||
Error as Error,
|
||||
Critical as Critical,
|
||||
DEBUG as DEBUG,
|
||||
INFO as INFO,
|
||||
WARNING as WARNING,
|
||||
ERROR as ERROR,
|
||||
CRITICAL as CRITICAL,
|
||||
)
|
||||
|
||||
from .registry import run_checks as run_checks, Tags as Tags, register as register
|
||||
from .registry import register as register, run_checks as run_checks, tag_exists as tag_exists, Tags as Tags
|
||||
|
||||
from . import model_checks as model_checks
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
E001: Any
|
||||
|
||||
def check_default_cache_is_configured(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
def check_default_cache_is_configured(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...
|
||||
|
||||
@@ -7,11 +7,11 @@ ERROR: int
|
||||
CRITICAL: int
|
||||
|
||||
class CheckMessage:
|
||||
level: Any = ...
|
||||
msg: Any = ...
|
||||
hint: Any = ...
|
||||
level: int = ...
|
||||
msg: str = ...
|
||||
hint: Optional[str] = ...
|
||||
obj: Any = ...
|
||||
id: Any = ...
|
||||
id: Optional[str] = ...
|
||||
def __init__(
|
||||
self, level: int, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...
|
||||
) -> None: ...
|
||||
@@ -25,19 +25,9 @@ class Info(CheckMessage):
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Warning(CheckMessage):
|
||||
hint: str
|
||||
id: str
|
||||
level: int
|
||||
msg: str
|
||||
obj: Any
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Error(CheckMessage):
|
||||
hint: None
|
||||
id: str
|
||||
level: int
|
||||
msg: str
|
||||
obj: Any
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Critical(CheckMessage):
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
def check_all_models(app_configs: None = ..., **kwargs: Any) -> List[Warning]: ...
|
||||
def check_lazy_references(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_all_models(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
|
||||
def check_lazy_references(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
|
||||
@@ -12,6 +12,7 @@ class Tags:
|
||||
security: str = ...
|
||||
signals: str = ...
|
||||
templates: str = ...
|
||||
translation: str = ...
|
||||
urls: str = ...
|
||||
|
||||
class CheckRegistry:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
SECRET_KEY_MIN_LENGTH: int
|
||||
SECRET_KEY_MIN_UNIQUE_CHARACTERS: int
|
||||
W001: Any
|
||||
@@ -17,15 +19,15 @@ W019: Any
|
||||
W020: Any
|
||||
W021: Any
|
||||
|
||||
def check_security_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xframe_options_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts_include_subdomains(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts_preload(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_content_type_nosniff(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xss_filter(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_ssl_redirect(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_secret_key(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_debug(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xframe_deny(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_allowed_hosts(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_security_middleware(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xframe_options_middleware(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts_include_subdomains(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts_preload(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_content_type_nosniff(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xss_filter(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_ssl_redirect(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_secret_key(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_debug(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xframe_deny(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_allowed_hosts(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
W003: Any
|
||||
W016: Any
|
||||
|
||||
def check_csrf_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_csrf_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_csrf_middleware(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_csrf_cookie_secure(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def add_session_cookie_message(message: Any): ...
|
||||
|
||||
W010: Any
|
||||
@@ -14,5 +16,5 @@ W013: Any
|
||||
W014: Any
|
||||
W015: Any
|
||||
|
||||
def check_session_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_session_cookie_httponly(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_session_cookie_secure(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def check_session_cookie_httponly(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
E001: Any
|
||||
E002: Any
|
||||
|
||||
def check_setting_app_dirs_loaders(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
def check_string_if_invalid_is_string(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
def check_setting_app_dirs_loaders(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...
|
||||
def check_string_if_invalid_is_string(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from typing import Any, Callable, List, Tuple, Union
|
||||
from typing import Any, Callable, List, Tuple, Union, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import CheckMessage, Error, Warning
|
||||
from django.urls.resolvers import URLPattern, URLResolver
|
||||
|
||||
def check_url_config(app_configs: None, **kwargs: Any) -> List[CheckMessage]: ...
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_url_config(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_resolver(resolver: Union[Tuple[str, Callable], URLPattern, URLResolver]) -> List[CheckMessage]: ...
|
||||
def check_url_namespaces_unique(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_url_namespaces_unique(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
|
||||
def get_warning_for_invalid_pattern(pattern: Any) -> List[Error]: ...
|
||||
def check_url_settings(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
def check_url_settings(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...
|
||||
def E006(name: str) -> Error: ...
|
||||
|
||||
@@ -8,7 +8,7 @@ _T = TypeVar("_T", bound="File")
|
||||
|
||||
class File(FileProxyMixin, IO[Any]):
|
||||
DEFAULT_CHUNK_SIZE: Any = ...
|
||||
file: StringIO = ...
|
||||
file: IO[Any] = ...
|
||||
name: str = ...
|
||||
mode: str = ...
|
||||
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
||||
|
||||
@@ -15,14 +15,14 @@ class SkipFile(UploadFileException): ...
|
||||
class StopFutureHandlers(UploadFileException): ...
|
||||
|
||||
class FileUploadHandler:
|
||||
chunk_size = ... # type: int
|
||||
file_name = ... # type: Optional[str]
|
||||
content_type = ... # type: Optional[str]
|
||||
content_length = ... # type: Optional[int]
|
||||
charset = ... # type: Optional[str]
|
||||
content_type_extra = ... # type: Optional[Dict[str, str]]
|
||||
request = ... # type: Optional[HttpRequest]
|
||||
field_name = ... # type: str
|
||||
chunk_size: int = ...
|
||||
file_name: Optional[str] = ...
|
||||
content_type: Optional[str] = ...
|
||||
content_length: Optional[int] = ...
|
||||
charset: Optional[str] = ...
|
||||
content_type_extra: Optional[Dict[str, str]] = ...
|
||||
request: Optional[HttpRequest] = ...
|
||||
field_name: str = ...
|
||||
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
|
||||
def handle_raw_input(
|
||||
self,
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.http.response import HttpResponse
|
||||
|
||||
from django.core.handlers import base
|
||||
from django.http import HttpRequest
|
||||
from django.http.response import HttpResponse
|
||||
|
||||
_Stream = Union[BytesIO, str]
|
||||
_WSGIEnviron = Dict[str, Any]
|
||||
@@ -22,7 +20,6 @@ class LimitedStream:
|
||||
|
||||
class WSGIRequest(HttpRequest):
|
||||
environ: _WSGIEnviron = ...
|
||||
user: AbstractUser
|
||||
session: SessionBase
|
||||
encoding: Any = ...
|
||||
def __init__(self, environ: _WSGIEnviron) -> None: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import types
|
||||
from typing import Any, TypeVar, Type, Iterable
|
||||
from typing import Any, TypeVar, Type, Iterable, Optional
|
||||
|
||||
from django.core.mail.message import EmailMessage
|
||||
|
||||
@@ -7,7 +7,7 @@ _T = TypeVar("_T", bound="BaseEmailBackend")
|
||||
|
||||
class BaseEmailBackend:
|
||||
def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ...
|
||||
def open(self) -> bool: ...
|
||||
def open(self) -> Optional[bool]: ...
|
||||
def close(self) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(
|
||||
|
||||
3
django-stubs/core/mail/backends/console.pyi
Normal file
3
django-stubs/core/mail/backends/console.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
|
||||
class EmailBackend(BaseEmailBackend): ...
|
||||
3
django-stubs/core/mail/backends/dummy.pyi
Normal file
3
django-stubs/core/mail/backends/dummy.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
|
||||
class EmailBackend(BaseEmailBackend): ...
|
||||
3
django-stubs/core/mail/backends/filebased.pyi
Normal file
3
django-stubs/core/mail/backends/filebased.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
|
||||
class EmailBackend(BaseEmailBackend): ...
|
||||
3
django-stubs/core/mail/backends/locmem.pyi
Normal file
3
django-stubs/core/mail/backends/locmem.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
|
||||
class EmailBackend(BaseEmailBackend): ...
|
||||
18
django-stubs/core/mail/backends/smtp.pyi
Normal file
18
django-stubs/core/mail/backends/smtp.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
import smtplib
|
||||
import threading
|
||||
from typing import Optional, Union
|
||||
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
|
||||
class EmailBackend(BaseEmailBackend):
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
username: str = ...
|
||||
password: str = ...
|
||||
use_tls: bool = ...
|
||||
use_ssl: bool = ...
|
||||
timeout: Optional[int] = ...
|
||||
ssl_keyfile: Optional[str] = ...
|
||||
ssl_certfile: Optional[str] = ...
|
||||
connection: Union[smtplib.SMTP_SSL, smtplib.SMTP, None] = ...
|
||||
_lock: threading.RLock = ...
|
||||
@@ -1,8 +1,10 @@
|
||||
from email._policybase import Policy # type: ignore
|
||||
from email.message import Message
|
||||
from email.mime.base import MIMEBase
|
||||
from email.mime.message import MIMEMessage
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, overload
|
||||
|
||||
utf8_charset: Any
|
||||
utf8_charset_qp: Any
|
||||
@@ -43,6 +45,11 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
|
||||
self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any
|
||||
) -> None: ...
|
||||
|
||||
_AttachmentContent = Union[bytes, EmailMessage, Message, SafeMIMEText, str]
|
||||
_AttachmentTuple = Union[
|
||||
Tuple[str, _AttachmentContent], Tuple[Optional[str], _AttachmentContent, str], Tuple[str, _AttachmentContent, None]
|
||||
]
|
||||
|
||||
class EmailMessage:
|
||||
content_subtype: str = ...
|
||||
mixed_subtype: str = ...
|
||||
@@ -62,42 +69,42 @@ class EmailMessage:
|
||||
subject: str = ...,
|
||||
body: Optional[str] = ...,
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[Union[Sequence[str], str]] = ...,
|
||||
bcc: Optional[Union[Sequence[str], str]] = ...,
|
||||
to: Optional[Sequence[str]] = ...,
|
||||
bcc: Optional[Sequence[str]] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
attachments: Optional[Union[List[Tuple[str, Union[str, bytes], str]], List[MIMEText]]] = ...,
|
||||
attachments: Optional[Sequence[Union[MIMEBase, _AttachmentTuple]]] = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
cc: Optional[Union[Sequence[str], str]] = ...,
|
||||
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
|
||||
cc: Optional[Sequence[str]] = ...,
|
||||
reply_to: Optional[Sequence[str]] = ...,
|
||||
) -> None: ...
|
||||
def get_connection(self, fail_silently: bool = ...) -> Any: ...
|
||||
# TODO: when typeshed gets more types for email.Message, move it to MIMEMessage, now it has too many false-positives
|
||||
def message(self) -> Any: ...
|
||||
def recipients(self) -> List[str]: ...
|
||||
def send(self, fail_silently: bool = ...) -> int: ...
|
||||
def attach(
|
||||
self,
|
||||
filename: Optional[Union[MIMEText, str]] = ...,
|
||||
content: Optional[Union[bytes, EmailMessage, SafeMIMEText, str]] = ...,
|
||||
mimetype: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def attach(self, filename: MIMEText = ...) -> None: ...
|
||||
@overload
|
||||
def attach(self, filename: None = ..., content: _AttachmentContent = ..., mimetype: str = ...) -> None: ...
|
||||
@overload
|
||||
def attach(self, filename: str = ..., content: _AttachmentContent = ..., mimetype: Optional[str] = ...) -> None: ...
|
||||
def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ...
|
||||
|
||||
class EmailMultiAlternatives(EmailMessage):
|
||||
alternative_subtype: str = ...
|
||||
alternatives: Any = ...
|
||||
alternatives: Sequence[Tuple[_AttachmentContent, str]] = ...
|
||||
def __init__(
|
||||
self,
|
||||
subject: str = ...,
|
||||
body: str = ...,
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[List[str]] = ...,
|
||||
bcc: Optional[List[str]] = ...,
|
||||
to: Optional[Sequence[str]] = ...,
|
||||
bcc: Optional[Sequence[str]] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
attachments: None = ...,
|
||||
attachments: Optional[Sequence[Union[MIMEBase, _AttachmentTuple]]] = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
alternatives: Optional[List[Tuple[str, str]]] = ...,
|
||||
cc: None = ...,
|
||||
reply_to: None = ...,
|
||||
alternatives: Optional[Sequence[Tuple[_AttachmentContent, str]]] = ...,
|
||||
cc: Optional[Sequence[str]] = ...,
|
||||
reply_to: Optional[Sequence[str]] = ...,
|
||||
) -> None: ...
|
||||
def attach_alternative(self, content: str, mimetype: str) -> None: ...
|
||||
def attach_alternative(self, content: _AttachmentContent, mimetype: str) -> None: ...
|
||||
|
||||
@@ -23,13 +23,16 @@ class OutputWrapper(TextIOBase):
|
||||
@property
|
||||
def style_func(self): ...
|
||||
@style_func.setter
|
||||
def style_func(self, style_func: Any): ...
|
||||
def style_func(self, style_func: Callable[[str], str]): ...
|
||||
ending: str = ...
|
||||
def __init__(
|
||||
self, out: Union[StringIO, TextIOWrapper], style_func: Optional[Callable] = ..., ending: str = ...
|
||||
self, out: Union[StringIO, TextIOWrapper], style_func: Optional[Callable[[str], str]] = ..., ending: str = ...
|
||||
) -> None: ...
|
||||
def __getattr__(self, name: str) -> Callable: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def write( # type: ignore[override]
|
||||
self, msg: str, style_func: Optional[Callable[[str], str]] = ..., ending: Optional[str] = ...
|
||||
) -> None: ...
|
||||
|
||||
class BaseCommand:
|
||||
help: str = ...
|
||||
@@ -63,7 +66,7 @@ class BaseCommand:
|
||||
fail_level: int = ...,
|
||||
) -> None: ...
|
||||
def check_migrations(self) -> None: ...
|
||||
def handle(self, *args: Any, **options: Any) -> None: ...
|
||||
def handle(self, *args: Any, **options: Any) -> Optional[str]: ...
|
||||
|
||||
class AppCommand(BaseCommand):
|
||||
missing_args_message: str = ...
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
def supports_color() -> bool: ...
|
||||
|
||||
class Style:
|
||||
def DEBUG(self, text: str) -> str: ...
|
||||
def INFO(self, text: str) -> str: ...
|
||||
def ERROR(self, text: str) -> str: ...
|
||||
def SUCCESS(self, text: str) -> str: ...
|
||||
def WARNING(self, text: str) -> str: ...
|
||||
def ERROR(self, text: str) -> str: ...
|
||||
def NOTICE(self, text: str) -> str: ...
|
||||
def SQL_FIELD(self, text: str) -> str: ...
|
||||
def SQL_COLTYPE(self, text: str) -> str: ...
|
||||
def SQL_KEYWORD(self, text: str) -> str: ...
|
||||
def SQL_TABLE(self, text: str) -> str: ...
|
||||
def HTTP_INFO(self, text: str) -> str: ...
|
||||
def HTTP_SUCCESS(self, text: str) -> str: ...
|
||||
def HTTP_REDIRECT(self, text: str) -> str: ...
|
||||
def HTTP_NOT_MODIFIED(self, text: str) -> str: ...
|
||||
def HTTP_BAD_REQUEST(self, text: str) -> str: ...
|
||||
def HTTP_NOT_FOUND(self, text: str) -> str: ...
|
||||
def HTTP_SERVER_ERROR(self, text: str) -> str: ...
|
||||
def MIGRATE_HEADING(self, text: str) -> str: ...
|
||||
def MIGRATE_LABEL(self, text: str) -> str: ...
|
||||
def ERROR_OUTPUT(self, text: str) -> str: ...
|
||||
|
||||
def make_style(config_string: str = ...) -> Style: ...
|
||||
def no_style() -> Style: ...
|
||||
|
||||
@@ -8,13 +8,13 @@ class InvalidPage(Exception): ...
|
||||
class PageNotAnInteger(InvalidPage): ...
|
||||
class EmptyPage(InvalidPage): ...
|
||||
|
||||
class SupportsLen(Protocol):
|
||||
class _SupportsLen(Protocol):
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
class SupportsCount(Protocol):
|
||||
class _SupportsCount(Protocol):
|
||||
def count(self) -> int: ...
|
||||
|
||||
class SupportsOrdered(Protocol):
|
||||
class _SupportsOrdered(Protocol):
|
||||
ordered: bool = ...
|
||||
|
||||
class Paginator:
|
||||
@@ -24,7 +24,7 @@ class Paginator:
|
||||
allow_empty_first_page: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
object_list: Union[SupportsLen, SupportsCount, SupportsOrdered],
|
||||
object_list: Union[_SupportsLen, _SupportsCount, _SupportsOrdered],
|
||||
per_page: Union[int, str],
|
||||
orphans: int = ...,
|
||||
allow_empty_first_page: bool = ...,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from datetime import date
|
||||
from io import BufferedReader, StringIO, TextIOWrapper
|
||||
from typing import Any, Dict, Iterable, List, Mapping, Optional, Type, Union
|
||||
from typing import Any, Dict, Iterable, List, Mapping, Optional, Type, Union, Collection
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.management.base import OutputWrapper
|
||||
@@ -35,18 +35,18 @@ class Serializer:
|
||||
internal_use_only: bool = ...
|
||||
progress_class: Any = ...
|
||||
stream_class: Any = ...
|
||||
options: Any = ...
|
||||
options: Dict[str, Any] = ...
|
||||
stream: Any = ...
|
||||
selected_fields: Any = ...
|
||||
use_natural_foreign_keys: Any = ...
|
||||
use_natural_primary_keys: Any = ...
|
||||
selected_fields: Optional[Collection[str]] = ...
|
||||
use_natural_foreign_keys: bool = ...
|
||||
use_natural_primary_keys: bool = ...
|
||||
first: bool = ...
|
||||
def serialize(
|
||||
self,
|
||||
queryset: Iterable[Model],
|
||||
*,
|
||||
stream: Optional[Any] = ...,
|
||||
fields: Optional[Any] = ...,
|
||||
fields: Optional[Collection[str]] = ...,
|
||||
use_natural_foreign_keys: bool = ...,
|
||||
use_natural_primary_keys: bool = ...,
|
||||
progress_output: Optional[Any] = ...,
|
||||
@@ -63,7 +63,7 @@ class Serializer:
|
||||
def getvalue(self) -> Optional[Union[bytes, str]]: ...
|
||||
|
||||
class Deserializer:
|
||||
options: Any = ...
|
||||
options: Dict[str, Any] = ...
|
||||
stream: Any = ...
|
||||
def __init__(self, stream_or_string: Union[BufferedReader, TextIOWrapper, str], **options: Any) -> None: ...
|
||||
def __iter__(self) -> Deserializer: ...
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from io import TextIOWrapper
|
||||
from typing import Any, Union, Dict
|
||||
from uuid import UUID
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.core.serializers.python import Serializer as PythonSerializer
|
||||
from django.db.models.base import Model
|
||||
|
||||
class Serializer(PythonSerializer):
|
||||
json_kwargs: Dict[str, Any]
|
||||
options: Dict[str, None]
|
||||
selected_fields: None
|
||||
stream: TextIOWrapper
|
||||
use_natural_foreign_keys: bool
|
||||
use_natural_primary_keys: bool
|
||||
internal_use_only: bool = ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def end_object(self, obj: Model) -> None: ...
|
||||
|
||||
def Deserializer(stream_or_string: Any, **options: Any) -> None: ...
|
||||
|
||||
@@ -29,4 +15,3 @@ class DjangoJSONEncoder(json.JSONEncoder):
|
||||
indent: int
|
||||
skipkeys: bool
|
||||
sort_keys: bool
|
||||
def default(self, o: Union[datetime, Decimal, UUID]) -> str: ...
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
from collections import OrderedDict
|
||||
from io import TextIOWrapper
|
||||
from typing import Any, Dict, Iterator, List
|
||||
from typing import Any, Dict, Iterator, List, Optional
|
||||
|
||||
from django.core.serializers.base import DeserializedObject
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.related import ForeignKey, ManyToManyField
|
||||
|
||||
from django.core.serializers import base
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class Serializer(base.Serializer):
|
||||
options: Dict[Any, Any]
|
||||
selected_fields: None
|
||||
stream: TextIOWrapper
|
||||
use_natural_foreign_keys: bool
|
||||
use_natural_primary_keys: bool
|
||||
internal_use_only: bool = ...
|
||||
objects: List[Any] = ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def start_object(self, obj: Model) -> None: ...
|
||||
def end_object(self, obj: Model) -> None: ...
|
||||
def get_dump_object(self, obj: Model) -> OrderedDict: ...
|
||||
def handle_field(self, obj: Model, field: Field) -> None: ...
|
||||
def handle_fk_field(self, obj: Model, field: ForeignKey) -> None: ...
|
||||
def handle_m2m_field(self, obj: Model, field: ManyToManyField) -> None: ...
|
||||
|
||||
def Deserializer(
|
||||
object_list: List[Dict[str, Any]], *, using: Any = ..., ignorenonexistent: bool = ..., **options: Any
|
||||
object_list: List[Dict[str, Any]], *, using: Optional[str] = ..., ignorenonexistent: bool = ..., **options: Any
|
||||
) -> Iterator[DeserializedObject]: ...
|
||||
|
||||
@@ -21,7 +21,11 @@ def dumps(
|
||||
obj: Any, key: None = ..., salt: str = ..., serializer: Type[Serializer] = ..., compress: bool = ...
|
||||
) -> str: ...
|
||||
def loads(
|
||||
s: str, key: None = ..., salt: str = ..., serializer: Type[Serializer] = ..., max_age: Optional[int] = ...
|
||||
s: str,
|
||||
key: None = ...,
|
||||
salt: str = ...,
|
||||
serializer: Type[Serializer] = ...,
|
||||
max_age: Optional[Union[int, timedelta]] = ...,
|
||||
) -> Any: ...
|
||||
|
||||
class Signer:
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from re import RegexFlag
|
||||
from typing import Any, Dict, List, Optional, Union, Pattern, Collection
|
||||
from uuid import UUID
|
||||
from typing import Any, Callable, Collection, Dict, List, Optional, Pattern, Tuple, Union
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.core.exceptions import ValidationError as ValidationError # noqa: F401
|
||||
|
||||
EMPTY_VALUES: Any
|
||||
|
||||
_Regex = Union[str, Pattern[str]]
|
||||
_ErrorMessage = Union[str, Any]
|
||||
|
||||
def _lazy_re_compile(regex: _Regex, flags: int = ...): ...
|
||||
|
||||
class RegexValidator:
|
||||
regex: _Regex = ...
|
||||
message: Any = ...
|
||||
message: str = ...
|
||||
code: str = ...
|
||||
inverse_match: bool = ...
|
||||
flags: int = ...
|
||||
def __init__(
|
||||
self,
|
||||
regex: Optional[_Regex] = ...,
|
||||
message: Optional[str] = ...,
|
||||
message: Optional[_ErrorMessage] = ...,
|
||||
code: Optional[str] = ...,
|
||||
inverse_match: Optional[bool] = ...,
|
||||
flags: Optional[RegexFlag] = ...,
|
||||
@@ -33,95 +31,82 @@ class URLValidator(RegexValidator):
|
||||
ul: str = ...
|
||||
ipv4_re: str = ...
|
||||
ipv6_re: str = ...
|
||||
hostname_re: Any = ...
|
||||
domain_re: Any = ...
|
||||
tld_re: Any = ...
|
||||
host_re: Any = ...
|
||||
schemes: Any = ...
|
||||
hostname_re: str = ...
|
||||
domain_re: str = ...
|
||||
tld_re: str = ...
|
||||
host_re: str = ...
|
||||
schemes: List[str] = ...
|
||||
def __init__(self, schemes: Optional[Collection[str]] = ..., **kwargs: Any) -> None: ...
|
||||
|
||||
integer_validator: Any
|
||||
integer_validator: RegexValidator = ...
|
||||
|
||||
def validate_integer(value: Optional[Union[float, str]]) -> None: ...
|
||||
|
||||
class EmailValidator:
|
||||
message: Any = ...
|
||||
message: str = ...
|
||||
code: str = ...
|
||||
user_regex: Any = ...
|
||||
domain_regex: Any = ...
|
||||
literal_regex: Any = ...
|
||||
domain_whitelist: Any = ...
|
||||
user_regex: Pattern = ...
|
||||
domain_regex: Pattern = ...
|
||||
literal_regex: Pattern = ...
|
||||
domain_whitelist: List[str] = ...
|
||||
def __init__(
|
||||
self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[Collection[str]] = ...
|
||||
self,
|
||||
message: Optional[_ErrorMessage] = ...,
|
||||
code: Optional[str] = ...,
|
||||
whitelist: Optional[Collection[str]] = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, value: Optional[str]) -> None: ...
|
||||
def validate_domain_part(self, domain_part: str) -> bool: ...
|
||||
|
||||
validate_email: Any
|
||||
slug_re: Any
|
||||
validate_slug: Any
|
||||
slug_unicode_re: Any
|
||||
validate_unicode_slug: Any
|
||||
validate_email: EmailValidator = ...
|
||||
slug_re: Pattern = ...
|
||||
validate_slug: RegexValidator = ...
|
||||
slug_unicode_re: Pattern = ...
|
||||
validate_unicode_slug: RegexValidator = ...
|
||||
|
||||
def validate_ipv4_address(value: str) -> None: ...
|
||||
def validate_ipv6_address(value: str) -> None: ...
|
||||
def validate_ipv46_address(value: str) -> None: ...
|
||||
|
||||
ip_address_validator_map: Any
|
||||
_IPValidator = Tuple[Callable[[Any], None], str]
|
||||
ip_address_validator_map: Dict[str, _IPValidator]
|
||||
|
||||
def ip_address_validators(protocol: str, unpack_ipv4: bool) -> Any: ...
|
||||
def ip_address_validators(protocol: str, unpack_ipv4: bool) -> _IPValidator: ...
|
||||
def int_list_validator(
|
||||
sep: str = ..., message: None = ..., code: str = ..., allow_negative: bool = ...
|
||||
sep: str = ..., message: Optional[_ErrorMessage] = ..., code: str = ..., allow_negative: bool = ...
|
||||
) -> RegexValidator: ...
|
||||
|
||||
validate_comma_separated_integer_list: Any
|
||||
|
||||
class BaseValidator:
|
||||
message: Any = ...
|
||||
message: str = ...
|
||||
code: str = ...
|
||||
limit_value: Any = ...
|
||||
def __init__(self, limit_value: Any, message: Optional[str] = ...) -> None: ...
|
||||
def __init__(self, limit_value: Any, message: Optional[_ErrorMessage] = ...) -> None: ...
|
||||
def __call__(self, value: Any) -> None: ...
|
||||
def compare(self, a: bool, b: bool) -> bool: ...
|
||||
def compare(self, a: Any, b: Any) -> bool: ...
|
||||
def clean(self, x: Any) -> Any: ...
|
||||
|
||||
class MaxValueValidator(BaseValidator):
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: Union[datetime, Decimal, float], b: Union[datetime, Decimal, float]) -> bool: ...
|
||||
|
||||
class MinValueValidator(BaseValidator):
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: Union[datetime, Decimal, float], b: Union[datetime, Decimal, float]) -> bool: ...
|
||||
|
||||
class MinLengthValidator(BaseValidator):
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: int, b: int) -> bool: ...
|
||||
def clean(self, x: str) -> int: ...
|
||||
|
||||
class MaxLengthValidator(BaseValidator):
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: int, b: int) -> bool: ...
|
||||
def clean(self, x: Union[bytes, str]) -> int: ...
|
||||
class MaxValueValidator(BaseValidator): ...
|
||||
class MinValueValidator(BaseValidator): ...
|
||||
class MinLengthValidator(BaseValidator): ...
|
||||
class MaxLengthValidator(BaseValidator): ...
|
||||
|
||||
class DecimalValidator:
|
||||
messages: Any = ...
|
||||
messages: Dict[str, str] = ...
|
||||
max_digits: int = ...
|
||||
decimal_places: int = ...
|
||||
def __init__(self, max_digits: Optional[Union[int, str]], decimal_places: Optional[Union[int, str]]) -> None: ...
|
||||
def __call__(self, value: Decimal) -> None: ...
|
||||
|
||||
class FileExtensionValidator:
|
||||
message: Any = ...
|
||||
message: str = ...
|
||||
code: str = ...
|
||||
allowed_extensions: List[str] = ...
|
||||
def __init__(
|
||||
self,
|
||||
allowed_extensions: Optional[Collection[str]] = ...,
|
||||
message: Optional[str] = ...,
|
||||
message: Optional[_ErrorMessage] = ...,
|
||||
code: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, value: File) -> None: ...
|
||||
@@ -130,7 +115,7 @@ def get_available_image_extensions() -> List[str]: ...
|
||||
def validate_image_file_extension(value: File) -> None: ...
|
||||
|
||||
class ProhibitNullCharactersValidator:
|
||||
message: Any = ...
|
||||
message: str = ...
|
||||
code: str = ...
|
||||
def __init__(self, message: Optional[str] = ..., code: Optional[str] = ...) -> None: ...
|
||||
def __call__(self, value: Optional[Union[Dict[Any, Any], str, UUID]]) -> None: ...
|
||||
def __init__(self, message: Optional[_ErrorMessage] = ..., code: Optional[str] = ...) -> None: ...
|
||||
def __call__(self, value: Any) -> None: ...
|
||||
|
||||
@@ -20,7 +20,7 @@ class BaseDatabaseWrapper:
|
||||
ops: Any = ...
|
||||
vendor: str = ...
|
||||
display_name: str = ...
|
||||
SchemaEditorClass: Any = ...
|
||||
SchemaEditorClass: Optional[BaseDatabaseSchemaEditor] = ...
|
||||
client_class: Any = ...
|
||||
creation_class: Any = ...
|
||||
features_class: Any = ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections import namedtuple
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Dict, List, Optional, Set, Type
|
||||
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.backends.utils import CursorWrapper
|
||||
@@ -13,7 +13,7 @@ class BaseDatabaseIntrospection:
|
||||
data_types_reverse: Any = ...
|
||||
connection: Any = ...
|
||||
def __init__(self, connection: BaseDatabaseWrapper) -> None: ...
|
||||
def get_field_type(self, data_type: str, description: FieldInfo) -> Union[Tuple[str, Dict[str, int]], str]: ...
|
||||
def get_field_type(self, data_type: str, description: FieldInfo) -> str: ...
|
||||
def table_name_converter(self, name: str) -> str: ...
|
||||
def column_name_converter(self, name: str) -> str: ...
|
||||
def table_names(self, cursor: Optional[CursorWrapper] = ..., include_views: bool = ...) -> List[str]: ...
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
from datetime import date, datetime, timedelta
|
||||
from datetime import date, datetime, timedelta, time
|
||||
from decimal import Decimal
|
||||
from typing import Any, List, Optional, Sequence, Tuple, Type, Union
|
||||
|
||||
from django.core.management.color import Style
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.backends.utils import CursorWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import Case, Expression
|
||||
@@ -13,6 +12,8 @@ from django.db.models.sql.compiler import SQLCompiler
|
||||
from django.db import DefaultConnectionProxy
|
||||
from django.db.models.fields import Field
|
||||
|
||||
_Connection = Union[DefaultConnectionProxy, BaseDatabaseWrapper]
|
||||
|
||||
class BaseDatabaseOperations:
|
||||
compiler_module: str = ...
|
||||
integer_field_ranges: Any = ...
|
||||
@@ -25,8 +26,8 @@ class BaseDatabaseOperations:
|
||||
UNBOUNDED_FOLLOWING: Any = ...
|
||||
CURRENT_ROW: str = ...
|
||||
explain_prefix: Any = ...
|
||||
connection: Any = ...
|
||||
def __init__(self, connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]]) -> None: ...
|
||||
connection: _Connection = ...
|
||||
def __init__(self, connection: Optional[_Connection]) -> None: ...
|
||||
def autoinc_sql(self, table: str, column: str) -> None: ...
|
||||
def bulk_batch_size(self, fields: Any, objs: Any): ...
|
||||
def cache_key_culling_sql(self) -> str: ...
|
||||
@@ -75,10 +76,10 @@ class BaseDatabaseOperations:
|
||||
def prep_for_like_query(self, x: str) -> str: ...
|
||||
prep_for_iexact_query: Any = ...
|
||||
def validate_autopk_value(self, value: int) -> int: ...
|
||||
def adapt_unknown_value(self, value: Union[datetime, Decimal, int, str]) -> Union[int, str]: ...
|
||||
def adapt_unknown_value(self, value: Any) -> Any: ...
|
||||
def adapt_datefield_value(self, value: Optional[date]) -> Optional[str]: ...
|
||||
def adapt_datetimefield_value(self, value: None) -> None: ...
|
||||
def adapt_timefield_value(self, value: Optional[datetime]) -> Optional[str]: ...
|
||||
def adapt_datetimefield_value(self, value: Optional[datetime]) -> Optional[str]: ...
|
||||
def adapt_timefield_value(self, value: Optional[Union[datetime, time]]) -> Optional[str]: ...
|
||||
def adapt_decimalfield_value(
|
||||
self, value: Optional[Decimal], max_digits: Optional[int] = ..., decimal_places: Optional[int] = ...
|
||||
) -> Optional[str]: ...
|
||||
@@ -87,19 +88,17 @@ class BaseDatabaseOperations:
|
||||
def year_lookup_bounds_for_datetime_field(self, value: int) -> List[str]: ...
|
||||
def get_db_converters(self, expression: Expression) -> List[Any]: ...
|
||||
def convert_durationfield_value(
|
||||
self, value: Optional[float], expression: Expression, connection: DatabaseWrapper
|
||||
self, value: Optional[float], expression: Expression, connection: _Connection
|
||||
) -> Optional[timedelta]: ...
|
||||
def check_expression_support(self, expression: Any) -> None: ...
|
||||
def combine_expression(self, connector: str, sub_expressions: List[str]) -> str: ...
|
||||
def combine_duration_expression(self, connector: Any, sub_expressions: Any): ...
|
||||
def binary_placeholder_sql(self, value: Optional[Case]) -> str: ...
|
||||
def modify_insert_params(
|
||||
self, placeholder: str, params: Union[List[None], List[bool], List[float], List[str]]
|
||||
) -> Union[List[None], List[bool], List[float], List[str]]: ...
|
||||
def modify_insert_params(self, placeholder: str, params: Any) -> Any: ...
|
||||
def integer_field_range(self, internal_type: Any): ...
|
||||
def subtract_temporals(self, internal_type: Any, lhs: Any, rhs: Any): ...
|
||||
def window_frame_start(self, start: Any): ...
|
||||
def window_frame_end(self, end: Any): ...
|
||||
def window_frame_rows_start_end(self, start: None = ..., end: None = ...) -> Any: ...
|
||||
def window_frame_range_start_end(self, start: Optional[Any] = ..., end: Optional[Any] = ...): ...
|
||||
def window_frame_rows_start_end(self, start: Optional[int] = ..., end: Optional[int] = ...) -> Any: ...
|
||||
def window_frame_range_start_end(self, start: Optional[int] = ..., end: Optional[int] = ...) -> Any: ...
|
||||
def explain_query_prefix(self, format: Optional[str] = ..., **options: Any) -> str: ...
|
||||
|
||||
@@ -48,7 +48,7 @@ class BaseDatabaseSchemaEditor(ContextManager[Any]):
|
||||
def quote_name(self, name: str) -> str: ...
|
||||
def column_sql(
|
||||
self, model: Type[Model], field: Field, include_default: bool = ...
|
||||
) -> Union[Tuple[None, None], Tuple[str, List[Any]]]: ...
|
||||
) -> Tuple[Optional[str], Optional[List[Any]]]: ...
|
||||
def skip_default(self, field: Any): ...
|
||||
def prepare_default(self, value: Any) -> None: ...
|
||||
def effective_default(self, field: Field) -> Optional[Union[int, str]]: ...
|
||||
|
||||
@@ -10,3 +10,5 @@ class DatabaseWrapper(BaseDatabaseWrapper): ...
|
||||
FORMAT_QMARK_REGEX: Any
|
||||
|
||||
class SQLiteCursorWrapper(Database.Cursor): ...
|
||||
|
||||
def check_sqlite_version() -> None: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Optional, Tuple, Union
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.db.backends.base.introspection import BaseDatabaseIntrospection
|
||||
|
||||
@@ -8,6 +8,6 @@ def get_field_size(name: str) -> Optional[int]: ...
|
||||
|
||||
class FlexibleFieldLookupDict:
|
||||
base_data_types_reverse: Any = ...
|
||||
def __getitem__(self, key: str) -> Union[Tuple[str, Dict[str, int]], str]: ...
|
||||
def __getitem__(self, key: str) -> Any: ...
|
||||
|
||||
class DatabaseIntrospection(BaseDatabaseIntrospection): ...
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, Set
|
||||
from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, Set
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.apps.registry import Apps
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class AppConfigStub:
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: None
|
||||
name: str
|
||||
verbose_name: str
|
||||
def __init__(self, label: str) -> None: ...
|
||||
def import_models(self) -> None: ...
|
||||
class AppConfigStub(AppConfig): ...
|
||||
|
||||
class ModelState:
|
||||
name: str
|
||||
@@ -66,13 +58,7 @@ class ProjectState:
|
||||
def remove_model(self, app_label: str, model_name: str) -> None: ...
|
||||
|
||||
class StateApps(Apps):
|
||||
all_models: DefaultDict
|
||||
apps_ready: bool
|
||||
loading: bool
|
||||
models_ready: bool
|
||||
ready: bool
|
||||
real_models: List[ModelState]
|
||||
stored_app_configs: List[Any]
|
||||
def __init__(
|
||||
self, real_apps: List[str], models: Dict[Tuple[str, str], ModelState], ignore_swappable: bool = ...
|
||||
) -> None: ...
|
||||
|
||||
@@ -40,6 +40,7 @@ from .fields import (
|
||||
DurationField as DurationField,
|
||||
BigAutoField as BigAutoField,
|
||||
CommaSeparatedIntegerField as CommaSeparatedIntegerField,
|
||||
NOT_PROVIDED as NOT_PROVIDED,
|
||||
)
|
||||
|
||||
from .fields.related import (
|
||||
@@ -67,6 +68,9 @@ from .deletion import (
|
||||
DO_NOTHING as DO_NOTHING,
|
||||
PROTECT as PROTECT,
|
||||
SET as SET,
|
||||
RESTRICT as RESTRICT,
|
||||
ProtectedError as ProtectedError,
|
||||
RestrictedError as RestrictedError,
|
||||
)
|
||||
|
||||
from .query import (
|
||||
@@ -128,3 +132,5 @@ from .constraints import (
|
||||
CheckConstraint as CheckConstraint,
|
||||
UniqueConstraint as UniqueConstraint,
|
||||
)
|
||||
|
||||
from .enums import Choices as Choices, IntegerChoices as IntegerChoices, TextChoices as TextChoices
|
||||
|
||||
@@ -1,27 +1,43 @@
|
||||
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union
|
||||
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, Collection, ClassVar
|
||||
|
||||
from django.core.checks.messages import CheckMessage
|
||||
from django.db.models.manager import Manager
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db.models.manager import BaseManager
|
||||
from django.db.models.options import Options
|
||||
|
||||
_Self = TypeVar("_Self", bound="Model")
|
||||
|
||||
class ModelStateFieldsCacheDescriptor: ...
|
||||
|
||||
class ModelState:
|
||||
db: Optional[str] = ...
|
||||
adding: bool = ...
|
||||
fields_cache: ModelStateFieldsCacheDescriptor = ...
|
||||
|
||||
class ModelBase(type): ...
|
||||
|
||||
class Model(metaclass=ModelBase):
|
||||
class DoesNotExist(Exception): ...
|
||||
class MultipleObjectsReturned(Exception): ...
|
||||
class Meta: ...
|
||||
_default_manager: Manager[Model]
|
||||
_meta: Options[Any]
|
||||
objects: Manager[Any]
|
||||
_default_manager: BaseManager[Model]
|
||||
objects: ClassVar[BaseManager[Any]]
|
||||
pk: Any = ...
|
||||
_state: ModelState
|
||||
def __init__(self: _Self, *args, **kwargs) -> None: ...
|
||||
@classmethod
|
||||
def add_to_class(cls, name: str, value: Any): ...
|
||||
@classmethod
|
||||
def from_db(cls, db: Optional[str], field_names: Collection[str], values: Collection[Any]) -> _Self: ...
|
||||
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
|
||||
def full_clean(self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...) -> None: ...
|
||||
def full_clean(self, exclude: Optional[Collection[str]] = ..., validate_unique: bool = ...) -> None: ...
|
||||
def clean(self) -> None: ...
|
||||
def clean_fields(self, exclude: List[str] = ...) -> None: ...
|
||||
def validate_unique(self, exclude: List[str] = ...) -> None: ...
|
||||
def clean_fields(self, exclude: Optional[Collection[str]] = ...) -> None: ...
|
||||
def validate_unique(self, exclude: Optional[Collection[str]] = ...) -> None: ...
|
||||
def unique_error_message(
|
||||
self, model_class: Type[_Self], unique_check: Collection[Union[Callable, str]]
|
||||
) -> ValidationError: ...
|
||||
def save(
|
||||
self,
|
||||
force_insert: bool = ...,
|
||||
@@ -37,15 +53,8 @@ class Model(metaclass=ModelBase):
|
||||
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 refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> None: ...
|
||||
def get_deferred_fields(self) -> Set[str]: ...
|
||||
@classmethod
|
||||
def check(cls, **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def __getstate__(self) -> dict: ...
|
||||
|
||||
class ModelStateFieldsCacheDescriptor: ...
|
||||
|
||||
class ModelState:
|
||||
db: None = ...
|
||||
adding: bool = ...
|
||||
fields_cache: ModelStateFieldsCacheDescriptor = ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, Iterable, Optional, Union
|
||||
from typing import Any, Callable, Iterable, Optional, Union, Collection, Type
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
@@ -11,11 +11,20 @@ def SET_NULL(collector, field, sub_objs, using): ...
|
||||
def SET_DEFAULT(collector, field, sub_objs, using): ...
|
||||
def DO_NOTHING(collector, field, sub_objs, using): ...
|
||||
def PROTECT(collector, field, sub_objs, using): ...
|
||||
def RESTRICT(collector, field, sub_objs, using): ...
|
||||
def SET(value: Any) -> Callable: ...
|
||||
def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ...
|
||||
|
||||
class ProtectedError(IntegrityError): ...
|
||||
class RestrictedError(IntegrityError): ...
|
||||
|
||||
class Collector:
|
||||
def __init__(self, using: str) -> None: ...
|
||||
def collect(
|
||||
self,
|
||||
objs: Collection[Optional[Model]],
|
||||
source: Optional[Type[Model]] = ...,
|
||||
source_attr: Optional[str] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def can_fast_delete(self, objs: Union[Model, Iterable[Model]], from_field: Optional[Field] = ...) -> bool: ...
|
||||
|
||||
30
django-stubs/db/models/enums.pyi
Normal file
30
django-stubs/db/models/enums.pyi
Normal file
@@ -0,0 +1,30 @@
|
||||
import enum
|
||||
from typing import Any, List, Tuple
|
||||
|
||||
class ChoicesMeta(enum.EnumMeta):
|
||||
names: List[str] = ...
|
||||
choices: List[Tuple[Any, str]] = ...
|
||||
labels: List[str] = ...
|
||||
values: List[Any] = ...
|
||||
def __contains__(self, item: Any) -> bool: ...
|
||||
|
||||
class Choices(enum.Enum, metaclass=ChoicesMeta):
|
||||
def __str__(self): ...
|
||||
|
||||
# fake
|
||||
class _IntegerChoicesMeta(ChoicesMeta):
|
||||
names: List[str] = ...
|
||||
choices: List[Tuple[int, str]] = ...
|
||||
labels: List[str] = ...
|
||||
values: List[int] = ...
|
||||
|
||||
class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta): ...
|
||||
|
||||
# fake
|
||||
class _TextChoicesMeta(ChoicesMeta):
|
||||
names: List[str] = ...
|
||||
choices: List[Tuple[str, str]] = ...
|
||||
labels: List[str] = ...
|
||||
values: List[str] = ...
|
||||
|
||||
class TextChoices(str, Choices, metaclass=_TextChoicesMeta): ...
|
||||
@@ -25,7 +25,9 @@ from django.db.models.expressions import Combinable, Col
|
||||
from django.db.models.query_utils import RegisterLookupMixin
|
||||
from django.forms import Field as FormField, Widget
|
||||
|
||||
from .mixins import NOT_PROVIDED as NOT_PROVIDED
|
||||
class NOT_PROVIDED: ...
|
||||
|
||||
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
||||
|
||||
_Choice = Tuple[Any, Any]
|
||||
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
||||
@@ -52,6 +54,8 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
auto_created: bool
|
||||
primary_key: bool
|
||||
remote_field: Field
|
||||
is_relation: bool
|
||||
related_model: Optional[Type[Model]]
|
||||
max_length: int
|
||||
model: Type[Model]
|
||||
name: str
|
||||
@@ -61,9 +65,10 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
null: bool = ...
|
||||
editable: bool = ...
|
||||
empty_strings_allowed: bool = ...
|
||||
choices: Optional[_FieldChoices] = ...
|
||||
choices: _FieldChoices = ...
|
||||
db_column: Optional[str]
|
||||
column: str
|
||||
default: Any
|
||||
error_messages: _ErrorMessagesToOverride
|
||||
def __init__(
|
||||
self,
|
||||
@@ -103,9 +108,13 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
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 pre_save(self, model_instance: Model, add: bool) -> Any: ...
|
||||
def get_prep_value(self, value: Any) -> Any: ...
|
||||
def get_db_prep_value(self, value: Any, connection: Any, prepared: bool) -> Any: ...
|
||||
def get_db_prep_save(self, value: Any, connection: Any) -> Any: ...
|
||||
def get_internal_type(self) -> str: ...
|
||||
def formfield(self, **kwargs) -> FormField: ...
|
||||
# TODO: plugin support
|
||||
def formfield(self, **kwargs) -> Any: ...
|
||||
def save_form_data(self, instance: Model, data: Any) -> None: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
|
||||
def to_python(self, value: Any) -> Any: ...
|
||||
@@ -128,11 +137,12 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
@property
|
||||
def cached_col(self) -> Col: ...
|
||||
def value_from_object(self, obj: Model) -> _GT: ...
|
||||
def get_attname(self) -> str: ...
|
||||
|
||||
class IntegerField(Field[_ST, _GT]):
|
||||
_pyi_private_set_type: Union[float, int, str, Combinable]
|
||||
_pyi_private_get_type: int
|
||||
_pyi_lookup_exact_type: int
|
||||
_pyi_lookup_exact_type: Union[str, int]
|
||||
|
||||
class PositiveIntegerRelDbTypeMixin:
|
||||
def rel_db_type(self, connection: Any): ...
|
||||
@@ -180,7 +190,7 @@ class DecimalField(Field[_ST, _GT]):
|
||||
class AutoField(Field[_ST, _GT]):
|
||||
_pyi_private_set_type: Union[Combinable, int, str]
|
||||
_pyi_private_get_type: int
|
||||
_pyi_lookup_exact_type: int
|
||||
_pyi_lookup_exact_type: Union[str, int]
|
||||
|
||||
class CharField(Field[_ST, _GT]):
|
||||
_pyi_private_set_type: Union[str, int, Combinable]
|
||||
@@ -357,20 +367,20 @@ class UUIDField(Field[_ST, _GT]):
|
||||
_pyi_private_get_type: uuid.UUID
|
||||
|
||||
class FilePathField(Field[_ST, _GT]):
|
||||
path: str = ...
|
||||
match: Optional[Any] = ...
|
||||
path: Any = ...
|
||||
match: Optional[str] = ...
|
||||
recursive: bool = ...
|
||||
allow_files: bool = ...
|
||||
allow_folders: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
path: str = ...,
|
||||
match: Optional[Any] = ...,
|
||||
path: Union[str, Callable[..., str]] = ...,
|
||||
match: Optional[str] = ...,
|
||||
recursive: bool = ...,
|
||||
allow_files: bool = ...,
|
||||
allow_folders: bool = ...,
|
||||
verbose_name: Optional[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
primary_key: bool = ...,
|
||||
max_length: int = ...,
|
||||
unique: bool = ...,
|
||||
@@ -389,7 +399,8 @@ class FilePathField(Field[_ST, _GT]):
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
|
||||
class BinaryField(Field[_ST, _GT]): ...
|
||||
class BinaryField(Field[_ST, _GT]):
|
||||
_pyi_private_get_type: bytes
|
||||
|
||||
class DurationField(Field[_ST, _GT]):
|
||||
_pyi_private_get_type: timedelta
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any, Callable, Iterable, List, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Iterable, Optional, Type, TypeVar, Union, overload
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.core.files.images import ImageFile
|
||||
@@ -7,8 +8,6 @@ from django.db.models.base import Model
|
||||
|
||||
from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride
|
||||
|
||||
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
||||
|
||||
class FieldFile(File):
|
||||
instance: Model = ...
|
||||
field: FileField = ...
|
||||
@@ -39,11 +38,10 @@ class FileField(Field):
|
||||
upload_to: Union[str, Callable] = ...
|
||||
def __init__(
|
||||
self,
|
||||
upload_to: Union[str, Callable, Path] = ...,
|
||||
storage: Optional[Storage] = ...,
|
||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||
name: Optional[str] = ...,
|
||||
upload_to: Union[str, Callable] = ...,
|
||||
storage: Optional[Storage] = ...,
|
||||
primary_key: bool = ...,
|
||||
max_length: Optional[int] = ...,
|
||||
unique: bool = ...,
|
||||
blank: bool = ...,
|
||||
|
||||
@@ -43,9 +43,8 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
|
||||
one_to_one: bool = ...
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
related_model: Type[Model]
|
||||
opts: Any = ...
|
||||
@property
|
||||
def related_model(self) -> Type[Model]: ...
|
||||
def get_forward_related_filter(self, obj: Model) -> Dict[str, Union[int, UUID]]: ...
|
||||
def get_reverse_related_filter(self, obj: Model) -> Q: ...
|
||||
@property
|
||||
|
||||
@@ -18,6 +18,7 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
concrete: bool = ...
|
||||
editable: bool = ...
|
||||
is_relation: bool = ...
|
||||
related_model: Type[Model]
|
||||
null: bool = ...
|
||||
field: RelatedField = ...
|
||||
model: Union[Type[Model], str] = ...
|
||||
@@ -44,8 +45,6 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def related_model(self) -> Type[Model]: ...
|
||||
@property
|
||||
def remote_field(self) -> RelatedField: ...
|
||||
@property
|
||||
def target_field(self) -> AutoField: ...
|
||||
|
||||
@@ -14,9 +14,14 @@ from .text import (
|
||||
Trim as Trim,
|
||||
Ord as Ord,
|
||||
Repeat as Repeat,
|
||||
SHA1 as SHA1,
|
||||
SHA224 as SHA224,
|
||||
SHA256 as SHA256,
|
||||
SHA384 as SHA384,
|
||||
SHA512 as SHA512,
|
||||
StrIndex as StrIndex,
|
||||
Replace as Replace,
|
||||
Substr as Substr,
|
||||
Replace as Replace,
|
||||
Reverse as Reverse,
|
||||
)
|
||||
|
||||
@@ -81,6 +86,7 @@ from .math import (
|
||||
Power as Power,
|
||||
Radians as Radians,
|
||||
Round as Round,
|
||||
Sign as Sign,
|
||||
Sin as Sin,
|
||||
Sqrt as Sqrt,
|
||||
Tan as Tan,
|
||||
|
||||
@@ -23,3 +23,4 @@ class Round(Transform): ...
|
||||
class Sin(NumericOutputFieldMixin, Transform): ...
|
||||
class Sqrt(NumericOutputFieldMixin, Transform): ...
|
||||
class Tan(NumericOutputFieldMixin, Transform): ...
|
||||
class Sign(Transform): ...
|
||||
|
||||
@@ -55,3 +55,11 @@ class Substr(Func):
|
||||
class Trim(Transform): ...
|
||||
class Upper(Transform): ...
|
||||
class Reverse(Transform): ...
|
||||
class MySQLSHA2Mixin: ...
|
||||
class OracleHashMixin: ...
|
||||
class PostgreSQLSHAMixin: ...
|
||||
class SHA1(OracleHashMixin, PostgreSQLSHAMixin, Transform): ...
|
||||
class SHA224(MySQLSHA2Mixin, PostgreSQLSHAMixin, Transform): ...
|
||||
class SHA256(MySQLSHA2Mixin, OracleHashMixin, PostgreSQLSHAMixin, Transform): ...
|
||||
class SHA384(MySQLSHA2Mixin, OracleHashMixin, PostgreSQLSHAMixin, Transform): ...
|
||||
class SHA512(MySQLSHA2Mixin, OracleHashMixin, PostgreSQLSHAMixin, Transform): ...
|
||||
|
||||
@@ -31,11 +31,9 @@ class Lookup(Generic[_T]):
|
||||
def process_lhs(
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, lhs: Optional[Expression] = ...
|
||||
) -> Tuple[str, List[Union[int, str]]]: ...
|
||||
def process_rhs(
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper
|
||||
) -> Tuple[str, Union[List[Union[int, str]], Tuple[int, int]]]: ...
|
||||
def process_rhs(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[Union[int, str]]]: ...
|
||||
def rhs_is_direct_value(self) -> bool: ...
|
||||
def relabeled_clone(self, relabels: Mapping[str, str]) -> Union[BuiltinLookup, FieldGetDbPrepValueMixin]: ...
|
||||
def relabeled_clone(self: _T, relabels: Mapping[str, str]) -> _T: ...
|
||||
def get_group_by_cols(self) -> List[Expression]: ...
|
||||
def as_sql(self, compiler: Any, connection: Any) -> Any: ...
|
||||
def contains_aggregate(self) -> bool: ...
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Iterable, Union
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
_T = TypeVar("_T", bound=Model, covariant=True)
|
||||
_M = TypeVar("_M", bound="BaseManager")
|
||||
|
||||
class BaseManager(QuerySet[_T]):
|
||||
creation_counter: int = ...
|
||||
auto_created: bool = ...
|
||||
use_in_migrations: bool = ...
|
||||
name: str = ...
|
||||
model: Type[Model] = ...
|
||||
model: Type[_T] = ...
|
||||
db: str
|
||||
_db: Optional[str]
|
||||
def __init__(self) -> None: ...
|
||||
def deconstruct(self) -> Tuple[bool, str, None, Tuple, Dict[str, int]]: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
@@ -20,13 +22,18 @@ class BaseManager(QuerySet[_T]):
|
||||
@classmethod
|
||||
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
|
||||
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
|
||||
def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ...
|
||||
def db_manager(self: _M, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> _M: ...
|
||||
def get_queryset(self) -> QuerySet[_T]: ...
|
||||
|
||||
class Manager(BaseManager[_T]): ...
|
||||
|
||||
class RelatedManager(Manager[_T]):
|
||||
def add(self, *objs: Model, bulk: bool = ...) -> None: ...
|
||||
related_val: Tuple[int, ...]
|
||||
def add(self, *objs: Union[_T, int], bulk: bool = ...) -> None: ...
|
||||
def remove(self, *objs: Union[_T, int], bulk: bool = ...) -> None: ...
|
||||
def set(
|
||||
self, objs: Union[QuerySet[_T], Iterable[Union[_T, int]]], *, bulk: bool = ..., clear: bool = ...
|
||||
) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
|
||||
class ManagerDescriptor:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import collections
|
||||
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
|
||||
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Sequence, Tuple, Type, TypeVar, Union
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.apps.registry import Apps
|
||||
@@ -8,6 +8,7 @@ from django.contrib.postgres.fields.array import ArrayField
|
||||
from django.contrib.postgres.fields.citext import CIText
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.db.models.fields.mixins import FieldCacheMixin
|
||||
from django.db.models.fields.related import ManyToManyField, OneToOneField
|
||||
from django.db.models.fields.reverse_related import ForeignObjectRel
|
||||
@@ -23,8 +24,8 @@ IMMUTABLE_WARNING: str
|
||||
DEFAULT_NAMES: Tuple[str, ...]
|
||||
|
||||
def normalize_together(
|
||||
option_together: Any
|
||||
) -> Union[List[Union[Tuple[str, str], int]], Set[Tuple[str, str]], Tuple, int, str]: ...
|
||||
option_together: Union[Sequence[Tuple[str, str]], Tuple[str, str]]
|
||||
) -> Tuple[Tuple[str, str], ...]: ...
|
||||
def make_immutable_fields_list(
|
||||
name: str, data: Union[Iterator[Any], List[Union[ArrayField, CIText]], List[Union[Field, FieldCacheMixin]]]
|
||||
) -> ImmutableList: ...
|
||||
@@ -34,6 +35,7 @@ _M = TypeVar("_M", bound=Model)
|
||||
class Options(Generic[_M]):
|
||||
base_manager: Manager
|
||||
concrete_fields: ImmutableList
|
||||
constraints: List[BaseConstraint]
|
||||
default_manager: Manager
|
||||
fields: ImmutableList
|
||||
local_concrete_fields: ImmutableList
|
||||
@@ -108,6 +110,8 @@ class Options(Generic[_M]):
|
||||
def managers(self) -> List[Manager]: ...
|
||||
@property
|
||||
def managers_map(self) -> Dict[str, Manager]: ...
|
||||
@property
|
||||
def db_returning_fields(self) -> List[Field]: ...
|
||||
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]]: ...
|
||||
|
||||
@@ -16,6 +16,7 @@ from typing import (
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
Reversible,
|
||||
)
|
||||
|
||||
from django.db.models.base import Model
|
||||
@@ -30,6 +31,7 @@ _T = TypeVar("_T", bound=models.Model, covariant=True)
|
||||
_QS = TypeVar("_QS", bound="_BaseQuerySet")
|
||||
|
||||
class _BaseQuerySet(Generic[_T], Sized):
|
||||
model: Type[_T]
|
||||
query: Query
|
||||
def __init__(
|
||||
self,
|
||||
@@ -52,8 +54,9 @@ class _BaseQuerySet(Generic[_T], Sized):
|
||||
def get(self, *args: Any, **kwargs: Any) -> _T: ...
|
||||
def create(self, *args: Any, **kwargs: Any) -> _T: ...
|
||||
def bulk_create(
|
||||
self, objs: Iterable[Model], batch_size: Optional[int] = ..., ignore_conflicts: bool = ...
|
||||
self, objs: Iterable[_T], batch_size: Optional[int] = ..., ignore_conflicts: bool = ...
|
||||
) -> List[_T]: ...
|
||||
def bulk_update(self, objs: Iterable[_T], fields: Sequence[str], batch_size: Optional[int] = ...) -> None: ...
|
||||
def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ...
|
||||
def update_or_create(
|
||||
self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any
|
||||
@@ -119,16 +122,15 @@ class _BaseQuerySet(Generic[_T], Sized):
|
||||
@property
|
||||
def db(self) -> str: ...
|
||||
def resolve_expression(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
# TODO: remove when django adds __class_getitem__ methods
|
||||
def __getattr__(self, item: str) -> Any: ...
|
||||
|
||||
class QuerySet(_BaseQuerySet[_T], Collection[_T], Sized):
|
||||
class QuerySet(_BaseQuerySet[_T], Collection[_T], Reversible[_T], Sized):
|
||||
def __iter__(self) -> Iterator[_T]: ...
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
@overload
|
||||
def __getitem__(self, i: int) -> _T: ...
|
||||
@overload
|
||||
def __getitem__(self: _QS, s: slice) -> _QS: ...
|
||||
def __reversed__(self) -> Iterator[_T]: ...
|
||||
|
||||
_Row = TypeVar("_Row", covariant=True)
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from collections import OrderedDict, namedtuple
|
||||
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
|
||||
from collections import namedtuple
|
||||
from typing import Any, Collection, Dict, Iterator, List, Mapping, Optional, Sequence, Set, Tuple, Type
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import Expression
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields.mixins import FieldCacheMixin
|
||||
from django.db.models.sql.compiler import SQLCompiler
|
||||
from django.db.models.sql.query import Query
|
||||
from django.db.models.sql.where import WhereNode
|
||||
|
||||
from django.db.models.fields import Field
|
||||
from django.utils import tree
|
||||
|
||||
PathInfo = namedtuple("PathInfo", "from_opts to_opts target_fields join_field m2m direct filtered_relation")
|
||||
@@ -23,12 +23,8 @@ class QueryWrapper:
|
||||
def as_sql(self, compiler: SQLCompiler = ..., connection: Any = ...) -> Any: ...
|
||||
|
||||
class Q(tree.Node):
|
||||
children: Union[List[Dict[str, str]], List[Tuple[str, Any]], List[Q]]
|
||||
connector: str
|
||||
negated: bool
|
||||
AND: str = ...
|
||||
OR: str = ...
|
||||
default: Any = ...
|
||||
conditional: bool = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def __or__(self, other: Any) -> Q: ...
|
||||
@@ -46,8 +42,8 @@ class Q(tree.Node):
|
||||
|
||||
class DeferredAttribute:
|
||||
field_name: str = ...
|
||||
field: Field
|
||||
def __init__(self, field_name: str) -> None: ...
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Any: ...
|
||||
|
||||
class RegisterLookupMixin:
|
||||
lookup_name: str
|
||||
@@ -65,15 +61,11 @@ class RegisterLookupMixin:
|
||||
def select_related_descend(
|
||||
field: Field,
|
||||
restricted: bool,
|
||||
requested: Optional[
|
||||
Union[Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[str, Dict[Any, Any]]]]]]]], bool]
|
||||
],
|
||||
load_fields: Optional[Set[str]],
|
||||
requested: Optional[Mapping[str, Any]],
|
||||
load_fields: Optional[Collection[str]],
|
||||
reverse: bool = ...,
|
||||
) -> bool: ...
|
||||
def refs_expression(
|
||||
lookup_parts: List[str], annotations: OrderedDict
|
||||
) -> Union[Tuple[bool, Tuple], Tuple[Expression, List[str]]]: ...
|
||||
def refs_expression(lookup_parts: Sequence[str], annotations: Mapping[str, bool]) -> Tuple[bool, Sequence[str]]: ...
|
||||
def check_rel_lookup_compatibility(model: Type[Model], target_opts: Any, field: FieldCacheMixin) -> bool: ...
|
||||
|
||||
class FilteredRelation:
|
||||
|
||||
@@ -25,7 +25,7 @@ class SQLCompiler:
|
||||
def setup_query(self) -> None: ...
|
||||
has_extra_select: Any = ...
|
||||
def pre_sql_setup(
|
||||
self
|
||||
self,
|
||||
) -> Tuple[
|
||||
List[Tuple[Expression, Tuple[str, Union[List[Any], Tuple[str, str]]], None]],
|
||||
List[Tuple[Expression, Tuple[str, List[Union[int, str]], bool]]],
|
||||
@@ -40,7 +40,7 @@ class SQLCompiler:
|
||||
self, expressions: List[Expression], having: Union[List[Expression], Tuple]
|
||||
) -> List[Expression]: ...
|
||||
def get_select(
|
||||
self
|
||||
self,
|
||||
) -> Tuple[
|
||||
List[Tuple[Expression, Tuple[str, List[Union[int, str]]], Optional[str]]],
|
||||
Optional[Dict[str, Any]],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import collections
|
||||
from collections import OrderedDict, namedtuple
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union, Iterable
|
||||
|
||||
from django.db.models.lookups import Lookup, Transform
|
||||
from django.db.models.query_utils import PathInfo, RegisterLookupMixin
|
||||
@@ -155,19 +155,19 @@ class Query:
|
||||
def add_ordering(self, *ordering: Any) -> None: ...
|
||||
def clear_ordering(self, force_empty: bool) -> None: ...
|
||||
def set_group_by(self) -> None: ...
|
||||
def add_select_related(self, fields: Tuple[str]) -> None: ...
|
||||
def add_select_related(self, fields: Iterable[str]) -> None: ...
|
||||
def add_extra(
|
||||
self,
|
||||
select: Optional[Union[Dict[str, int], Dict[str, str], OrderedDict]],
|
||||
select_params: Optional[Union[List[int], List[str], Tuple[int]]],
|
||||
where: Optional[List[str]],
|
||||
params: Optional[List[str]],
|
||||
tables: Optional[List[str]],
|
||||
order_by: Optional[Union[List[str], Tuple[str]]],
|
||||
select: Optional[Dict[str, Any]],
|
||||
select_params: Optional[Iterable[Any]],
|
||||
where: Optional[Sequence[str]],
|
||||
params: Optional[Sequence[str]],
|
||||
tables: Optional[Sequence[str]],
|
||||
order_by: Optional[Sequence[str]],
|
||||
) -> None: ...
|
||||
def clear_deferred_loading(self) -> None: ...
|
||||
def add_deferred_loading(self, field_names: Tuple[str]) -> None: ...
|
||||
def add_immediate_loading(self, field_names: Tuple[str]) -> None: ...
|
||||
def add_deferred_loading(self, field_names: Iterable[str]) -> None: ...
|
||||
def add_immediate_loading(self, field_names: Iterable[str]) -> None: ...
|
||||
def get_loaded_field_names(self) -> Dict[Type[Model], Set[str]]: ...
|
||||
def get_loaded_field_names_cb(
|
||||
self, target: Dict[Type[Model], Set[str]], model: Type[Model], fields: Set[Field]
|
||||
|
||||
@@ -39,4 +39,11 @@ def atomic(using: _C) -> _C: ...
|
||||
# Decorator or context-manager with parameters
|
||||
@overload
|
||||
def atomic(using: Optional[str] = ..., savepoint: bool = ...) -> Atomic: ...
|
||||
def non_atomic_requests(using: Callable = ...) -> Callable: ...
|
||||
|
||||
# Bare decorator
|
||||
@overload
|
||||
def non_atomic_requests(using: _C) -> _C: ...
|
||||
|
||||
# Decorator with arguments
|
||||
@overload
|
||||
def non_atomic_requests(using: Optional[str] = ...) -> Callable[[_C], _C]: ...
|
||||
|
||||
@@ -2,6 +2,8 @@ from django.core.exceptions import ValidationError as ValidationError
|
||||
|
||||
from .forms import Form as Form, BaseForm as BaseForm
|
||||
|
||||
from .formsets import BaseFormSet as BaseFormSet, all_valid as all_valid, formset_factory as formset_factory
|
||||
|
||||
from .models import (
|
||||
ModelForm as ModelForm,
|
||||
ModelChoiceField as ModelChoiceField,
|
||||
|
||||
@@ -14,7 +14,7 @@ class Field:
|
||||
initial: Any
|
||||
label: Optional[str]
|
||||
required: bool
|
||||
widget: Widget = ...
|
||||
widget: Type[Widget] = ...
|
||||
hidden_widget: Any = ...
|
||||
default_validators: Any = ...
|
||||
default_error_messages: Any = ...
|
||||
@@ -205,10 +205,9 @@ class CallableChoiceIterator:
|
||||
def __iter__(self) -> None: ...
|
||||
|
||||
class ChoiceField(Field):
|
||||
choices: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
choices: Any = ...,
|
||||
choices: Union[_FieldChoices, Callable[[], _FieldChoices]] = ...,
|
||||
required: bool = ...,
|
||||
widget: Optional[Union[Widget, Type[Widget]]] = ...,
|
||||
label: Optional[Any] = ...,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Type, Union
|
||||
|
||||
from django.core.exceptions import ValidationError as ValidationError
|
||||
from django.core.files import uploadedfile
|
||||
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.utils.datastructures import MultiValueDict
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
class DeclarativeFieldsMetaclass(MediaDefiningClass): ...
|
||||
@@ -18,11 +20,11 @@ class BaseForm:
|
||||
use_required_attribute: bool = ...
|
||||
is_bound: bool = ...
|
||||
data: Dict[str, Any] = ...
|
||||
files: Optional[Dict[str, Any]] = ...
|
||||
auto_id: str = ...
|
||||
files: MultiValueDict[str, uploadedfile.UploadedFile] = ...
|
||||
auto_id: Union[bool, str] = ...
|
||||
initial: Dict[str, Any] = ...
|
||||
error_class: Type[ErrorList] = ...
|
||||
prefix: str = ...
|
||||
prefix: Optional[str] = ...
|
||||
label_suffix: str = ...
|
||||
empty_permitted: bool = ...
|
||||
fields: Dict[str, Any] = ...
|
||||
@@ -67,5 +69,10 @@ class BaseForm:
|
||||
def hidden_fields(self): ...
|
||||
def visible_fields(self): ...
|
||||
def get_initial_for_field(self, field: Field, field_name: str) -> Any: ...
|
||||
def _html_output(
|
||||
self, normal_row: str, error_row: str, row_ender: str, help_text_html: str, errors_on_separate_row: bool,
|
||||
) -> SafeText: ...
|
||||
|
||||
class Form(BaseForm): ...
|
||||
class Form(BaseForm):
|
||||
base_fields: Dict[str, Field]
|
||||
declared_fields: Dict[str, Field]
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, Dict, Iterator, List, Mapping, MutableMapping, Optional, Sequence, Tuple, Type, Union
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Mapping,
|
||||
MutableMapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
ClassVar,
|
||||
Container,
|
||||
TypeVar,
|
||||
)
|
||||
from unittest.mock import MagicMock
|
||||
from uuid import UUID
|
||||
|
||||
@@ -24,6 +40,11 @@ _Fields = Union[List[Union[Callable, str]], Sequence[str], Literal["__all__"]]
|
||||
_Labels = Dict[str, str]
|
||||
_ErrorMessages = Dict[str, Dict[str, str]]
|
||||
|
||||
_M = TypeVar("_M", bound=Model)
|
||||
|
||||
def construct_instance(
|
||||
form: BaseForm, instance: _M, fields: Optional[Container[str]] = ..., exclude: Optional[Container[str]] = ...
|
||||
) -> _M: ...
|
||||
def model_to_dict(
|
||||
instance: Model, fields: Optional[_Fields] = ..., exclude: Optional[_Fields] = ...
|
||||
) -> Dict[str, Any]: ...
|
||||
@@ -76,7 +97,8 @@ class BaseModelForm(BaseForm):
|
||||
save_m2m: Any = ...
|
||||
def save(self, commit: bool = ...) -> Any: ...
|
||||
|
||||
class ModelForm(BaseModelForm): ...
|
||||
class ModelForm(BaseModelForm, metaclass=ModelFormMetaclass):
|
||||
base_fields: ClassVar[Dict[str, Field]] = ...
|
||||
|
||||
def modelform_factory(
|
||||
model: Type[Model],
|
||||
|
||||
@@ -17,7 +17,9 @@ from typing import (
|
||||
)
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.contrib.sites.models import Site
|
||||
from django.utils.datastructures import CaseInsensitiveMapping, ImmutableList, MultiValueDict
|
||||
|
||||
from django.core.files import uploadedfile, uploadhandler
|
||||
@@ -50,7 +52,8 @@ class HttpRequest(BytesIO):
|
||||
resolver_match: ResolverMatch = ...
|
||||
content_type: Optional[str] = ...
|
||||
content_params: Optional[Dict[str, str]] = ...
|
||||
user: AbstractBaseUser
|
||||
user: Union[AbstractBaseUser, AnonymousUser]
|
||||
site: Site
|
||||
session: SessionBase
|
||||
encoding: Optional[str] = ...
|
||||
upload_handlers: UploadHandlerList = ...
|
||||
@@ -63,7 +66,7 @@ class HttpRequest(BytesIO):
|
||||
self, key: str, default: Any = ..., salt: str = ..., max_age: Optional[int] = ...
|
||||
) -> Optional[str]: ...
|
||||
def get_raw_uri(self) -> str: ...
|
||||
def build_absolute_uri(self, location: str = ...) -> str: ...
|
||||
def build_absolute_uri(self, location: Optional[str] = ...) -> str: ...
|
||||
@property
|
||||
def scheme(self) -> Optional[str]: ...
|
||||
def is_secure(self) -> bool: ...
|
||||
|
||||
@@ -62,28 +62,27 @@ class HttpResponseBase(Iterable[Any]):
|
||||
def __iter__(self) -> Iterator[Any]: ...
|
||||
|
||||
class HttpResponse(HttpResponseBase):
|
||||
client: Client
|
||||
context: Optional[Context]
|
||||
content: Any
|
||||
csrf_cookie_set: bool
|
||||
redirect_chain: List[Tuple[str, int]]
|
||||
request: Dict[str, Any]
|
||||
resolver_match: ResolverMatch
|
||||
sameorigin: bool
|
||||
templates: List[Template]
|
||||
test_server_port: str
|
||||
test_was_secure_request: bool
|
||||
wsgi_request: WSGIRequest
|
||||
xframe_options_exempt: bool
|
||||
streaming: bool = ...
|
||||
def __init__(self, content: object = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def serialize(self) -> bytes: ...
|
||||
@property
|
||||
def content(self) -> Any: ...
|
||||
@content.setter
|
||||
def content(self, value: Any) -> None: ...
|
||||
@property
|
||||
def url(self) -> str: ...
|
||||
def json(self) -> Dict[str, Any]: ...
|
||||
# Attributes assigned by monkey-patching in test client ClientHandler.__call__()
|
||||
wsgi_request: WSGIRequest
|
||||
# Attributes assigned by monkey-patching in test client Client.request()
|
||||
client: Client
|
||||
request: Dict[str, Any]
|
||||
templates: List[Template]
|
||||
context: Context
|
||||
resolver_match: ResolverMatch
|
||||
def json(self) -> Any: ...
|
||||
|
||||
class StreamingHttpResponse(HttpResponseBase):
|
||||
content: Any
|
||||
@@ -107,7 +106,7 @@ class FileResponse(StreamingHttpResponse):
|
||||
def json(self) -> Dict[str, Any]: ...
|
||||
|
||||
class HttpResponseRedirectBase(HttpResponse):
|
||||
allowed_schemes = ... # type: List[str]
|
||||
allowed_schemes: List[str] = ...
|
||||
def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class HttpResponseRedirect(HttpResponseRedirectBase): ...
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
from typing import Any, Callable, Dict, List, Optional, Protocol, Sequence, Type, TypeVar, Union
|
||||
import sys
|
||||
from typing import Any, Callable, List, Mapping, Optional, overload, 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.http.response import (
|
||||
HttpResponse as HttpResponse,
|
||||
HttpResponseRedirect as HttpResponseRedirect,
|
||||
HttpResponsePermanentRedirect as HttpResponsePermanentRedirect,
|
||||
)
|
||||
|
||||
from django.db.models import Manager, QuerySet
|
||||
from django.http import HttpRequest
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
from typing_extensions import Literal
|
||||
else:
|
||||
from typing import Literal
|
||||
|
||||
def render_to_response(
|
||||
template_name: Union[str, Sequence[str]],
|
||||
context: Optional[Dict[str, Any]] = ...,
|
||||
context: Optional[Mapping[str, Any]] = ...,
|
||||
content_type: Optional[str] = ...,
|
||||
status: Optional[int] = ...,
|
||||
using: Optional[str] = ...,
|
||||
@@ -16,7 +26,7 @@ def render_to_response(
|
||||
def render(
|
||||
request: HttpRequest,
|
||||
template_name: Union[str, Sequence[str]],
|
||||
context: Optional[Dict[str, Any]] = ...,
|
||||
context: Optional[Mapping[str, Any]] = ...,
|
||||
content_type: Optional[str] = ...,
|
||||
status: Optional[int] = ...,
|
||||
using: Optional[str] = ...,
|
||||
@@ -24,9 +34,18 @@ def render(
|
||||
|
||||
class SupportsGetAbsoluteUrl(Protocol): ...
|
||||
|
||||
@overload
|
||||
def redirect(
|
||||
to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: Literal[True], **kwargs: Any
|
||||
) -> HttpResponsePermanentRedirect: ...
|
||||
@overload
|
||||
def redirect(
|
||||
to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: Literal[False], **kwargs: Any
|
||||
) -> HttpResponseRedirect: ...
|
||||
@overload
|
||||
def redirect(
|
||||
to: Union[Callable, str, SupportsGetAbsoluteUrl], *args: Any, permanent: bool = ..., **kwargs: Any
|
||||
) -> HttpResponseRedirect: ...
|
||||
) -> Union[HttpResponseRedirect, HttpResponsePermanentRedirect]: ...
|
||||
|
||||
_T = TypeVar("_T", bound=Model)
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
from io import BytesIO
|
||||
from types import TracebackType
|
||||
from typing import Any, Dict, List, Optional, Pattern, Tuple, Type, Union
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.core.handlers.base import BaseHandler
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.http.cookie import SimpleCookie
|
||||
from django.http.request import HttpRequest
|
||||
from django.http.response import HttpResponse, HttpResponseBase
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from json import JSONEncoder
|
||||
|
||||
BOUNDARY: str = ...
|
||||
MULTIPART_CONTENT: str = ...
|
||||
CONTENT_TYPE_RE: Pattern = ...
|
||||
@@ -35,35 +38,36 @@ def encode_multipart(boundary: str, data: Dict[str, Any]) -> bytes: ...
|
||||
def encode_file(boundary: str, key: str, file: Any) -> List[bytes]: ...
|
||||
|
||||
class RequestFactory:
|
||||
json_encoder: Type[DjangoJSONEncoder] = ...
|
||||
defaults: Dict[str, str] = ...
|
||||
cookies: SimpleCookie = ...
|
||||
errors: BytesIO = ...
|
||||
def __init__(self, *, json_encoder: Any = ..., **defaults: Any) -> None: ...
|
||||
def request(self, **request: Any) -> HttpRequest: ...
|
||||
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpRequest: ...
|
||||
json_encoder: Type[JSONEncoder]
|
||||
defaults: Dict[str, str]
|
||||
cookies: SimpleCookie
|
||||
errors: BytesIO
|
||||
def __init__(self, *, json_encoder: Type[JSONEncoder] = ..., **defaults: Any) -> None: ...
|
||||
def request(self, **request: Any) -> WSGIRequest: ...
|
||||
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> WSGIRequest: ...
|
||||
def post(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpRequest: ...
|
||||
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpRequest: ...
|
||||
def trace(self, path: str, secure: bool = ..., **extra: Any) -> HttpRequest: ...
|
||||
) -> WSGIRequest: ...
|
||||
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> WSGIRequest: ...
|
||||
def trace(self, path: str, secure: bool = ..., **extra: Any) -> WSGIRequest: ...
|
||||
def options(
|
||||
self,
|
||||
path: str,
|
||||
data: Union[Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
) -> HttpRequest: ...
|
||||
) -> WSGIRequest: ...
|
||||
def put(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpRequest: ...
|
||||
) -> WSGIRequest: ...
|
||||
def patch(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpRequest: ...
|
||||
) -> WSGIRequest: ...
|
||||
def delete(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpRequest: ...
|
||||
) -> WSGIRequest: ...
|
||||
def generic(
|
||||
self,
|
||||
method: str,
|
||||
@@ -72,54 +76,57 @@ class RequestFactory:
|
||||
content_type: Optional[str] = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
) -> HttpRequest: ...
|
||||
) -> WSGIRequest: ...
|
||||
|
||||
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(
|
||||
class Client(RequestFactory):
|
||||
handler: ClientHandler
|
||||
raise_request_exception: bool
|
||||
exc_info: Optional[Tuple[Type[BaseException], BaseException, TracebackType]]
|
||||
def __init__(
|
||||
self,
|
||||
enforce_csrf_checks: bool = ...,
|
||||
raise_request_exception: bool = ...,
|
||||
*,
|
||||
json_encoder: Type[JSONEncoder] = ...,
|
||||
**defaults: Any
|
||||
) -> None: ...
|
||||
# Silence type warnings, since this class overrides arguments and return types in an unsafe manner.
|
||||
def request(self, **request: Any) -> HttpResponse: ... # type: ignore
|
||||
def get( # type: ignore
|
||||
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def post( # type: ignore
|
||||
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def head( # type: ignore
|
||||
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def trace( # type: ignore
|
||||
self, path: str, follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def options( # type: ignore
|
||||
self,
|
||||
path: str,
|
||||
data: Union[Dict[str, str], str] = ...,
|
||||
content_type: str = ...,
|
||||
follow: bool = ...,
|
||||
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: ...
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def put( # type: ignore
|
||||
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def patch( # type: ignore
|
||||
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
def delete( # type: ignore
|
||||
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponse: ... # type: ignore
|
||||
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: ...
|
||||
def force_login(self, user: AbstractUser, backend: Optional[str] = ...) -> None: ...
|
||||
def logout(self) -> None: ...
|
||||
|
||||
def conditional_content_removal(request: HttpRequest, response: HttpResponseBase) -> HttpResponse: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import threading
|
||||
import unittest
|
||||
from datetime import date
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, ClassVar, overload
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.handlers.wsgi import WSGIHandler
|
||||
@@ -47,7 +47,8 @@ class SimpleTestCase(unittest.TestCase):
|
||||
client_class: Any = ...
|
||||
client: Client
|
||||
allow_database_queries: bool = ...
|
||||
databases: Set[str] = ...
|
||||
# TODO: str -> Literal['__all__']
|
||||
databases: Union[Set[str], str] = ...
|
||||
def __call__(self, result: Optional[unittest.TestResult] = ...) -> None: ...
|
||||
def settings(self, **kwargs: Any) -> Any: ...
|
||||
def modify_settings(self, **kwargs: Any) -> Any: ...
|
||||
@@ -125,9 +126,17 @@ class SimpleTestCase(unittest.TestCase):
|
||||
self, needle: str, haystack: SafeText, count: Optional[int] = ..., msg_prefix: str = ...
|
||||
) -> None: ...
|
||||
def assertJSONEqual(
|
||||
self, raw: str, expected_data: Union[Dict[str, str], bool, str], msg: Optional[str] = ...
|
||||
self,
|
||||
raw: str,
|
||||
expected_data: Union[Dict[str, Any], List[Any], str, int, float, bool, None],
|
||||
msg: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def assertJSONNotEqual(
|
||||
self,
|
||||
raw: str,
|
||||
expected_data: Union[Dict[str, Any], List[Any], str, int, float, bool, None],
|
||||
msg: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def assertJSONNotEqual(self, raw: str, expected_data: str, msg: Optional[str] = ...) -> None: ...
|
||||
def assertXMLEqual(self, xml1: str, xml2: str, msg: Optional[str] = ...) -> None: ...
|
||||
def assertXMLNotEqual(self, xml1: str, xml2: str, msg: Optional[str] = ...) -> None: ...
|
||||
|
||||
@@ -145,9 +154,14 @@ class TransactionTestCase(SimpleTestCase):
|
||||
ordered: bool = ...,
|
||||
msg: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def assertNumQueries(
|
||||
self, num: int, func: Optional[Union[Callable, Type[list]]] = ..., *args: Any, using: Any = ..., **kwargs: Any
|
||||
) -> Optional[_AssertNumQueriesContext]: ...
|
||||
self, num: int, func: Callable[..., Any], *args: Any, using: str = ..., **kwargs: Any
|
||||
) -> None: ...
|
||||
@overload
|
||||
def assertNumQueries(
|
||||
self, num: int, func: None = ..., *args: Any, using: str = ..., **kwargs: Any
|
||||
) -> _AssertNumQueriesContext: ...
|
||||
|
||||
class TestCase(TransactionTestCase):
|
||||
@classmethod
|
||||
@@ -198,13 +212,12 @@ class LiveServerThread(threading.Thread):
|
||||
def terminate(self) -> None: ...
|
||||
|
||||
class LiveServerTestCase(TransactionTestCase):
|
||||
live_server_url: ClassVar[str]
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
server_thread_class: Type[Any] = ...
|
||||
server_thread: Any
|
||||
static_handler: Any = ...
|
||||
@classmethod
|
||||
def live_server_url(cls): ...
|
||||
|
||||
class SerializeMixin:
|
||||
lockfile: Any = ...
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user