mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-12 23:16:31 +08:00
Compare commits
58 Commits
1.0.0
...
readme-fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
584d4e8911 | ||
|
|
02bdf5be95 | ||
|
|
4d4b0003bd | ||
|
|
e143ba568c | ||
|
|
32c0cbca45 | ||
|
|
acc3ca4205 | ||
|
|
be3fc259d5 | ||
|
|
7725b416b6 | ||
|
|
2c23d8e70f | ||
|
|
5910bd1b25 | ||
|
|
963d50c717 | ||
|
|
7407b93151 | ||
|
|
afcd0d9293 | ||
|
|
a85dbff793 | ||
|
|
68aebe2528 | ||
|
|
d3dca5b408 | ||
|
|
c69090ec5b | ||
|
|
29ac1c3017 | ||
|
|
23ad65033b | ||
|
|
64720f492c | ||
|
|
a8fdd4c673 | ||
|
|
813dd8cc1a | ||
|
|
2b53fa5a1a | ||
|
|
e3ea84143f | ||
|
|
82e3aa5464 | ||
|
|
5b9a467cf0 | ||
|
|
4a4dc53c4d | ||
|
|
77fd46987d | ||
|
|
9291164a6b | ||
|
|
0c3e06e875 | ||
|
|
b8379d4fe6 | ||
|
|
caa0e60743 | ||
|
|
de4fa92441 | ||
|
|
dce0c0e930 | ||
|
|
fc9a335dfd | ||
|
|
5fc39ff110 | ||
|
|
e95b40ef52 | ||
|
|
c91a6d1d5b | ||
|
|
d7e8222163 | ||
|
|
09767210ec | ||
|
|
656105bab2 | ||
|
|
ff7bf33e9c | ||
|
|
d94b7b0c6a | ||
|
|
7bf1664307 | ||
|
|
0545c2d3ea | ||
|
|
825931da9f | ||
|
|
737fd239b6 | ||
|
|
7f476057b0 | ||
|
|
d31512854a | ||
|
|
552de422dc | ||
|
|
a9978cc021 | ||
|
|
bb08212b20 | ||
|
|
5d2efdb80b | ||
|
|
27793ecd32 | ||
|
|
dddcb20fe4 | ||
|
|
ac40b80764 | ||
|
|
6b21a0476d | ||
|
|
735b58e9bf |
10
.editorconfig
Normal file
10
.editorconfig
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Check http://editorconfig.org for more information
|
||||||
|
# This is the main config file for this project:
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
trim_trailing_whitespace = true
|
||||||
35
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
35
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
name: Bug
|
||||||
|
about: Create a report of something is not working
|
||||||
|
labels: 'bug'
|
||||||
|
---
|
||||||
|
|
||||||
|
# Bug report
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Hi, thanks for submitting a bug. We appreciate that.
|
||||||
|
|
||||||
|
But, we will need some information about what's wrong to help you.
|
||||||
|
-->
|
||||||
|
|
||||||
|
## What's wrong
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Describe what is not working.
|
||||||
|
|
||||||
|
Please, attach a traceback.
|
||||||
|
We would also appreciate a failing test case.
|
||||||
|
That is EXTREMELY helpful!
|
||||||
|
-->
|
||||||
|
|
||||||
|
## How is that should be
|
||||||
|
|
||||||
|
<!-- Describe how it should work. -->
|
||||||
|
|
||||||
|
## System information
|
||||||
|
|
||||||
|
- OS:
|
||||||
|
- `python` version:
|
||||||
|
- `django` version:
|
||||||
|
- `mypy` version:
|
||||||
|
- `django-stubs` version:
|
||||||
29
.github/pull_request_template.md
vendored
Normal file
29
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# I have made things!
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Hi, thanks for submitting a Pull Request. We appreciate it.
|
||||||
|
|
||||||
|
Please, fill in all the required information
|
||||||
|
to make our review and merging processes easier.
|
||||||
|
|
||||||
|
Cheers!
|
||||||
|
-->
|
||||||
|
|
||||||
|
## Related issues
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Mark what issues this Pull Request closes or references.
|
||||||
|
|
||||||
|
Format is:
|
||||||
|
- Closes #issue-number
|
||||||
|
- Refs #issue-number
|
||||||
|
|
||||||
|
Example. Refs #0
|
||||||
|
Documentation: https://blog.github.com/2013-05-14-closing-issues-via-pull-requests/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
If you have any feedback, just write it here.
|
||||||
|
|
||||||
|
It can be whatever you want!
|
||||||
|
-->
|
||||||
17
.travis.yml
17
.travis.yml
@@ -6,9 +6,7 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- name: Run plugin test suite with python 3.7
|
- name: Run plugin test suite with python 3.7
|
||||||
python: 3.7
|
python: 3.7
|
||||||
script: |
|
script: 'pytest'
|
||||||
set -e
|
|
||||||
pytest
|
|
||||||
|
|
||||||
- name: Typecheck Django test suite with python 3.7
|
- name: Typecheck Django test suite with python 3.7
|
||||||
python: 3.7
|
python: 3.7
|
||||||
@@ -24,18 +22,23 @@ jobs:
|
|||||||
|
|
||||||
- name: Lint with black
|
- name: Lint with black
|
||||||
python: 3.7
|
python: 3.7
|
||||||
script: 'black --check --line-length=120 django-stubs/'
|
script: 'black --check django-stubs/'
|
||||||
|
|
||||||
- name: Lint plugin code with flake8
|
- name: Lint plugin code with flake8
|
||||||
python: 3.7
|
python: 3.7
|
||||||
script: 'flake8'
|
script: 'flake8'
|
||||||
|
|
||||||
|
- name: Lint stubs with flake8-pyi and check for unused imports
|
||||||
|
python: 3.7
|
||||||
|
script: 'flake8 --config flake8-pyi.ini'
|
||||||
|
|
||||||
- name: Lint plugin code with isort
|
- name: Lint plugin code with isort
|
||||||
python: 3.7
|
python: 3.7
|
||||||
script: 'isort --check'
|
script: 'isort --check --diff'
|
||||||
|
|
||||||
before_install: |
|
before_install: |
|
||||||
# Upgrade pip, setuptools, and wheel
|
sudo apt update
|
||||||
|
sudo apt install binutils libproj-dev gdal-bin
|
||||||
pip install -U pip setuptools wheel
|
pip install -U pip setuptools wheel
|
||||||
install: |
|
install: |
|
||||||
pip install -r ./dev-requirements.txt
|
pip install -r ./dev-requirements.txt
|
||||||
|
|||||||
58
README.md
58
README.md
@@ -2,65 +2,89 @@
|
|||||||
|
|
||||||
# pep484 stubs for Django framework
|
# pep484 stubs for Django framework
|
||||||
|
|
||||||
[](https://travis-ci.org/mkurnikov/django-stubs)
|
[](https://travis-ci.org/typeddjango/django-stubs)
|
||||||
[](http://mypy-lang.org/)
|
[](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.
|
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns.
|
||||||
|
|
||||||
Supports Python 3.6/3.7, and Django 2.1/2.2.
|
|
||||||
|
|
||||||
Could be run on earlier versions of Django, but expect some missing imports warnings.
|
Could be run on earlier versions of Django, but expect some missing imports warnings.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```
|
```bash
|
||||||
pip install django-stubs
|
pip install django-stubs
|
||||||
```
|
```
|
||||||
|
|
||||||
### WARNING: All configuration from pre-1.0.0 versions is dropped, use one below.
|
|
||||||
|
|
||||||
### WARNING: 1.0.0 breaks `dmypy`, if you need it, stay on the 0.12.x series.
|
## 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
|
||||||
|
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
To make mypy aware of the plugin, you need to add
|
To make mypy aware of the plugin, you need to add
|
||||||
|
|
||||||
```
|
```ini
|
||||||
[mypy]
|
[mypy]
|
||||||
plugins =
|
plugins =
|
||||||
mypy_django_plugin.main
|
mypy_django_plugin.main
|
||||||
```
|
```
|
||||||
|
|
||||||
in your `mypy.ini` file.
|
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
|
||||||
|
|
||||||
Plugin requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified inside `mypy.ini` file.
|
Plugin also requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified.
|
||||||
```
|
|
||||||
|
```ini
|
||||||
[mypy]
|
[mypy]
|
||||||
strict_optional = True
|
strict_optional = True
|
||||||
|
|
||||||
; this one is new
|
# This one is new:
|
||||||
[mypy.plugins.django-stubs]
|
[mypy.plugins.django-stubs]
|
||||||
django_settings_module = mysettings
|
django_settings_module = mysettings
|
||||||
```
|
```
|
||||||
where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes)
|
|
||||||
|
|
||||||
New 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()`.
|
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.
|
In other words, if your `manage.py runserver` crashes, mypy will crash too.
|
||||||
|
|
||||||
|
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
|
||||||
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
Implementation monkey-patches Django to add `__class_getitem__` to the `Manager` class. If you'd use Python3.7 and do that too in your code, you can make things like
|
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
|
||||||
|
|
||||||
|
```python
|
||||||
class MyUserManager(models.Manager['MyUser']):
|
class MyUserManager(models.Manager['MyUser']):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class MyUser(models.Model):
|
class MyUser(models.Model):
|
||||||
objects = UserManager()
|
objects = UserManager()
|
||||||
```
|
```
|
||||||
|
|
||||||
work, which should make a error messages a bit better.
|
work, which should make a error messages a bit better.
|
||||||
|
|
||||||
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`.
|
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
|
## To get help
|
||||||
|
|
||||||
We have Gitter here https://gitter.im/mypy-django/Lobby.
|
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,5 +1,7 @@
|
|||||||
black
|
black
|
||||||
pytest-mypy-plugins==1.0.3
|
pytest-mypy-plugins==1.1.0
|
||||||
flake8
|
psycopg2
|
||||||
isort==4.3.4
|
flake8==3.7.8
|
||||||
|
flake8-pyi==19.3.0
|
||||||
|
isort==4.3.21
|
||||||
-e .
|
-e .
|
||||||
|
|||||||
Submodule django-sources updated: 4d6449e125...f452d4232e
@@ -1,6 +1,6 @@
|
|||||||
import threading
|
import threading
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict, Dict
|
from typing import Any, Callable, DefaultDict, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.db.migrations.state import AppConfigStub
|
from django.db.migrations.state import AppConfigStub
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
@@ -8,8 +8,8 @@ from django.db.models.base import Model
|
|||||||
from .config import AppConfig
|
from .config import AppConfig
|
||||||
|
|
||||||
class Apps:
|
class Apps:
|
||||||
all_models: "Dict[str, OrderedDict[str, Type[Model]]]" = ...
|
all_models: Dict[str, OrderedDict[str, Type[Model]]] = ...
|
||||||
app_configs: "OrderedDict[str, AppConfig]" = ...
|
app_configs: OrderedDict[str, AppConfig] = ...
|
||||||
stored_app_configs: List[Any] = ...
|
stored_app_configs: List[Any] = ...
|
||||||
apps_ready: bool = ...
|
apps_ready: bool = ...
|
||||||
ready_event: threading.Event = ...
|
ready_event: threading.Event = ...
|
||||||
@@ -24,7 +24,7 @@ class Apps:
|
|||||||
def get_app_configs(self) -> Iterable[AppConfig]: ...
|
def get_app_configs(self) -> Iterable[AppConfig]: ...
|
||||||
def get_app_config(self, app_label: str) -> AppConfig: ...
|
def get_app_config(self, app_label: str) -> AppConfig: ...
|
||||||
# it's not possible to support it in plugin properly now
|
# it's not possible to support it in plugin properly now
|
||||||
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Any]]: ...
|
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ...
|
||||||
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
|
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
|
||||||
def register_model(self, app_label: str, model: Type[Model]) -> None: ...
|
def register_model(self, app_label: str, model: Type[Model]) -> None: ...
|
||||||
def is_installed(self, app_name: str) -> bool: ...
|
def is_installed(self, app_name: str) -> bool: ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import Any, List, Union
|
from typing import Any, List, Union
|
||||||
|
|
||||||
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin
|
from django.contrib.admin.options import BaseModelAdmin
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import Error
|
||||||
|
|
||||||
_CheckError = Union[str, Error]
|
_CheckError = Union[str, Error]
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional, Type
|
||||||
|
|
||||||
def register(*models: Any, site: Optional[Any] = ...) -> Callable: ...
|
from django.db.models.base import Model
|
||||||
|
|
||||||
|
def register(*models: Type[Model], site: Optional[Any] = ...) -> Callable: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
|
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Iterable
|
||||||
|
|
||||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||||
from django.forms.boundfield import BoundField
|
from django.forms.boundfield import BoundField
|
||||||
@@ -26,7 +26,7 @@ class AdminForm:
|
|||||||
form: AdminPasswordChangeForm,
|
form: AdminPasswordChangeForm,
|
||||||
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
||||||
prepopulated_fields: Dict[Any, Any],
|
prepopulated_fields: Dict[Any, Any],
|
||||||
readonly_fields: Any = ...,
|
readonly_fields: Optional[Iterable[Any]] = ...,
|
||||||
model_admin: Any = ...,
|
model_admin: Any = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def __iter__(self) -> Iterator[Fieldset]: ...
|
def __iter__(self) -> Iterator[Fieldset]: ...
|
||||||
@@ -47,7 +47,7 @@ class Fieldset:
|
|||||||
self,
|
self,
|
||||||
form: Any,
|
form: Any,
|
||||||
name: Optional[Any] = ...,
|
name: Optional[Any] = ...,
|
||||||
readonly_fields: Any = ...,
|
readonly_fields: Optional[Iterable[Any]] = ...,
|
||||||
fields: Any = ...,
|
fields: Any = ...,
|
||||||
classes: Any = ...,
|
classes: Any = ...,
|
||||||
description: Optional[Any] = ...,
|
description: Optional[Any] = ...,
|
||||||
@@ -64,7 +64,7 @@ class Fieldline:
|
|||||||
model_admin: Any = ...
|
model_admin: Any = ...
|
||||||
readonly_fields: Any = ...
|
readonly_fields: Any = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self, form: Any, field: Any, readonly_fields: Optional[Any] = ..., model_admin: Optional[Any] = ...
|
self, form: Any, field: Any, readonly_fields: Optional[Iterable[Any]] = ..., model_admin: Optional[Any] = ...
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ...
|
def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ...
|
||||||
def errors(self) -> SafeText: ...
|
def errors(self) -> SafeText: ...
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ class BaseModelAdmin:
|
|||||||
show_full_result_count: bool = ...
|
show_full_result_count: bool = ...
|
||||||
checks_class: Any = ...
|
checks_class: Any = ...
|
||||||
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
|
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
|
||||||
def __init__(self) -> None: ...
|
|
||||||
def formfield_for_dbfield(
|
def formfield_for_dbfield(
|
||||||
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
|
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
|
||||||
) -> Optional[Field]: ...
|
) -> Optional[Field]: ...
|
||||||
@@ -94,7 +93,6 @@ class BaseModelAdmin:
|
|||||||
def has_module_permission(self, request: HttpRequest) -> bool: ...
|
def has_module_permission(self, request: HttpRequest) -> bool: ...
|
||||||
|
|
||||||
class ModelAdmin(BaseModelAdmin):
|
class ModelAdmin(BaseModelAdmin):
|
||||||
formfield_overrides: Any
|
|
||||||
list_display: Sequence[Union[str, Callable]] = ...
|
list_display: Sequence[Union[str, Callable]] = ...
|
||||||
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
|
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
|
||||||
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
|
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
|
||||||
@@ -122,7 +120,6 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
actions_on_top: bool = ...
|
actions_on_top: bool = ...
|
||||||
actions_on_bottom: bool = ...
|
actions_on_bottom: bool = ...
|
||||||
actions_selection_counter: bool = ...
|
actions_selection_counter: bool = ...
|
||||||
checks_class: Any = ...
|
|
||||||
model: Type[Model] = ...
|
model: Type[Model] = ...
|
||||||
opts: Options = ...
|
opts: Options = ...
|
||||||
admin_site: AdminSite = ...
|
admin_site: AdminSite = ...
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.contrib.admin.options import ModelAdmin
|
from django.contrib.admin.options import ModelAdmin
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.urls.resolvers import URLPattern, URLResolver
|
from django.urls.resolvers import URLResolver
|
||||||
from django.utils.functional import LazyObject
|
from django.utils.functional import LazyObject
|
||||||
|
|
||||||
all_sites: Any
|
all_sites: Any
|
||||||
@@ -31,11 +31,11 @@ class AdminSite:
|
|||||||
def check(self, app_configs: None) -> List[Any]: ...
|
def check(self, app_configs: None) -> List[Any]: ...
|
||||||
def register(
|
def register(
|
||||||
self,
|
self,
|
||||||
model_or_iterable: Union[List[Type[Model]], Tuple[Type[Model]], Type[Model]],
|
model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
|
||||||
admin_class: Optional[Type[ModelAdmin]] = ...,
|
admin_class: Optional[Type[ModelAdmin]] = ...,
|
||||||
**options: Any
|
**options: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def unregister(self, model_or_iterable: Type[Model]) -> None: ...
|
def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
|
||||||
def is_registered(self, model: Type[Model]) -> bool: ...
|
def is_registered(self, model: Type[Model]) -> bool: ...
|
||||||
def add_action(self, action: Callable, name: None = ...) -> None: ...
|
def add_action(self, action: Callable, name: None = ...) -> None: ...
|
||||||
def disable_action(self, name: str) -> None: ...
|
def disable_action(self, name: str) -> None: ...
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from django.contrib.admin.helpers import InlineAdminForm
|
from django.contrib.admin.helpers import InlineAdminForm
|
||||||
from django.contrib.admin.templatetags.base import InclusionAdminNode
|
|
||||||
from django.template.base import Parser, Token
|
from django.template.base import Parser, Token
|
||||||
from django.template.context import Context, RequestContext
|
from django.template.context import Context, RequestContext
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
register: Any
|
register: Any
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from typing import Any, Callable, Optional
|
from typing import Callable, TypeVar, overload
|
||||||
|
|
||||||
def staff_member_required(
|
_C = TypeVar("_C", bound=Callable)
|
||||||
view_func: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: str = ...
|
@overload
|
||||||
) -> Callable: ...
|
def staff_member_required(view_func: _C = ..., redirect_field_name: str = ..., login_url: str = ...) -> _C: ...
|
||||||
|
@overload
|
||||||
|
def staff_member_required(view_func: None = ..., redirect_field_name: str = ..., login_url: str = ...) -> Callable: ...
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ from collections import OrderedDict
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.contrib.admin.filters import ListFilter, SimpleListFilter
|
from django.contrib.admin.filters import ListFilter, SimpleListFilter
|
||||||
from django.contrib.admin.options import ModelAdmin, IS_POPUP_VAR as IS_POPUP_VAR, TO_FIELD_VAR as TO_FIELD_VAR
|
from django.contrib.admin.options import ( # noqa: F401
|
||||||
|
ModelAdmin,
|
||||||
|
IS_POPUP_VAR as IS_POPUP_VAR,
|
||||||
|
TO_FIELD_VAR as TO_FIELD_VAR,
|
||||||
|
)
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
|
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
|
||||||
|
|||||||
3
django-stubs/contrib/admindocs/urls.pyi
Normal file
3
django-stubs/contrib/admindocs/urls.pyi
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from typing import Any, List
|
||||||
|
|
||||||
|
urlpatterns: List[Any] = ...
|
||||||
@@ -3,46 +3,17 @@ from typing import Any, Optional, Union
|
|||||||
from django.db.models.fields import Field
|
from django.db.models.fields import Field
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from .utils import get_view_name
|
|
||||||
|
|
||||||
MODEL_METHODS_EXCLUDE: Any
|
MODEL_METHODS_EXCLUDE: Any
|
||||||
|
|
||||||
class BaseAdminDocsView(TemplateView):
|
class BaseAdminDocsView(TemplateView): ...
|
||||||
template_name: str = ...
|
class BookmarkletsView(BaseAdminDocsView): ...
|
||||||
def dispatch(self, request: Any, *args: Any, **kwargs: Any): ...
|
class TemplateTagIndexView(BaseAdminDocsView): ...
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
class TemplateFilterIndexView(BaseAdminDocsView): ...
|
||||||
|
class ViewIndexView(BaseAdminDocsView): ...
|
||||||
class BookmarkletsView(BaseAdminDocsView):
|
class ViewDetailView(BaseAdminDocsView): ...
|
||||||
template_name: str = ...
|
class ModelIndexView(BaseAdminDocsView): ...
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
class ModelDetailView(BaseAdminDocsView): ...
|
||||||
|
class TemplateDetailView(BaseAdminDocsView): ...
|
||||||
class TemplateTagIndexView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
class TemplateFilterIndexView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
class ViewIndexView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
class ViewDetailView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
class ModelIndexView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
class ModelDetailView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
class TemplateDetailView(BaseAdminDocsView):
|
|
||||||
template_name: str = ...
|
|
||||||
def get_context_data(self, **kwargs: Any): ...
|
|
||||||
|
|
||||||
def get_return_data_type(func_name: Any): ...
|
def get_return_data_type(func_name: Any): ...
|
||||||
def get_readable_field_data_type(field: Union[Field, str]) -> str: ...
|
def get_readable_field_data_type(field: Union[Field, str]) -> str: ...
|
||||||
|
|||||||
@@ -13,14 +13,12 @@ class BaseUserManager(models.Manager[_T]):
|
|||||||
def get_by_natural_key(self, username: Optional[str]) -> _T: ...
|
def get_by_natural_key(self, username: Optional[str]) -> _T: ...
|
||||||
|
|
||||||
class AbstractBaseUser(models.Model):
|
class AbstractBaseUser(models.Model):
|
||||||
password: models.CharField = ...
|
password = models.CharField(max_length=128)
|
||||||
last_login: models.DateTimeField = ...
|
last_login = models.DateTimeField(blank=True, null=True)
|
||||||
is_active: models.BooleanField = ...
|
|
||||||
REQUIRED_FIELDS: List[str] = ...
|
REQUIRED_FIELDS: List[str] = ...
|
||||||
class Meta: ...
|
class Meta: ...
|
||||||
def get_username(self) -> str: ...
|
def get_username(self) -> str: ...
|
||||||
def clean(self) -> None: ...
|
|
||||||
def save(self, *args: Any, **kwargs: Any) -> None: ...
|
|
||||||
def natural_key(self) -> Tuple[str]: ...
|
def natural_key(self) -> Tuple[str]: ...
|
||||||
@property
|
@property
|
||||||
def is_anonymous(self) -> bool: ...
|
def is_anonymous(self) -> bool: ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import Any, Callable, List, Optional, Set, Union
|
from typing import Callable, List, Optional, Set, Union
|
||||||
|
|
||||||
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME
|
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
|
||||||
|
|
||||||
def user_passes_test(
|
def user_passes_test(
|
||||||
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
|
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict
|
||||||
|
|
||||||
UserModel: Any
|
UserModel: Any
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import getpass as getpass
|
import getpass as getpass # noqa: F401
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Callable, List, Optional
|
from typing import Any, Callable, List
|
||||||
|
|
||||||
from django import http
|
from django import http
|
||||||
from django.http.response import HttpResponse, HttpResponseRedirect
|
from django.http.response import HttpResponse, HttpResponseRedirect
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ class PermissionManager(models.Manager):
|
|||||||
|
|
||||||
class Permission(models.Model):
|
class Permission(models.Model):
|
||||||
content_type_id: int
|
content_type_id: int
|
||||||
name: models.CharField = ...
|
name = models.CharField(max_length=255)
|
||||||
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||||
codename: models.CharField = ...
|
codename = models.CharField(max_length=100)
|
||||||
def natural_key(self) -> Tuple[str, str, str]: ...
|
def natural_key(self) -> Tuple[str, str, str]: ...
|
||||||
|
|
||||||
class GroupManager(models.Manager):
|
class GroupManager(models.Manager):
|
||||||
def get_by_natural_key(self, name: str) -> Group: ...
|
def get_by_natural_key(self, name: str) -> Group: ...
|
||||||
|
|
||||||
class Group(models.Model):
|
class Group(models.Model):
|
||||||
name: models.CharField = ...
|
name = models.CharField(max_length=150)
|
||||||
permissions: models.ManyToManyField = models.ManyToManyField(Permission)
|
permissions = models.ManyToManyField(Permission)
|
||||||
def natural_key(self): ...
|
def natural_key(self): ...
|
||||||
|
|
||||||
_T = TypeVar("_T", bound=Model)
|
_T = TypeVar("_T", bound=Model)
|
||||||
@@ -39,7 +39,7 @@ class UserManager(BaseUserManager[_T]):
|
|||||||
) -> _T: ...
|
) -> _T: ...
|
||||||
|
|
||||||
class PermissionsMixin(models.Model):
|
class PermissionsMixin(models.Model):
|
||||||
is_superuser: models.BooleanField = ...
|
is_superuser = models.BooleanField()
|
||||||
groups: models.ManyToManyField = models.ManyToManyField(Group)
|
groups: models.ManyToManyField = models.ManyToManyField(Group)
|
||||||
user_permissions: models.ManyToManyField = models.ManyToManyField(Permission)
|
user_permissions: models.ManyToManyField = models.ManyToManyField(Permission)
|
||||||
def get_group_permissions(self, obj: None = ...) -> Set[str]: ...
|
def get_group_permissions(self, obj: None = ...) -> Set[str]: ...
|
||||||
@@ -50,15 +50,17 @@ class PermissionsMixin(models.Model):
|
|||||||
|
|
||||||
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
|
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
|
||||||
username_validator: UnicodeUsernameValidator = ...
|
username_validator: UnicodeUsernameValidator = ...
|
||||||
username: models.CharField = ...
|
|
||||||
first_name: models.CharField = ...
|
username = models.CharField(max_length=150)
|
||||||
last_name: models.CharField = ...
|
first_name = models.CharField(max_length=30, blank=True)
|
||||||
email: models.EmailField = ...
|
last_name = models.CharField(max_length=150, blank=True)
|
||||||
is_staff: models.BooleanField = ...
|
email = models.EmailField(blank=True)
|
||||||
date_joined: models.DateTimeField = ...
|
is_staff = models.BooleanField()
|
||||||
|
is_active = models.BooleanField()
|
||||||
|
date_joined = models.DateTimeField()
|
||||||
|
|
||||||
EMAIL_FIELD: str = ...
|
EMAIL_FIELD: str = ...
|
||||||
USERNAME_FIELD: str = ...
|
USERNAME_FIELD: str = ...
|
||||||
def clean(self) -> None: ...
|
|
||||||
def get_full_name(self) -> str: ...
|
def get_full_name(self) -> str: ...
|
||||||
def get_short_name(self) -> str: ...
|
def get_short_name(self) -> str: ...
|
||||||
def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ...
|
def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ...
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from pathlib import Path, PosixPath
|
from pathlib import Path, PosixPath
|
||||||
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union
|
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union
|
||||||
|
|
||||||
from django.contrib.auth.base_user import AbstractBaseUser
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
|
||||||
_UserModel = Model
|
_UserModel = Model
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||||
def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Generic
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import Error
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
from django.db.models.expressions import Combinable
|
||||||
|
from django.db.models.fields.mixins import FieldCacheMixin
|
||||||
from django.db.models.fields.related import ForeignObject
|
from django.db.models.fields.related import ForeignObject
|
||||||
from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor
|
from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor
|
||||||
from django.db.models.fields.reverse_related import ForeignObjectRel
|
from django.db.models.fields.reverse_related import ForeignObjectRel
|
||||||
|
|
||||||
from django.db.models.expressions import Combinable
|
|
||||||
from django.db.models.fields import Field, PositiveIntegerField
|
|
||||||
from django.db.models.fields.mixins import FieldCacheMixin
|
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
from django.db.models.query_utils import FilteredRelation, PathInfo
|
from django.db.models.query_utils import FilteredRelation, PathInfo
|
||||||
from django.db.models.sql.where import WhereNode
|
from django.db.models.sql.where import WhereNode
|
||||||
|
|
||||||
|
from django.db.models.fields import Field, PositiveIntegerField
|
||||||
|
|
||||||
class GenericForeignKey(FieldCacheMixin):
|
class GenericForeignKey(FieldCacheMixin):
|
||||||
# django-stubs implementation only fields
|
# django-stubs implementation only fields
|
||||||
_pyi_private_set_type: Union[Any, Combinable]
|
_pyi_private_set_type: Union[Any, Combinable]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional, Union
|
from typing import Union
|
||||||
|
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
|
|||||||
3
django-stubs/contrib/flatpages/urls.pyi
Normal file
3
django-stubs/contrib/flatpages/urls.pyi
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from typing import Any, List
|
||||||
|
|
||||||
|
urlpatterns: List[Any] = ...
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
from typing import Any, Optional
|
|
||||||
|
|
||||||
from django.contrib.flatpages.models import FlatPage
|
from django.contrib.flatpages.models import FlatPage
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
|
|||||||
0
django-stubs/contrib/gis/__init__.pyi
Normal file
0
django-stubs/contrib/gis/__init__.pyi
Normal file
0
django-stubs/contrib/gis/db/__init__.pyi
Normal file
0
django-stubs/contrib/gis/db/__init__.pyi
Normal file
13
django-stubs/contrib/gis/db/models/__init__.pyi
Normal file
13
django-stubs/contrib/gis/db/models/__init__.pyi
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from django.db.models import *
|
||||||
|
|
||||||
|
from .fields import (
|
||||||
|
GeometryField as GeometryField,
|
||||||
|
LineStringField as LineStringField,
|
||||||
|
MultiLineStringField as MultiLineStringField,
|
||||||
|
MultiPointField as MultiPointField,
|
||||||
|
MultiPolygonField as MultiPolygonField,
|
||||||
|
PointField as PointField,
|
||||||
|
PolygonField as PolygonField,
|
||||||
|
GeometryCollectionField as GeometryCollectionField,
|
||||||
|
RasterField as RasterField,
|
||||||
|
)
|
||||||
91
django-stubs/contrib/gis/db/models/fields.pyi
Normal file
91
django-stubs/contrib/gis/db/models/fields.pyi
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
from typing import Any, Iterable, NamedTuple, Optional, TypeVar, Union, Tuple
|
||||||
|
|
||||||
|
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
|
||||||
|
|
||||||
|
_Connection = Any
|
||||||
|
|
||||||
|
# __set__ value type
|
||||||
|
_ST = TypeVar("_ST")
|
||||||
|
# __get__ return type
|
||||||
|
_GT = TypeVar("_GT")
|
||||||
|
|
||||||
|
class SRIDCacheEntry(NamedTuple):
|
||||||
|
units: Any
|
||||||
|
units_name: str
|
||||||
|
geodetic: bool
|
||||||
|
spheroid: str
|
||||||
|
|
||||||
|
def get_srid_info(srid: int, connection: _Connection) -> SRIDCacheEntry: ...
|
||||||
|
|
||||||
|
class BaseSpatialField(Field[_ST, _GT]):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||||
|
srid: int = ...,
|
||||||
|
spatial_index: bool = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
primary_key: bool = ...,
|
||||||
|
max_length: Optional[int] = ...,
|
||||||
|
unique: bool = ...,
|
||||||
|
blank: bool = ...,
|
||||||
|
null: bool = ...,
|
||||||
|
db_index: bool = ...,
|
||||||
|
default: Any = ...,
|
||||||
|
editable: bool = ...,
|
||||||
|
auto_created: bool = ...,
|
||||||
|
serialize: bool = ...,
|
||||||
|
unique_for_date: Optional[str] = ...,
|
||||||
|
unique_for_month: Optional[str] = ...,
|
||||||
|
unique_for_year: Optional[str] = ...,
|
||||||
|
choices: Optional[_FieldChoices] = ...,
|
||||||
|
help_text: str = ...,
|
||||||
|
db_column: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
|
): ...
|
||||||
|
def spheroid(self, connection: _Connection) -> str: ...
|
||||||
|
def units(self, connection: _Connection) -> Any: ...
|
||||||
|
def units_name(self, connection: _Connection) -> str: ...
|
||||||
|
def geodetic(self, connection: _Connection) -> bool: ...
|
||||||
|
|
||||||
|
class GeometryField(BaseSpatialField):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||||
|
dim: int = ...,
|
||||||
|
geography: bool = ...,
|
||||||
|
extent: Tuple[float, float, float, float] = ...,
|
||||||
|
tolerance: float = ...,
|
||||||
|
srid: int = ...,
|
||||||
|
spatial_index: bool = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
primary_key: bool = ...,
|
||||||
|
max_length: Optional[int] = ...,
|
||||||
|
unique: bool = ...,
|
||||||
|
blank: bool = ...,
|
||||||
|
null: bool = ...,
|
||||||
|
db_index: bool = ...,
|
||||||
|
default: Any = ...,
|
||||||
|
editable: bool = ...,
|
||||||
|
auto_created: bool = ...,
|
||||||
|
serialize: bool = ...,
|
||||||
|
unique_for_date: Optional[str] = ...,
|
||||||
|
unique_for_month: Optional[str] = ...,
|
||||||
|
unique_for_year: Optional[str] = ...,
|
||||||
|
choices: Optional[_FieldChoices] = ...,
|
||||||
|
help_text: str = ...,
|
||||||
|
db_column: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
|
): ...
|
||||||
|
|
||||||
|
class PointField(GeometryField): ...
|
||||||
|
class LineStringField(GeometryField): ...
|
||||||
|
class PolygonField(GeometryField): ...
|
||||||
|
class MultiPointField(GeometryField): ...
|
||||||
|
class MultiLineStringField(GeometryField): ...
|
||||||
|
class MultiPolygonField(GeometryField): ...
|
||||||
|
class GeometryCollectionField(GeometryField): ...
|
||||||
|
class RasterField(BaseSpatialField): ...
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Union
|
||||||
|
|
||||||
from django.contrib.messages.storage.base import BaseStorage
|
from django.contrib.messages.storage.base import BaseStorage
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional, Union
|
from typing import Any, List, Optional
|
||||||
|
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
from django.http.response import HttpResponseBase
|
from django.http.response import HttpResponseBase
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
from typing import Dict, Optional
|
from typing import Dict
|
||||||
|
|
||||||
def get_level_tags() -> Dict[int, str]: ...
|
def get_level_tags() -> Dict[int, str]: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, Optional
|
from typing import Dict
|
||||||
|
|
||||||
from django.forms.forms import BaseForm
|
from django.forms.forms import BaseForm
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
|
|||||||
24
django-stubs/contrib/postgres/aggregates/__init__.pyi
Normal file
24
django-stubs/contrib/postgres/aggregates/__init__.pyi
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from .general import (
|
||||||
|
ArrayAgg as ArrayAgg,
|
||||||
|
BitAnd as BitAnd,
|
||||||
|
BitOr as BitOr,
|
||||||
|
BoolAnd as BoolAnd,
|
||||||
|
BoolOr as BoolOr,
|
||||||
|
JSONBAgg as JSONBAgg,
|
||||||
|
StringAgg as StringAgg,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .statistics import (
|
||||||
|
Corr as Corr,
|
||||||
|
CovarPop as CovarPop,
|
||||||
|
RegrAvgX as RegrAvgX,
|
||||||
|
RegrAvgY as RegrAvgY,
|
||||||
|
RegrCount as RegrCount,
|
||||||
|
RegrIntercept as RegrIntercept,
|
||||||
|
RegrR2 as RegrR2,
|
||||||
|
RegrSlope as RegrSlope,
|
||||||
|
RegrSXX as RegrSXX,
|
||||||
|
RegrSXY as RegrSXY,
|
||||||
|
RegrSYY as RegrSYY,
|
||||||
|
StatAggregate as StatAggregate,
|
||||||
|
)
|
||||||
11
django-stubs/contrib/postgres/aggregates/general.pyi
Normal file
11
django-stubs/contrib/postgres/aggregates/general.pyi
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
from django.db.models.aggregates import Aggregate
|
||||||
|
|
||||||
|
from .mixins import OrderableAggMixin
|
||||||
|
|
||||||
|
class ArrayAgg(OrderableAggMixin, Aggregate): ...
|
||||||
|
class BitAnd(Aggregate): ...
|
||||||
|
class BitOr(Aggregate): ...
|
||||||
|
class BoolAnd(Aggregate): ...
|
||||||
|
class BoolOr(Aggregate): ...
|
||||||
|
class JSONBAgg(Aggregate): ...
|
||||||
|
class StringAgg(OrderableAggMixin, Aggregate): ...
|
||||||
1
django-stubs/contrib/postgres/aggregates/mixins.pyi
Normal file
1
django-stubs/contrib/postgres/aggregates/mixins.pyi
Normal file
@@ -0,0 +1 @@
|
|||||||
|
class OrderableAggMixin: ...
|
||||||
14
django-stubs/contrib/postgres/aggregates/statistics.pyi
Normal file
14
django-stubs/contrib/postgres/aggregates/statistics.pyi
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from django.db.models.aggregates import Aggregate
|
||||||
|
|
||||||
|
class StatAggregate(Aggregate): ...
|
||||||
|
class Corr(StatAggregate): ...
|
||||||
|
class CovarPop(StatAggregate): ...
|
||||||
|
class RegrAvgX(StatAggregate): ...
|
||||||
|
class RegrAvgY(StatAggregate): ...
|
||||||
|
class RegrCount(StatAggregate): ...
|
||||||
|
class RegrIntercept(StatAggregate): ...
|
||||||
|
class RegrR2(StatAggregate): ...
|
||||||
|
class RegrSlope(StatAggregate): ...
|
||||||
|
class RegrSXX(StatAggregate): ...
|
||||||
|
class RegrSXY(StatAggregate): ...
|
||||||
|
class RegrSYY(StatAggregate): ...
|
||||||
@@ -1,29 +1,82 @@
|
|||||||
from typing import Any, Optional
|
from typing import Optional, Sequence
|
||||||
|
|
||||||
|
from django.db.models.query_utils import Q
|
||||||
|
|
||||||
from django.db.models import Index
|
from django.db.models import Index
|
||||||
|
|
||||||
class PostgresIndex(Index):
|
class PostgresIndex(Index): ...
|
||||||
@property
|
|
||||||
def max_name_length(self) -> int: ...
|
|
||||||
|
|
||||||
class BrinIndex(PostgresIndex):
|
class BrinIndex(PostgresIndex):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, *, autosummarize: Optional[bool] = ..., pages_per_range: Optional[int] = ..., **kwargs: Any
|
self,
|
||||||
|
*,
|
||||||
|
autosummarize: Optional[bool] = ...,
|
||||||
|
pages_per_range: Optional[int] = ...,
|
||||||
|
fields: Sequence[str] = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
opclasses: Sequence[str] = ...,
|
||||||
|
condition: Optional[Q] = ...
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
class BTreeIndex(PostgresIndex):
|
class BTreeIndex(PostgresIndex):
|
||||||
def __init__(self, *, fillfactor: Optional[int] = ..., **kwargs: Any): ...
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
fillfactor: Optional[int] = ...,
|
||||||
|
fields: Sequence[str] = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
opclasses: Sequence[str] = ...,
|
||||||
|
condition: Optional[Q] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class GinIndex(PostgresIndex):
|
class GinIndex(PostgresIndex):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, *, fastupdate: Optional[bool] = ..., gin_pending_list_limit: Optional[int] = ..., **kwargs: Any
|
self,
|
||||||
|
*,
|
||||||
|
fastupdate: Optional[bool] = ...,
|
||||||
|
gin_pending_list_limit: Optional[int] = ...,
|
||||||
|
fields: Sequence[str] = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
opclasses: Sequence[str] = ...,
|
||||||
|
condition: Optional[Q] = ...
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
||||||
class GistIndex(PostgresIndex):
|
class GistIndex(PostgresIndex):
|
||||||
def __init__(self, *, buffering: Optional[bool] = ..., fillfactor: Optional[int] = ..., **kwargs: Any) -> None: ...
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
buffering: Optional[bool] = ...,
|
||||||
|
fillfactor: Optional[int] = ...,
|
||||||
|
fields: Sequence[str] = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
opclasses: Sequence[str] = ...,
|
||||||
|
condition: Optional[Q] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class HashIndex(PostgresIndex):
|
class HashIndex(PostgresIndex):
|
||||||
def __init__(self, *, fillfactor: Optional[int] = ..., **kwargs: Any) -> None: ...
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
fillfactor: Optional[int] = ...,
|
||||||
|
fields: Sequence[str] = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
opclasses: Sequence[str] = ...,
|
||||||
|
condition: Optional[Q] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class SpGistIndex(PostgresIndex):
|
class SpGistIndex(PostgresIndex):
|
||||||
def __init__(self, *, fillfactor: Optional[int] = ..., **kwargs: Any) -> None: ...
|
def __init__(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
fillfactor: Optional[int] = ...,
|
||||||
|
fields: Sequence[str] = ...,
|
||||||
|
name: Optional[str] = ...,
|
||||||
|
db_tablespace: Optional[str] = ...,
|
||||||
|
opclasses: Sequence[str] = ...,
|
||||||
|
condition: Optional[Q] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|||||||
18
django-stubs/contrib/postgres/lookups.pyi
Normal file
18
django-stubs/contrib/postgres/lookups.pyi
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from django.db.models.lookups import Exact
|
||||||
|
|
||||||
|
from django.db.models import Lookup, Transform
|
||||||
|
from .search import SearchVectorExact
|
||||||
|
|
||||||
|
class PostgresSimpleLookup(Lookup):
|
||||||
|
operator: str
|
||||||
|
|
||||||
|
class DataContains(PostgresSimpleLookup): ...
|
||||||
|
class ContainedBy(PostgresSimpleLookup): ...
|
||||||
|
class Overlap(PostgresSimpleLookup): ...
|
||||||
|
class HasKey(PostgresSimpleLookup): ...
|
||||||
|
class HasKeys(PostgresSimpleLookup): ...
|
||||||
|
class HasAnyKeys(HasKeys): ...
|
||||||
|
class Unaccent(Transform): ...
|
||||||
|
class SearchLookup(SearchVectorExact): ...
|
||||||
|
class TrigramSimilar(PostgresSimpleLookup): ...
|
||||||
|
class JSONExact(Exact): ...
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
from typing import Any, Dict, Optional, TypeVar, Union
|
from typing import Any, Dict, Optional, TypeVar, Union
|
||||||
|
|
||||||
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value
|
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value, _OutputField
|
||||||
from django.db.models.lookups import Lookup
|
from django.db.models.lookups import Lookup
|
||||||
|
|
||||||
from django.db.models import Field
|
from django.db.models import Field
|
||||||
|
|
||||||
|
_Expression = Union[str, Combinable, "SearchQueryCombinable"]
|
||||||
|
|
||||||
class SearchVectorExact(Lookup): ...
|
class SearchVectorExact(Lookup): ...
|
||||||
class SearchVectorField(Field): ...
|
class SearchVectorField(Field): ...
|
||||||
class SearchQueryField(Field): ...
|
class SearchQueryField(Field): ...
|
||||||
@@ -13,11 +15,13 @@ class SearchVectorCombinable:
|
|||||||
ADD: str = ...
|
ADD: str = ...
|
||||||
|
|
||||||
class SearchVector(SearchVectorCombinable, Func):
|
class SearchVector(SearchVectorCombinable, Func):
|
||||||
config: Optional[Any] = None
|
config: Optional[Any] = ...
|
||||||
def __init__(self, *expressions: Union[str, Combinable], **extra: Any): ...
|
def __init__(self, *expressions: _Expression, **extra: Any): ...
|
||||||
|
|
||||||
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
|
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
|
||||||
def __init__(self, lhs, connector, rhs, config, output_field: Optional[Field, str] = ...): ...
|
def __init__(
|
||||||
|
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
|
||||||
|
): ...
|
||||||
|
|
||||||
_T = TypeVar("_T", bound="SearchQueryCombinable")
|
_T = TypeVar("_T", bound="SearchQueryCombinable")
|
||||||
|
|
||||||
@@ -29,19 +33,31 @@ class SearchQueryCombinable:
|
|||||||
def __and__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
def __and__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
||||||
def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
||||||
|
|
||||||
class SearchQuery(SearchQueryCombinable, Value):
|
class SearchQuery(SearchQueryCombinable, Value): # type: ignore
|
||||||
SEARCH_TYPES: Dict[str, str] = {"plain": "plainto_tsquery", "phrase": "phraseto_tsquery", "raw": "to_tsquery"}
|
SEARCH_TYPES: Dict[str, str] = ...
|
||||||
def __init__(self, value, output_field=None, *, config=None, invert=False, search_type="plain"): ...
|
def __init__(
|
||||||
|
self,
|
||||||
|
value: str,
|
||||||
|
output_field: Optional[_OutputField] = ...,
|
||||||
|
*,
|
||||||
|
config: Optional[_Expression] = ...,
|
||||||
|
invert: bool = ...,
|
||||||
|
search_type: str = ...
|
||||||
|
): ...
|
||||||
def __invert__(self: _T) -> _T: ...
|
def __invert__(self: _T) -> _T: ...
|
||||||
|
|
||||||
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression):
|
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: ignore
|
||||||
def __init__(self, lhs, connector, rhs, config, output_field=None) -> None: ...
|
def __init__(
|
||||||
|
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class SearchRank(Func):
|
class SearchRank(Func):
|
||||||
def __init__(self, vector, query, **extra: Any) -> None: ...
|
def __init__(
|
||||||
|
self, vector: Union[SearchVector, _Expression], query: Union[SearchQuery, _Expression], **extra: Any
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
class TrigramBase(Func):
|
class TrigramBase(Func):
|
||||||
def __init__(self, expression, string, **extra: Any) -> None: ...
|
def __init__(self, expression: _Expression, string, **extra: Any) -> None: ...
|
||||||
|
|
||||||
class TrigramSimilarity(TrigramBase): ...
|
class TrigramSimilarity(TrigramBase): ...
|
||||||
class TrigramDistance(TrigramBase): ...
|
class TrigramDistance(TrigramBase): ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import Error
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import Storage
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
@@ -23,6 +23,6 @@ class Command(BaseCommand):
|
|||||||
def log(self, msg: str, level: int = ...) -> None: ...
|
def log(self, msg: str, level: int = ...) -> None: ...
|
||||||
def is_local_storage(self) -> bool: ...
|
def is_local_storage(self) -> bool: ...
|
||||||
def clear_dir(self, path: str) -> None: ...
|
def clear_dir(self, path: str) -> None: ...
|
||||||
def delete_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> bool: ...
|
def delete_file(self, path: str, prefixed_path: str, source_storage: Storage) -> bool: ...
|
||||||
def link_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> None: ...
|
def link_file(self, path: str, prefixed_path: str, source_storage: Storage) -> None: ...
|
||||||
def copy_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> None: ...
|
def copy_file(self, path: str, prefixed_path: str, source_storage: Storage) -> None: ...
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from typing import Any, Callable, Iterator, Optional, Tuple
|
|||||||
from django.core.files.base import File
|
from django.core.files.base import File
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
from django.utils.functional import LazyObject
|
from django.utils.functional import LazyObject
|
||||||
from django.utils.safestring import SafeText
|
|
||||||
|
|
||||||
class StaticFilesStorage(FileSystemStorage):
|
class StaticFilesStorage(FileSystemStorage):
|
||||||
base_location: Any = ...
|
base_location: Any = ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from django.template.base import Parser, Token
|
from django.template.base import Parser, Token
|
||||||
from django.templatetags.static import StaticNode
|
from django.templatetags.static import StaticNode
|
||||||
|
|||||||
3
django-stubs/contrib/staticfiles/testing.pyi
Normal file
3
django-stubs/contrib/staticfiles/testing.pyi
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import LiveServerTestCase
|
||||||
|
|
||||||
|
class StaticLiveServerTestCase(LiveServerTestCase): ...
|
||||||
@@ -2,6 +2,6 @@ from typing import Any, List, Optional
|
|||||||
|
|
||||||
from django.urls.resolvers import URLPattern
|
from django.urls.resolvers import URLPattern
|
||||||
|
|
||||||
urlpatterns: Any
|
urlpatterns: List[Any] = ...
|
||||||
|
|
||||||
def staticfiles_urlpatterns(prefix: Optional[str] = ...) -> List[URLPattern]: ...
|
def staticfiles_urlpatterns(prefix: Optional[str] = ...) -> List[URLPattern]: ...
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Iterator, List, Optional, Tuple, Union
|
from typing import Iterator, List, Optional, Tuple, Union
|
||||||
|
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.http.response import FileResponse
|
from django.http.response import FileResponse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
|
|||||||
24
django-stubs/core/cache/backends/locmem.pyi
vendored
24
django-stubs/core/cache/backends/locmem.pyi
vendored
@@ -1,26 +1,6 @@
|
|||||||
from typing import Any, Callable, Dict, Optional, Union
|
from typing import Any, Dict
|
||||||
|
|
||||||
from django.core.cache.backends.base import BaseCache
|
from django.core.cache.backends.base import BaseCache
|
||||||
|
|
||||||
class LocMemCache(BaseCache):
|
class LocMemCache(BaseCache):
|
||||||
default_timeout: int
|
def __init__(self, name: str, params: Dict[str, Any]) -> None: ...
|
||||||
key_func: Callable
|
|
||||||
key_prefix: str
|
|
||||||
version: int
|
|
||||||
def __init__(self, name: str, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
|
|
||||||
def add(
|
|
||||||
self,
|
|
||||||
key: str,
|
|
||||||
value: Union[Dict[str, int], Dict[str, str], bytes, int, str],
|
|
||||||
timeout: Any = ...,
|
|
||||||
version: Optional[int] = ...,
|
|
||||||
) -> Any: ...
|
|
||||||
def get(
|
|
||||||
self, key: Union[int, str], default: Optional[Union[int, str]] = ..., version: Optional[int] = ...
|
|
||||||
) -> Any: ...
|
|
||||||
def set(self, key: Union[int, str], value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
|
||||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> Any: ...
|
|
||||||
def incr(self, key: Union[int, str], delta: int = ..., version: Optional[int] = ...) -> int: ...
|
|
||||||
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
|
|
||||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
|
||||||
def clear(self) -> None: ...
|
|
||||||
|
|||||||
10
django-stubs/core/cache/backends/memcached.pyi
vendored
Normal file
10
django-stubs/core/cache/backends/memcached.pyi
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django.core.cache.backends.base import BaseCache
|
||||||
|
|
||||||
|
class BaseMemcachedCache(BaseCache):
|
||||||
|
def __init__(self, server, params, library, value_not_found_exception) -> None: ...
|
||||||
|
|
||||||
|
class MemcachedCache(BaseMemcachedCache):
|
||||||
|
def __init__(self, server, params): ...
|
||||||
|
|
||||||
|
class PyLibMCCache(BaseMemcachedCache):
|
||||||
|
def __init__(self, server, params): ...
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import Error
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ...
|
def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.core.checks.messages import Warning
|
from django.core.checks.messages import Warning
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.core.checks.messages import Warning
|
from django.core.checks.messages import Warning
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.core.checks.messages import Warning
|
from django.core.checks.messages import Warning
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import Error
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Callable, List, Optional, Tuple, Union
|
from typing import Any, Callable, List, Tuple, Union
|
||||||
|
|
||||||
from django.core.checks.messages import CheckMessage, Error, Warning
|
from django.core.checks.messages import CheckMessage, Error, Warning
|
||||||
from django.urls.resolvers import URLPattern, URLResolver
|
from django.urls.resolvers import URLPattern, URLResolver
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class File(FileProxyMixin, IO[Any]):
|
|||||||
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
||||||
def __bool__(self) -> bool: ...
|
def __bool__(self) -> bool: ...
|
||||||
def __len__(self) -> int: ...
|
def __len__(self) -> int: ...
|
||||||
|
@property
|
||||||
def size(self) -> int: ...
|
def size(self) -> int: ...
|
||||||
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
|
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
|
||||||
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
|
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ from django.utils.datastructures import MultiValueDict
|
|||||||
class UploadFileException(Exception): ...
|
class UploadFileException(Exception): ...
|
||||||
|
|
||||||
class StopUpload(UploadFileException):
|
class StopUpload(UploadFileException):
|
||||||
connection_reset = ... # type: bool
|
connection_reset: bool = ...
|
||||||
def __init__(self, connection_reset: bool = False) -> None: ...
|
def __init__(self, connection_reset: bool = ...) -> None: ...
|
||||||
|
|
||||||
class SkipFile(UploadFileException): ...
|
class SkipFile(UploadFileException): ...
|
||||||
class StopFutureHandlers(UploadFileException): ...
|
class StopFutureHandlers(UploadFileException): ...
|
||||||
@@ -23,9 +23,14 @@ class FileUploadHandler:
|
|||||||
content_type_extra = ... # type: Optional[Dict[str, str]]
|
content_type_extra = ... # type: Optional[Dict[str, str]]
|
||||||
request = ... # type: Optional[HttpRequest]
|
request = ... # type: Optional[HttpRequest]
|
||||||
field_name = ... # type: str
|
field_name = ... # type: str
|
||||||
def __init__(self, request: HttpRequest = None) -> None: ...
|
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
|
||||||
def handle_raw_input(
|
def handle_raw_input(
|
||||||
self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, encoding: str = None
|
self,
|
||||||
|
input_data: IO[bytes],
|
||||||
|
META: Dict[str, str],
|
||||||
|
content_length: int,
|
||||||
|
boundary: str,
|
||||||
|
encoding: Optional[str] = ...,
|
||||||
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
|
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
|
||||||
def new_file(
|
def new_file(
|
||||||
self,
|
self,
|
||||||
@@ -33,15 +38,15 @@ class FileUploadHandler:
|
|||||||
file_name: str,
|
file_name: str,
|
||||||
content_type: str,
|
content_type: str,
|
||||||
content_length: Optional[int],
|
content_length: Optional[int],
|
||||||
charset: str = None,
|
charset: Optional[str] = ...,
|
||||||
content_type_extra: Dict[str, str] = None,
|
content_type_extra: Optional[Dict[str, str]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||||
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
||||||
def upload_complete(self) -> None: ...
|
def upload_complete(self) -> None: ...
|
||||||
|
|
||||||
class TemporaryFileUploadHandler(FileUploadHandler):
|
class TemporaryFileUploadHandler(FileUploadHandler):
|
||||||
def __init__(self, request: HttpRequest = None) -> None: ...
|
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
|
||||||
file = ... # type: TemporaryUploadedFile
|
file = ... # type: TemporaryUploadedFile
|
||||||
def new_file(
|
def new_file(
|
||||||
self,
|
self,
|
||||||
@@ -49,8 +54,8 @@ class TemporaryFileUploadHandler(FileUploadHandler):
|
|||||||
file_name: str,
|
file_name: str,
|
||||||
content_type: str,
|
content_type: str,
|
||||||
content_length: Optional[int],
|
content_length: Optional[int],
|
||||||
charset: str = None,
|
charset: Optional[str] = ...,
|
||||||
content_type_extra: Dict[str, str] = None,
|
content_type_extra: Optional[Dict[str, str]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||||
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
||||||
@@ -59,7 +64,12 @@ class MemoryFileUploadHandler(FileUploadHandler):
|
|||||||
activated = ... # type: bool
|
activated = ... # type: bool
|
||||||
file = ... # type: IO[bytes]
|
file = ... # type: IO[bytes]
|
||||||
def handle_raw_input(
|
def handle_raw_input(
|
||||||
self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, encoding: str = None
|
self,
|
||||||
|
input_data: IO[bytes],
|
||||||
|
META: Dict[str, str],
|
||||||
|
content_length: int,
|
||||||
|
boundary: str,
|
||||||
|
encoding: Optional[str] = ...,
|
||||||
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
|
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
|
||||||
def new_file(
|
def new_file(
|
||||||
self,
|
self,
|
||||||
@@ -67,8 +77,8 @@ class MemoryFileUploadHandler(FileUploadHandler):
|
|||||||
file_name: str,
|
file_name: str,
|
||||||
content_type: str,
|
content_type: str,
|
||||||
content_length: Optional[int],
|
content_length: Optional[int],
|
||||||
charset: str = None,
|
charset: Optional[str] = ...,
|
||||||
content_type_extra: Dict[str, str] = None,
|
content_type_extra: Optional[Dict[str, str]] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||||
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ from django.http.response import HttpResponse, HttpResponseBase
|
|||||||
logger: Any
|
logger: Any
|
||||||
|
|
||||||
class BaseHandler:
|
class BaseHandler:
|
||||||
_view_middleware: None = ...
|
|
||||||
_template_response_middleware: None = ...
|
|
||||||
_exception_middleware: None = ...
|
|
||||||
_middleware_chain: None = ...
|
|
||||||
def load_middleware(self) -> None: ...
|
def load_middleware(self) -> None: ...
|
||||||
def make_view_atomic(self, view: Callable) -> Callable: ...
|
def make_view_atomic(self, view: Callable) -> Callable: ...
|
||||||
def get_exception_response(self, request: Any, resolver: Any, status_code: Any, exception: Any): ...
|
def get_exception_response(self, request: Any, resolver: Any, status_code: Any, exception: Any): ...
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class EmailMessage:
|
|||||||
to: Optional[Union[Sequence[str], str]] = ...,
|
to: Optional[Union[Sequence[str], str]] = ...,
|
||||||
bcc: Optional[Union[Sequence[str], str]] = ...,
|
bcc: Optional[Union[Sequence[str], str]] = ...,
|
||||||
connection: Optional[Any] = ...,
|
connection: Optional[Any] = ...,
|
||||||
attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ...,
|
attachments: Optional[Union[List[Tuple[str, Union[str, bytes], str]], List[MIMEText]]] = ...,
|
||||||
headers: Optional[Dict[str, str]] = ...,
|
headers: Optional[Dict[str, str]] = ...,
|
||||||
cc: Optional[Union[Sequence[str], str]] = ...,
|
cc: Optional[Union[Sequence[str], str]] = ...,
|
||||||
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
|
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from argparse import ArgumentParser, HelpFormatter, Namespace
|
from argparse import ArgumentParser, HelpFormatter, Namespace
|
||||||
from io import StringIO, TextIOBase, TextIOWrapper
|
from io import StringIO, TextIOBase, TextIOWrapper
|
||||||
from typing import Any, Callable, List, Optional, Union
|
from typing import Any, Callable, List, Optional, Union, Tuple
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
from django.core.management.color import Style
|
from django.core.management.color import Style
|
||||||
@@ -36,8 +36,8 @@ class BaseCommand:
|
|||||||
output_transaction: bool = ...
|
output_transaction: bool = ...
|
||||||
requires_migrations_checks: bool = ...
|
requires_migrations_checks: bool = ...
|
||||||
requires_system_checks: bool = ...
|
requires_system_checks: bool = ...
|
||||||
base_stealth_options: Any = ...
|
base_stealth_options: Tuple[str, ...] = ...
|
||||||
stealth_options: Any = ...
|
stealth_options: Tuple[str, ...] = ...
|
||||||
stdout: OutputWrapper = ...
|
stdout: OutputWrapper = ...
|
||||||
stderr: OutputWrapper = ...
|
stderr: OutputWrapper = ...
|
||||||
style: Style = ...
|
style: Style = ...
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
from collections import Callable
|
|
||||||
|
|
||||||
def supports_color() -> bool: ...
|
def supports_color() -> bool: ...
|
||||||
|
|
||||||
class Style:
|
class Style:
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import os
|
from typing import Any, Optional, Pattern, Type
|
||||||
import re
|
|
||||||
from typing import Any, Pattern, Type, Optional
|
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.utils.functional import cached_property
|
|
||||||
from django.utils.jslex import prepare_js_for_gettext
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import templatize
|
|
||||||
|
|
||||||
plural_forms_re: Pattern = ...
|
plural_forms_re: Pattern = ...
|
||||||
STATUS_OK: int = ...
|
STATUS_OK: int = ...
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
class Command(BaseCommand): ...
|
class Command(BaseCommand):
|
||||||
|
default_addr: str = ...
|
||||||
|
default_addr_ipv6: str = ...
|
||||||
|
default_port: int = ...
|
||||||
|
protocol: str = ...
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ from django.db.models.base import Model
|
|||||||
|
|
||||||
def popen_wrapper(args: List[str], stdout_encoding: str = ...) -> Tuple[str, str, int]: ...
|
def popen_wrapper(args: List[str], stdout_encoding: str = ...) -> Tuple[str, str, int]: ...
|
||||||
def handle_extensions(extensions: List[str]) -> Set[str]: ...
|
def handle_extensions(extensions: List[str]) -> Set[str]: ...
|
||||||
def find_command(cmd: str, path: None = ..., pathext: None = ...) -> Optional[str]: ...
|
def find_command(cmd: str, path: Optional[str] = ..., pathext: Optional[str] = ...) -> Optional[str]: ...
|
||||||
def get_random_secret_key(): ...
|
def get_random_secret_key(): ...
|
||||||
def parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ...
|
def parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Dict, List, Optional, Union, Iterable, Sequence, Protocol, Any
|
from typing import Dict, List, Optional, Protocol, Sequence, Union
|
||||||
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
@@ -32,7 +32,9 @@ class Paginator:
|
|||||||
def validate_number(self, number: Optional[Union[float, str]]) -> int: ...
|
def validate_number(self, number: Optional[Union[float, str]]) -> int: ...
|
||||||
def get_page(self, number: Optional[int]) -> Page: ...
|
def get_page(self, number: Optional[int]) -> Page: ...
|
||||||
def page(self, number: Union[int, str]) -> Page: ...
|
def page(self, number: Union[int, str]) -> Page: ...
|
||||||
|
@property
|
||||||
def count(self) -> int: ...
|
def count(self) -> int: ...
|
||||||
|
@property
|
||||||
def num_pages(self) -> int: ...
|
def num_pages(self) -> int: ...
|
||||||
@property
|
@property
|
||||||
def page_range(self) -> range: ...
|
def page_range(self) -> range: ...
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from typing import Any, Dict
|
|||||||
from wsgiref import simple_server
|
from wsgiref import simple_server
|
||||||
|
|
||||||
from django.core.handlers.wsgi import WSGIRequest, WSGIHandler
|
from django.core.handlers.wsgi import WSGIRequest, WSGIHandler
|
||||||
from django.core.wsgi import get_wsgi_application as get_wsgi_application
|
from django.core.wsgi import get_wsgi_application as get_wsgi_application # noqa: F401
|
||||||
|
|
||||||
class WSGIServer(simple_server.WSGIServer):
|
class WSGIServer(simple_server.WSGIServer):
|
||||||
request_queue_size: int = ...
|
request_queue_size: int = ...
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import timedelta
|
||||||
from typing import Any, Dict, List, Optional, Type, Union, Protocol
|
from typing import Any, Dict, Optional, Protocol, Type, Union
|
||||||
|
|
||||||
from django.contrib.sessions.serializers import PickleSerializer
|
|
||||||
|
|
||||||
class BadSignature(Exception): ...
|
class BadSignature(Exception): ...
|
||||||
class SignatureExpired(BadSignature): ...
|
class SignatureExpired(BadSignature): ...
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Union, Pattern, Collection
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from django.core.files.base import File
|
from django.core.files.base import File
|
||||||
from django.core.exceptions import ValidationError as ValidationError
|
from django.core.exceptions import ValidationError as ValidationError # noqa: F401
|
||||||
|
|
||||||
EMPTY_VALUES: Any
|
EMPTY_VALUES: Any
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any
|
||||||
|
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Any, List, Optional, Set, Tuple, Type, Union, Sequence
|
from typing import Any, List, Optional, Sequence, Tuple, Type, Union
|
||||||
|
|
||||||
from django.core.management.color import Style
|
from django.core.management.color import Style
|
||||||
from django.db import DefaultConnectionProxy
|
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||||
from django.db.backends.utils import CursorWrapper
|
from django.db.backends.utils import CursorWrapper
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.expressions import Case, Expression
|
from django.db.models.expressions import Case, Expression
|
||||||
from django.db.models.fields import Field
|
|
||||||
from django.db.models.sql.compiler import SQLCompiler
|
from django.db.models.sql.compiler import SQLCompiler
|
||||||
|
|
||||||
|
from django.db import DefaultConnectionProxy
|
||||||
|
from django.db.models.fields import Field
|
||||||
|
|
||||||
class BaseDatabaseOperations:
|
class BaseDatabaseOperations:
|
||||||
compiler_module: str = ...
|
compiler_module: str = ...
|
||||||
integer_field_ranges: Any = ...
|
integer_field_ranges: Any = ...
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from typing import Any, List, Optional
|
from typing import Any, List
|
||||||
|
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
|
|
||||||
from django.db.models.fields import Field
|
from django.db.models.fields import Field
|
||||||
|
|
||||||
class BaseDatabaseValidation:
|
class BaseDatabaseValidation:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
from django.db.backends.base.client import BaseDatabaseClient
|
from django.db.backends.base.client import BaseDatabaseClient
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Dict, Optional
|
from typing import Dict
|
||||||
|
|
||||||
from django.db.backends.base.client import BaseDatabaseClient
|
from django.db.backends.base.client import BaseDatabaseClient
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from sqlite3 import dbapi2 as Database
|
from sqlite3 import dbapi2 as Database
|
||||||
from sqlite3 import dbapi2 as Database
|
from typing import Any, Callable
|
||||||
from typing import Any, Callable, Iterator
|
|
||||||
|
|
||||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import types
|
||||||
from datetime import date, datetime, time
|
from datetime import date, datetime, time
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple, Union
|
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
logger: Any
|
logger: Any
|
||||||
@@ -16,7 +17,12 @@ class CursorWrapper:
|
|||||||
def __getattr__(self, attr: str) -> Any: ...
|
def __getattr__(self, attr: str) -> Any: ...
|
||||||
def __iter__(self) -> None: ...
|
def __iter__(self) -> None: ...
|
||||||
def __enter__(self) -> CursorWrapper: ...
|
def __enter__(self) -> CursorWrapper: ...
|
||||||
def __exit__(self, type: None, value: None, traceback: None) -> None: ...
|
def __exit__(
|
||||||
|
self,
|
||||||
|
exc_type: Optional[Type[BaseException]],
|
||||||
|
exc_value: Optional[BaseException],
|
||||||
|
tb: Optional[types.TracebackType],
|
||||||
|
) -> None: ...
|
||||||
def callproc(self, procname: str, params: List[Any] = ..., kparams: Dict[str, int] = ...) -> Any: ...
|
def callproc(self, procname: str, params: List[Any] = ..., kparams: Dict[str, int] = ...) -> Any: ...
|
||||||
def execute(
|
def execute(
|
||||||
self, sql: str, params: Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]] = ...
|
self, sql: str, params: Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]] = ...
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from django.db.migrations.migration import Migration
|
from django.db.migrations.migration import Migration
|
||||||
from django.db.utils import DatabaseError
|
from django.db.utils import DatabaseError
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Callable, List, Optional, Tuple, Union, Set, Dict
|
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
||||||
|
|
||||||
from django.db.migrations.migration import Migration, SwappableTuple
|
from django.db.migrations.migration import Migration, SwappableTuple
|
||||||
from django.db.migrations.state import ProjectState
|
from django.db.migrations.state import ProjectState
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Tuple, Type, List
|
from typing import Any, List, Tuple
|
||||||
|
|
||||||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
from django.db.migrations.state import ProjectState
|
from django.db.migrations.state import ProjectState
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, Iterable, Union, Optional, List
|
from typing import Any
|
||||||
|
|
||||||
COMPILED_REGEX_TYPE: Any
|
COMPILED_REGEX_TYPE: Any
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from django.db.models.expressions import Func
|
|||||||
class Aggregate(Func):
|
class Aggregate(Func):
|
||||||
filter_template: str = ...
|
filter_template: str = ...
|
||||||
filter: Any = ...
|
filter: Any = ...
|
||||||
|
allow_distinct: bool = ...
|
||||||
def __init__(self, *expressions: Any, distinct: bool = ..., filter: Optional[Any] = ..., **extra: Any) -> None: ...
|
def __init__(self, *expressions: Any, distinct: bool = ..., filter: Optional[Any] = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
class Avg(Aggregate): ...
|
class Avg(Aggregate): ...
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union, ClassVar, Type
|
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union
|
||||||
|
|
||||||
from django.db.models.manager import Manager
|
|
||||||
|
|
||||||
from django.core.checks.messages import CheckMessage
|
from django.core.checks.messages import CheckMessage
|
||||||
|
from django.db.models.manager import Manager
|
||||||
from django.db.models.options import Options
|
from django.db.models.options import Options
|
||||||
|
|
||||||
_Self = TypeVar("_Self", bound="Model")
|
_Self = TypeVar("_Self", bound="Model")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from django.db.models.sql.compiler import SQLCompiler
|
|||||||
|
|
||||||
from django.db.models import Q, QuerySet
|
from django.db.models import Q, QuerySet
|
||||||
from django.db.models.fields import Field
|
from django.db.models.fields import Field
|
||||||
|
from django.db.models.query import _BaseQuerySet
|
||||||
|
|
||||||
_OutputField = Union[Field, str]
|
_OutputField = Union[Field, str]
|
||||||
|
|
||||||
@@ -125,7 +126,7 @@ class Subquery(Expression):
|
|||||||
template: str = ...
|
template: str = ...
|
||||||
queryset: QuerySet = ...
|
queryset: QuerySet = ...
|
||||||
extra: Dict[Any, Any] = ...
|
extra: Dict[Any, Any] = ...
|
||||||
def __init__(self, queryset: QuerySet, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ...
|
def __init__(self, queryset: _BaseQuerySet, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
class Exists(Subquery):
|
class Exists(Subquery):
|
||||||
negated: bool = ...
|
negated: bool = ...
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ _GT = TypeVar("_GT")
|
|||||||
class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||||
_pyi_private_set_type: Any
|
_pyi_private_set_type: Any
|
||||||
_pyi_private_get_type: Any
|
_pyi_private_get_type: Any
|
||||||
|
_pyi_lookup_exact_type: Any
|
||||||
|
|
||||||
widget: Widget
|
widget: Widget
|
||||||
help_text: str
|
help_text: str
|
||||||
@@ -55,9 +56,11 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
|||||||
model: Type[Model]
|
model: Type[Model]
|
||||||
name: str
|
name: str
|
||||||
verbose_name: str
|
verbose_name: str
|
||||||
|
description: str
|
||||||
blank: bool = ...
|
blank: bool = ...
|
||||||
null: bool = ...
|
null: bool = ...
|
||||||
editable: bool = ...
|
editable: bool = ...
|
||||||
|
empty_strings_allowed: bool = ...
|
||||||
choices: Optional[_FieldChoices] = ...
|
choices: Optional[_FieldChoices] = ...
|
||||||
db_column: Optional[str]
|
db_column: Optional[str]
|
||||||
column: str
|
column: str
|
||||||
@@ -129,6 +132,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
|||||||
class IntegerField(Field[_ST, _GT]):
|
class IntegerField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[float, int, str, Combinable]
|
_pyi_private_set_type: Union[float, int, str, Combinable]
|
||||||
_pyi_private_get_type: int
|
_pyi_private_get_type: int
|
||||||
|
_pyi_lookup_exact_type: int
|
||||||
|
|
||||||
class PositiveIntegerRelDbTypeMixin:
|
class PositiveIntegerRelDbTypeMixin:
|
||||||
def rel_db_type(self, connection: Any): ...
|
def rel_db_type(self, connection: Any): ...
|
||||||
@@ -141,10 +145,12 @@ class BigIntegerField(IntegerField[_ST, _GT]): ...
|
|||||||
class FloatField(Field[_ST, _GT]):
|
class FloatField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[float, int, str, Combinable]
|
_pyi_private_set_type: Union[float, int, str, Combinable]
|
||||||
_pyi_private_get_type: float
|
_pyi_private_get_type: float
|
||||||
|
_pyi_lookup_exact_type: float
|
||||||
|
|
||||||
class DecimalField(Field[_ST, _GT]):
|
class DecimalField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[str, float, decimal.Decimal, Combinable]
|
_pyi_private_set_type: Union[str, float, decimal.Decimal, Combinable]
|
||||||
_pyi_private_get_type: decimal.Decimal
|
_pyi_private_get_type: decimal.Decimal
|
||||||
|
_pyi_lookup_exact_type: Union[str, decimal.Decimal]
|
||||||
# attributes
|
# attributes
|
||||||
max_digits: int = ...
|
max_digits: int = ...
|
||||||
decimal_places: int = ...
|
decimal_places: int = ...
|
||||||
@@ -174,10 +180,13 @@ class DecimalField(Field[_ST, _GT]):
|
|||||||
class AutoField(Field[_ST, _GT]):
|
class AutoField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[Combinable, int, str]
|
_pyi_private_set_type: Union[Combinable, int, str]
|
||||||
_pyi_private_get_type: int
|
_pyi_private_get_type: int
|
||||||
|
_pyi_lookup_exact_type: int
|
||||||
|
|
||||||
class CharField(Field[_ST, _GT]):
|
class CharField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[str, int, Combinable]
|
_pyi_private_set_type: Union[str, int, Combinable]
|
||||||
_pyi_private_get_type: str
|
_pyi_private_get_type: str
|
||||||
|
# objects are converted to string before comparison
|
||||||
|
_pyi_lookup_exact_type: Any
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||||
@@ -236,14 +245,18 @@ class URLField(CharField[_ST, _GT]): ...
|
|||||||
class TextField(Field[_ST, _GT]):
|
class TextField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[str, Combinable]
|
_pyi_private_set_type: Union[str, Combinable]
|
||||||
_pyi_private_get_type: str
|
_pyi_private_get_type: str
|
||||||
|
# objects are converted to string before comparison
|
||||||
|
_pyi_lookup_exact_type: Any
|
||||||
|
|
||||||
class BooleanField(Field[_ST, _GT]):
|
class BooleanField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[bool, Combinable]
|
_pyi_private_set_type: Union[bool, Combinable]
|
||||||
_pyi_private_get_type: bool
|
_pyi_private_get_type: bool
|
||||||
|
_pyi_lookup_exact_type: bool
|
||||||
|
|
||||||
class NullBooleanField(Field[_ST, _GT]):
|
class NullBooleanField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Optional[Union[bool, Combinable]]
|
_pyi_private_set_type: Optional[Union[bool, Combinable]]
|
||||||
_pyi_private_get_type: Optional[bool]
|
_pyi_private_get_type: Optional[bool]
|
||||||
|
_pyi_lookup_exact_type: Optional[bool]
|
||||||
|
|
||||||
class IPAddressField(Field[_ST, _GT]):
|
class IPAddressField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[str, Combinable]
|
_pyi_private_set_type: Union[str, Combinable]
|
||||||
@@ -284,6 +297,7 @@ class DateTimeCheckMixin: ...
|
|||||||
class DateField(DateTimeCheckMixin, Field[_ST, _GT]):
|
class DateField(DateTimeCheckMixin, Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[str, date, Combinable]
|
_pyi_private_set_type: Union[str, date, Combinable]
|
||||||
_pyi_private_get_type: date
|
_pyi_private_get_type: date
|
||||||
|
_pyi_lookup_exact_type: Union[str, date]
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||||
@@ -336,6 +350,7 @@ class TimeField(DateTimeCheckMixin, Field[_ST, _GT]):
|
|||||||
|
|
||||||
class DateTimeField(DateField[_ST, _GT]):
|
class DateTimeField(DateField[_ST, _GT]):
|
||||||
_pyi_private_get_type: datetime
|
_pyi_private_get_type: datetime
|
||||||
|
_pyi_lookup_exact_type: Union[str, datetime]
|
||||||
|
|
||||||
class UUIDField(Field[_ST, _GT]):
|
class UUIDField(Field[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[str, uuid.UUID]
|
_pyi_private_set_type: Union[str, uuid.UUID]
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable
|
from typing import Any, Callable, Iterable, List, Optional, Tuple, Type, TypeVar, Union, overload
|
||||||
|
|
||||||
from django.core.checks.messages import Error
|
|
||||||
from django.core.files.base import File
|
from django.core.files.base import File
|
||||||
from django.core.files.images import ImageFile
|
from django.core.files.images import ImageFile
|
||||||
from django.core.files.storage import FileSystemStorage, Storage
|
from django.core.files.storage import FileSystemStorage, Storage
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
|
||||||
from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride
|
from django.db.models.fields import Field, _FieldChoices, _ValidatorCallable, _ErrorMessagesToOverride
|
||||||
from django.forms import fields as form_fields
|
|
||||||
|
|
||||||
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
BLANK_CHOICE_DASH: List[Tuple[str, str]] = ...
|
||||||
|
|
||||||
@@ -34,6 +32,8 @@ class FileDescriptor:
|
|||||||
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
||||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
||||||
|
|
||||||
|
_T = TypeVar("_T", bound="Field")
|
||||||
|
|
||||||
class FileField(Field):
|
class FileField(Field):
|
||||||
storage: Any = ...
|
storage: Any = ...
|
||||||
upload_to: Union[str, Callable] = ...
|
upload_to: Union[str, Callable] = ...
|
||||||
@@ -63,6 +63,15 @@ class FileField(Field):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
|
# class access
|
||||||
|
@overload # type: ignore
|
||||||
|
def __get__(self, instance: None, owner) -> FileDescriptor: ...
|
||||||
|
# Model instance access
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: Model, owner) -> Any: ...
|
||||||
|
# non-Model instances
|
||||||
|
@overload
|
||||||
|
def __get__(self: _T, instance, owner) -> _T: ...
|
||||||
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
||||||
|
|
||||||
class ImageFileDescriptor(FileDescriptor):
|
class ImageFileDescriptor(FileDescriptor):
|
||||||
@@ -82,4 +91,13 @@ class ImageField(FileField):
|
|||||||
height_field: Optional[str] = ...,
|
height_field: Optional[str] = ...,
|
||||||
**kwargs: Any
|
**kwargs: Any
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
# class access
|
||||||
|
@overload # type: ignore
|
||||||
|
def __get__(self, instance: None, owner) -> ImageFileDescriptor: ...
|
||||||
|
# Model instance access
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: Model, owner) -> Any: ...
|
||||||
|
# non-Model instances
|
||||||
|
@overload
|
||||||
|
def __get__(self: _T, instance, owner) -> _T: ...
|
||||||
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
|
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
|||||||
@@ -1,31 +1,29 @@
|
|||||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, TYPE_CHECKING, Tuple, Type, TypeVar, Union
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Type, TypeVar, Union, overload
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.db.models.base import Model
|
||||||
|
from django.db.models.fields import Field
|
||||||
|
from django.db.models.query_utils import Q, PathInfo
|
||||||
|
from django.db.models.manager import RelatedManager
|
||||||
from django.db.models.expressions import Combinable
|
from django.db.models.expressions import Combinable
|
||||||
from django.db.models.fields.mixins import FieldCacheMixin
|
from django.db.models.fields.mixins import FieldCacheMixin
|
||||||
from django.db.models.query_utils import PathInfo, Q
|
from django.db.models.fields.related_descriptors import ( # noqa: F401
|
||||||
|
|
||||||
from django.db import models
|
|
||||||
from django.db.models import Field, Model
|
|
||||||
from django.db.models.fields.related_descriptors import (
|
|
||||||
ForwardOneToOneDescriptor as ForwardOneToOneDescriptor,
|
ForwardOneToOneDescriptor as ForwardOneToOneDescriptor,
|
||||||
ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
|
ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
|
||||||
ManyToManyDescriptor as ManyToManyDescriptor,
|
ManyToManyDescriptor as ManyToManyDescriptor,
|
||||||
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor,
|
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor,
|
||||||
ReverseManyToOneDescriptor as ReverseManyToOneDescriptor,
|
ReverseManyToOneDescriptor as ReverseManyToOneDescriptor,
|
||||||
)
|
)
|
||||||
from django.db.models.fields.reverse_related import (
|
from django.db.models.fields.reverse_related import ( # noqa: F401
|
||||||
ForeignObjectRel as ForeignObjectRel,
|
ForeignObjectRel as ForeignObjectRel,
|
||||||
OneToOneRel as OneToOneRel,
|
OneToOneRel as OneToOneRel,
|
||||||
ManyToOneRel as ManyToOneRel,
|
ManyToOneRel as ManyToOneRel,
|
||||||
ManyToManyRel as ManyToManyRel,
|
ManyToManyRel as ManyToManyRel,
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from django.db.models.manager import RelatedManager
|
|
||||||
|
|
||||||
_T = TypeVar("_T", bound=models.Model)
|
_T = TypeVar("_T", bound=models.Model)
|
||||||
|
_F = TypeVar("_F", bound=models.Field)
|
||||||
_Choice = Tuple[Any, str]
|
_Choice = Tuple[Any, str]
|
||||||
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
||||||
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||||
@@ -66,9 +64,9 @@ class ForeignObject(RelatedField[_ST, _GT]):
|
|||||||
on_delete: Callable[..., None],
|
on_delete: Callable[..., None],
|
||||||
from_fields: Sequence[str],
|
from_fields: Sequence[str],
|
||||||
to_fields: Sequence[str],
|
to_fields: Sequence[str],
|
||||||
rel: None = ...,
|
rel: Optional[ForeignObjectRel] = ...,
|
||||||
related_name: Optional[str] = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: None = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||||
parent_link: bool = ...,
|
parent_link: bool = ...,
|
||||||
db_constraint: bool = ...,
|
db_constraint: bool = ...,
|
||||||
@@ -100,7 +98,7 @@ class ForeignKey(ForeignObject[_ST, _GT]):
|
|||||||
to: Union[Type[Model], str],
|
to: Union[Type[Model], str],
|
||||||
on_delete: Callable[..., None],
|
on_delete: Callable[..., None],
|
||||||
to_field: Optional[str] = ...,
|
to_field: Optional[str] = ...,
|
||||||
related_name: str = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
|
||||||
parent_link: bool = ...,
|
parent_link: bool = ...,
|
||||||
@@ -127,6 +125,15 @@ class ForeignKey(ForeignObject[_ST, _GT]):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
|
# class access
|
||||||
|
@overload # type: ignore
|
||||||
|
def __get__(self, instance: None, owner) -> ForwardManyToOneDescriptor: ...
|
||||||
|
# Model instance access
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: Model, owner) -> _GT: ...
|
||||||
|
# non-Model instances
|
||||||
|
@overload
|
||||||
|
def __get__(self: _F, instance, owner) -> _F: ...
|
||||||
|
|
||||||
class OneToOneField(RelatedField[_ST, _GT]):
|
class OneToOneField(RelatedField[_ST, _GT]):
|
||||||
_pyi_private_set_type: Union[Any, Combinable]
|
_pyi_private_set_type: Union[Any, Combinable]
|
||||||
@@ -136,7 +143,7 @@ class OneToOneField(RelatedField[_ST, _GT]):
|
|||||||
to: Union[Type[Model], str],
|
to: Union[Type[Model], str],
|
||||||
on_delete: Any,
|
on_delete: Any,
|
||||||
to_field: Optional[str] = ...,
|
to_field: Optional[str] = ...,
|
||||||
related_name: str = ...,
|
related_name: Optional[str] = ...,
|
||||||
related_query_name: Optional[str] = ...,
|
related_query_name: Optional[str] = ...,
|
||||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
|
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any], Q]] = ...,
|
||||||
parent_link: bool = ...,
|
parent_link: bool = ...,
|
||||||
@@ -163,6 +170,15 @@ class OneToOneField(RelatedField[_ST, _GT]):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
|
# class access
|
||||||
|
@overload # type: ignore
|
||||||
|
def __get__(self, instance: None, owner) -> ForwardOneToOneDescriptor: ...
|
||||||
|
# Model instance access
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: Model, owner) -> _GT: ...
|
||||||
|
# non-Model instances
|
||||||
|
@overload
|
||||||
|
def __get__(self: _F, instance, owner) -> _F: ...
|
||||||
|
|
||||||
class ManyToManyField(RelatedField[_ST, _GT]):
|
class ManyToManyField(RelatedField[_ST, _GT]):
|
||||||
_pyi_private_set_type: Sequence[Any]
|
_pyi_private_set_type: Sequence[Any]
|
||||||
@@ -206,7 +222,15 @@ class ManyToManyField(RelatedField[_ST, _GT]):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def __get__(self, instance, owner) -> _GT: ... # type: ignore
|
# class access
|
||||||
|
@overload # type: ignore
|
||||||
|
def __get__(self, instance: None, owner) -> ManyToManyDescriptor: ...
|
||||||
|
# Model instance access
|
||||||
|
@overload
|
||||||
|
def __get__(self, instance: Model, owner) -> _GT: ...
|
||||||
|
# non-Model instances
|
||||||
|
@overload
|
||||||
|
def __get__(self: _F, instance, owner) -> _F: ...
|
||||||
def get_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
def get_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
||||||
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
||||||
def contribute_to_related_class(self, cls: Type[Model], related: RelatedField) -> None: ...
|
def contribute_to_related_class(self, cls: Type[Model], related: RelatedField) -> None: ...
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.fields import AutoField, Field
|
|
||||||
from django.db.models.fields.related import ForeignKey, OneToOneField, RelatedField
|
from django.db.models.fields.related import ForeignKey, OneToOneField, RelatedField
|
||||||
from django.db.models.lookups import BuiltinLookup, StartsWith
|
from django.db.models.lookups import BuiltinLookup, StartsWith
|
||||||
from django.db.models.query_utils import FilteredRelation, PathInfo, Q
|
from django.db.models.query_utils import FilteredRelation, PathInfo
|
||||||
from django.db.models.sql.where import WhereNode
|
from django.db.models.sql.where import WhereNode
|
||||||
|
|
||||||
|
from django.db.models.fields import AutoField, Field
|
||||||
from .mixins import FieldCacheMixin
|
from .mixins import FieldCacheMixin
|
||||||
|
|
||||||
class ForeignObjectRel(FieldCacheMixin):
|
class ForeignObjectRel(FieldCacheMixin):
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
from collections import OrderedDict
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union, Mapping
|
from typing import Any, Iterable, List, Optional, Tuple, Type, Union, Mapping, TypeVar, Generic
|
||||||
|
|
||||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||||
from django.db.models.expressions import Combinable, Expression, Func
|
from django.db.models.expressions import Expression, Func
|
||||||
from django.db.models.query_utils import RegisterLookupMixin
|
from django.db.models.query_utils import RegisterLookupMixin
|
||||||
from django.db.models.sql.compiler import SQLCompiler
|
from django.db.models.sql.compiler import SQLCompiler
|
||||||
from django.db.models.sql.query import Query
|
|
||||||
from django.utils.datastructures import OrderedSet
|
from django.utils.datastructures import OrderedSet
|
||||||
from django.utils.safestring import SafeText
|
from django.utils.safestring import SafeText
|
||||||
|
|
||||||
from django.db.models.fields import TextField, related_lookups
|
from django.db.models.fields import TextField, related_lookups
|
||||||
|
|
||||||
class Lookup:
|
_T = TypeVar("_T")
|
||||||
|
|
||||||
|
class Lookup(Generic[_T]):
|
||||||
lookup_name: str = ...
|
lookup_name: str = ...
|
||||||
prepare_rhs: bool = ...
|
prepare_rhs: bool = ...
|
||||||
can_use_none_as_rhs: bool = ...
|
can_use_none_as_rhs: bool = ...
|
||||||
@@ -49,7 +49,7 @@ class Transform(RegisterLookupMixin, Func):
|
|||||||
def lhs(self) -> Expression: ...
|
def lhs(self) -> Expression: ...
|
||||||
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...
|
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...
|
||||||
|
|
||||||
class BuiltinLookup(Lookup):
|
class BuiltinLookup(Lookup[_T]):
|
||||||
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
|
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
|
||||||
|
|
||||||
class FieldGetDbPrepValueMixin:
|
class FieldGetDbPrepValueMixin:
|
||||||
@@ -64,21 +64,21 @@ class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
|
|||||||
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||||
class IExact(BuiltinLookup): ...
|
class IExact(BuiltinLookup): ...
|
||||||
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||||
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
|
||||||
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup[_T]): ...
|
||||||
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||||
|
|
||||||
class IntegerFieldFloatRounding:
|
class IntegerFieldFloatRounding:
|
||||||
rhs: Any = ...
|
rhs: Any = ...
|
||||||
def get_prep_lookup(self) -> Any: ...
|
def get_prep_lookup(self) -> Any: ...
|
||||||
|
|
||||||
class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual): ...
|
class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual[Union[int, float]]): ...
|
||||||
class IntegerLessThan(IntegerFieldFloatRounding, LessThan): ...
|
class IntegerLessThan(IntegerFieldFloatRounding, LessThan[Union[int, float]]): ...
|
||||||
|
|
||||||
class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
|
class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
|
||||||
def split_parameter_list_as_sql(self, compiler: Any, connection: Any): ...
|
def split_parameter_list_as_sql(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
class PatternLookup(BuiltinLookup):
|
class PatternLookup(BuiltinLookup[str]):
|
||||||
param_pattern: str = ...
|
param_pattern: str = ...
|
||||||
|
|
||||||
class Contains(PatternLookup): ...
|
class Contains(PatternLookup): ...
|
||||||
@@ -88,8 +88,8 @@ class IStartsWith(StartsWith): ...
|
|||||||
class EndsWith(PatternLookup): ...
|
class EndsWith(PatternLookup): ...
|
||||||
class IEndsWith(EndsWith): ...
|
class IEndsWith(EndsWith): ...
|
||||||
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup): ...
|
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup): ...
|
||||||
class IsNull(BuiltinLookup): ...
|
class IsNull(BuiltinLookup[bool]): ...
|
||||||
class Regex(BuiltinLookup): ...
|
class Regex(BuiltinLookup[str]): ...
|
||||||
class IRegex(Regex): ...
|
class IRegex(Regex): ...
|
||||||
|
|
||||||
class YearLookup(Lookup):
|
class YearLookup(Lookup):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from django.db.models.query import QuerySet
|
|||||||
|
|
||||||
_T = TypeVar("_T", bound=Model, covariant=True)
|
_T = TypeVar("_T", bound=Model, covariant=True)
|
||||||
|
|
||||||
class BaseManager(QuerySet[_T, _T]):
|
class BaseManager(QuerySet[_T]):
|
||||||
creation_counter: int = ...
|
creation_counter: int = ...
|
||||||
auto_created: bool = ...
|
auto_created: bool = ...
|
||||||
use_in_migrations: bool = ...
|
use_in_migrations: bool = ...
|
||||||
@@ -21,7 +21,7 @@ class BaseManager(QuerySet[_T, _T]):
|
|||||||
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
|
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
|
||||||
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
|
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
|
||||||
def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ...
|
def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ...
|
||||||
def get_queryset(self) -> QuerySet[_T, _T]: ...
|
def get_queryset(self) -> QuerySet[_T]: ...
|
||||||
|
|
||||||
class Manager(BaseManager[_T]): ...
|
class Manager(BaseManager[_T]): ...
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import collections
|
import collections
|
||||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, TypeVar, Generic, Sequence
|
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
from django.apps.registry import Apps
|
from django.apps.registry import Apps
|
||||||
@@ -9,13 +9,13 @@ from django.contrib.postgres.fields.citext import CIText
|
|||||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.fields.mixins import FieldCacheMixin
|
from django.db.models.fields.mixins import FieldCacheMixin
|
||||||
from django.db.models.fields.related import OneToOneField, ManyToManyField
|
from django.db.models.fields.related import ManyToManyField, OneToOneField
|
||||||
from django.db.models.fields.reverse_related import ForeignObjectRel
|
from django.db.models.fields.reverse_related import ForeignObjectRel
|
||||||
from django.db.models.manager import Manager
|
from django.db.models.manager import Manager
|
||||||
from django.db.models.query_utils import PathInfo
|
from django.db.models.query_utils import PathInfo
|
||||||
from django.utils.datastructures import ImmutableList
|
from django.utils.datastructures import ImmutableList
|
||||||
|
|
||||||
from django.db.models.fields import Field, mixins, AutoField
|
from django.db.models.fields import AutoField, Field
|
||||||
|
|
||||||
PROXY_PARENTS: Any
|
PROXY_PARENTS: Any
|
||||||
EMPTY_RELATION_TREE: Any
|
EMPTY_RELATION_TREE: Any
|
||||||
@@ -51,7 +51,7 @@ class Options(Generic[_M]):
|
|||||||
verbose_name: Optional[str] = ...
|
verbose_name: Optional[str] = ...
|
||||||
verbose_name_plural: Optional[str] = ...
|
verbose_name_plural: Optional[str] = ...
|
||||||
db_table: str = ...
|
db_table: str = ...
|
||||||
ordering: Optional[List[str]] = ...
|
ordering: Optional[Sequence[str]] = ...
|
||||||
indexes: List[Any] = ...
|
indexes: List[Any] = ...
|
||||||
unique_together: Union[List[Any], Tuple] = ...
|
unique_together: Union[List[Any], Tuple] = ...
|
||||||
index_together: Union[List[Any], Tuple] = ...
|
index_together: Union[List[Any], Tuple] = ...
|
||||||
@@ -71,7 +71,7 @@ class Options(Generic[_M]):
|
|||||||
abstract: bool = ...
|
abstract: bool = ...
|
||||||
managed: bool = ...
|
managed: bool = ...
|
||||||
proxy: bool = ...
|
proxy: bool = ...
|
||||||
proxy_for_model: None = ...
|
proxy_for_model: Optional[Type[Model]] = ...
|
||||||
concrete_model: Optional[Type[Model]] = ...
|
concrete_model: Optional[Type[Model]] = ...
|
||||||
swappable: None = ...
|
swappable: None = ...
|
||||||
parents: collections.OrderedDict = ...
|
parents: collections.OrderedDict = ...
|
||||||
@@ -97,7 +97,7 @@ class Options(Generic[_M]):
|
|||||||
def setup_proxy(self, target: Type[Model]) -> None: ...
|
def setup_proxy(self, target: Type[Model]) -> None: ...
|
||||||
def can_migrate(self, connection: Union[DatabaseWrapper, str]) -> bool: ...
|
def can_migrate(self, connection: Union[DatabaseWrapper, str]) -> bool: ...
|
||||||
@property
|
@property
|
||||||
def verbose_name_raw(self) -> Any: ...
|
def verbose_name_raw(self) -> str: ...
|
||||||
@property
|
@property
|
||||||
def swapped(self) -> Optional[str]: ...
|
def swapped(self) -> Optional[str]: ...
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
Collection,
|
||||||
Dict,
|
Dict,
|
||||||
|
Generic,
|
||||||
Iterable,
|
Iterable,
|
||||||
Iterator,
|
Iterator,
|
||||||
List,
|
List,
|
||||||
@@ -14,23 +16,124 @@ from typing import (
|
|||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
overload,
|
overload,
|
||||||
Generic,
|
|
||||||
NamedTuple,
|
|
||||||
Collection,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.expressions import Combinable as Combinable, F as F
|
from django.db.models.expressions import Combinable as Combinable, F as F # noqa: F401
|
||||||
from django.db.models.sql.query import Query, RawQuery
|
from django.db.models.sql.query import Query, RawQuery
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Manager
|
from django.db.models import Manager
|
||||||
from django.db.models.query_utils import Q as Q
|
from django.db.models.query_utils import Q as Q # noqa: F401
|
||||||
|
|
||||||
|
_T = TypeVar("_T", bound=models.Model, covariant=True)
|
||||||
|
_QS = TypeVar("_QS", bound="_BaseQuerySet")
|
||||||
|
|
||||||
|
class _BaseQuerySet(Generic[_T], Sized):
|
||||||
|
query: Query
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
model: Optional[Type[models.Model]] = ...,
|
||||||
|
query: Optional[Query] = ...,
|
||||||
|
using: Optional[str] = ...,
|
||||||
|
hints: Optional[Dict[str, models.Model]] = ...,
|
||||||
|
) -> None: ...
|
||||||
|
@classmethod
|
||||||
|
def as_manager(cls) -> Manager[Any]: ...
|
||||||
|
def __len__(self) -> int: ...
|
||||||
|
def __bool__(self) -> bool: ...
|
||||||
|
def __class_getitem__(cls, item: Type[_T]): ...
|
||||||
|
def __getstate__(self) -> Dict[str, Any]: ...
|
||||||
|
# Technically, the other QuerySet must be of the same type _T, but _T is covariant
|
||||||
|
def __and__(self: _QS, other: _BaseQuerySet[_T]) -> _QS: ...
|
||||||
|
def __or__(self: _QS, other: _BaseQuerySet[_T]) -> _QS: ...
|
||||||
|
def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
|
||||||
|
def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
|
||||||
|
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 = ...
|
||||||
|
) -> List[_T]: ...
|
||||||
|
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
|
||||||
|
) -> Tuple[_T, bool]: ...
|
||||||
|
def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
|
||||||
|
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
|
||||||
|
def first(self) -> Optional[_T]: ...
|
||||||
|
def last(self) -> Optional[_T]: ...
|
||||||
|
def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ...
|
||||||
|
def delete(self) -> Tuple[int, Dict[str, int]]: ...
|
||||||
|
def update(self, **kwargs: Any) -> int: ...
|
||||||
|
def exists(self) -> bool: ...
|
||||||
|
def explain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ...
|
||||||
|
def raw(
|
||||||
|
self,
|
||||||
|
raw_query: str,
|
||||||
|
params: Any = ...,
|
||||||
|
translations: Optional[Dict[str, str]] = ...,
|
||||||
|
using: Optional[str] = ...,
|
||||||
|
) -> RawQuerySet: ...
|
||||||
|
# The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param
|
||||||
|
def values(self, *fields: Union[str, Combinable], **expressions: Any) -> ValuesQuerySet[_T, Dict[str, Any]]: ...
|
||||||
|
# The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param
|
||||||
|
def values_list(
|
||||||
|
self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ...
|
||||||
|
) -> ValuesQuerySet[_T, Any]: ...
|
||||||
|
def dates(self, field_name: str, kind: str, order: str = ...) -> ValuesQuerySet[_T, datetime.date]: ...
|
||||||
|
def datetimes(
|
||||||
|
self, field_name: str, kind: str, order: str = ..., tzinfo: Optional[datetime.tzinfo] = ...
|
||||||
|
) -> ValuesQuerySet[_T, datetime.datetime]: ...
|
||||||
|
def none(self: _QS) -> _QS: ...
|
||||||
|
def all(self: _QS) -> _QS: ...
|
||||||
|
def filter(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
|
||||||
|
def exclude(self: _QS, *args: Any, **kwargs: Any) -> _QS: ...
|
||||||
|
def complex_filter(self, filter_obj: Any) -> _QS: ...
|
||||||
|
def count(self) -> int: ...
|
||||||
|
def union(self: _QS, *other_qs: Any, all: bool = ...) -> _QS: ...
|
||||||
|
def intersection(self: _QS, *other_qs: Any) -> _QS: ...
|
||||||
|
def difference(self: _QS, *other_qs: Any) -> _QS: ...
|
||||||
|
def select_for_update(self: _QS, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...) -> _QS: ...
|
||||||
|
def select_related(self: _QS, *fields: Any) -> _QS: ...
|
||||||
|
def prefetch_related(self: _QS, *lookups: Any) -> _QS: ...
|
||||||
|
# TODO: return type
|
||||||
|
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[Any]: ...
|
||||||
|
def order_by(self: _QS, *field_names: Any) -> _QS: ...
|
||||||
|
def distinct(self: _QS, *field_names: Any) -> _QS: ...
|
||||||
|
# extra() return type won't be supported any time soon
|
||||||
|
def extra(
|
||||||
|
self,
|
||||||
|
select: Optional[Dict[str, Any]] = ...,
|
||||||
|
where: Optional[List[str]] = ...,
|
||||||
|
params: Optional[List[Any]] = ...,
|
||||||
|
tables: Optional[List[str]] = ...,
|
||||||
|
order_by: Optional[Sequence[str]] = ...,
|
||||||
|
select_params: Optional[Sequence[Any]] = ...,
|
||||||
|
) -> QuerySet[Any]: ...
|
||||||
|
def reverse(self: _QS) -> _QS: ...
|
||||||
|
def defer(self: _QS, *fields: Any) -> _QS: ...
|
||||||
|
def only(self: _QS, *fields: Any) -> _QS: ...
|
||||||
|
def using(self: _QS, alias: Optional[str]) -> _QS: ...
|
||||||
|
@property
|
||||||
|
def ordered(self) -> bool: ...
|
||||||
|
@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):
|
||||||
|
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: ...
|
||||||
|
|
||||||
_Row = TypeVar("_Row", covariant=True)
|
_Row = TypeVar("_Row", covariant=True)
|
||||||
|
|
||||||
class BaseIterable(Sequence[_Row]):
|
class BaseIterable(Sequence[_Row]):
|
||||||
def __init__(self, queryset: QuerySet, chunked_fetch: bool = ..., chunk_size: int = ...): ...
|
def __init__(self, queryset: _BaseQuerySet, chunked_fetch: bool = ..., chunk_size: int = ...): ...
|
||||||
def __iter__(self) -> Iterator[_Row]: ...
|
def __iter__(self) -> Iterator[_Row]: ...
|
||||||
def __contains__(self, x: object) -> bool: ...
|
def __contains__(self, x: object) -> bool: ...
|
||||||
def __len__(self) -> int: ...
|
def __len__(self) -> int: ...
|
||||||
@@ -47,109 +150,19 @@ class NamedValuesListIterable(ValuesListIterable): ...
|
|||||||
class FlatValuesListIterable(BaseIterable):
|
class FlatValuesListIterable(BaseIterable):
|
||||||
def __iter__(self) -> Iterator[Any]: ...
|
def __iter__(self) -> Iterator[Any]: ...
|
||||||
|
|
||||||
_T = TypeVar("_T", bound=models.Model, covariant=True)
|
class ValuesQuerySet(_BaseQuerySet[_T], Collection[_Row], Sized):
|
||||||
|
|
||||||
class QuerySet(Generic[_T, _Row], Collection[_Row], Sized):
|
|
||||||
query: Query
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
model: Optional[Type[models.Model]] = ...,
|
|
||||||
query: Optional[Query] = ...,
|
|
||||||
using: Optional[str] = ...,
|
|
||||||
hints: Optional[Dict[str, models.Model]] = ...,
|
|
||||||
) -> None: ...
|
|
||||||
@classmethod
|
|
||||||
def as_manager(cls) -> Manager[Any]: ...
|
|
||||||
def __len__(self) -> int: ...
|
|
||||||
def __iter__(self) -> Iterator[_Row]: ...
|
|
||||||
def __contains__(self, x: object) -> bool: ...
|
def __contains__(self, x: object) -> bool: ...
|
||||||
@overload
|
def __iter__(self) -> Iterator[_Row]: ... # type: ignore
|
||||||
|
@overload # type: ignore
|
||||||
def __getitem__(self, i: int) -> _Row: ...
|
def __getitem__(self, i: int) -> _Row: ...
|
||||||
@overload
|
@overload
|
||||||
def __getitem__(self, s: slice) -> QuerySet[_T, _Row]: ...
|
def __getitem__(self: _QS, s: slice) -> _QS: ...
|
||||||
def __bool__(self) -> bool: ...
|
def iterator(self, chunk_size: int = ...) -> Iterator[_Row]: ... # type: ignore
|
||||||
def __class_getitem__(cls, item: Type[_T]):
|
def get(self, *args: Any, **kwargs: Any) -> _Row: ... # type: ignore
|
||||||
pass
|
def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ... # type: ignore
|
||||||
def __getstate__(self) -> Dict[str, Any]: ...
|
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ... # type: ignore
|
||||||
# __and__ and __or__ ignore the other QuerySet's _Row type parameter because they use the same row type as the self QuerySet.
|
def first(self) -> Optional[_Row]: ... # type: ignore
|
||||||
# Technically, the other QuerySet must be of the same type _T, but _T is covariant
|
def last(self) -> Optional[_Row]: ... # type: ignore
|
||||||
def __and__(self, other: QuerySet[_T, Any]) -> QuerySet[_T, _Row]: ...
|
|
||||||
def __or__(self, other: QuerySet[_T, Any]) -> QuerySet[_T, _Row]: ...
|
|
||||||
def iterator(self, chunk_size: int = ...) -> Iterator[_Row]: ...
|
|
||||||
def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
|
|
||||||
def get(self, *args: Any, **kwargs: Any) -> _Row: ...
|
|
||||||
def create(self, *args: Any, **kwargs: Any) -> _T: ...
|
|
||||||
def bulk_create(
|
|
||||||
self, objs: Iterable[Model], batch_size: Optional[int] = ..., ignore_conflicts: bool = ...
|
|
||||||
) -> List[_T]: ...
|
|
||||||
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
|
|
||||||
) -> Tuple[_T, bool]: ...
|
|
||||||
def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ...
|
|
||||||
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _Row: ...
|
|
||||||
# technically it's Optional[_Row], but it creates a lot of false-positives (same for last())
|
|
||||||
def first(self) -> _Row: ...
|
|
||||||
def last(self) -> _Row: ...
|
|
||||||
def in_bulk(self, id_list: Iterable[Any] = ..., *, field_name: str = ...) -> Dict[Any, _T]: ...
|
|
||||||
def delete(self) -> Tuple[int, Dict[str, int]]: ...
|
|
||||||
def update(self, **kwargs: Any) -> int: ...
|
|
||||||
def exists(self) -> bool: ...
|
|
||||||
def explain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ...
|
|
||||||
def raw(
|
|
||||||
self,
|
|
||||||
raw_query: str,
|
|
||||||
params: Any = ...,
|
|
||||||
translations: Optional[Dict[str, str]] = ...,
|
|
||||||
using: Optional[str] = ...,
|
|
||||||
) -> RawQuerySet: ...
|
|
||||||
# The type of values may be overridden to be more specific in the mypy plugin, depending on the fields param
|
|
||||||
def values(self, *fields: Union[str, Combinable], **expressions: Any) -> QuerySet[_T, Dict[str, Any]]: ...
|
|
||||||
# The type of values_list may be overridden to be more specific in the mypy plugin, depending on the fields param
|
|
||||||
def values_list(
|
|
||||||
self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ...
|
|
||||||
) -> QuerySet[_T, Any]: ...
|
|
||||||
def dates(self, field_name: str, kind: str, order: str = ...) -> QuerySet[_T, datetime.date]: ...
|
|
||||||
def datetimes(
|
|
||||||
self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...
|
|
||||||
) -> QuerySet[_T, datetime.datetime]: ...
|
|
||||||
def none(self) -> QuerySet[_T, _Row]: ...
|
|
||||||
def all(self) -> QuerySet[_T, _Row]: ...
|
|
||||||
def filter(self, *args: Any, **kwargs: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def exclude(self, *args: Any, **kwargs: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def complex_filter(self, filter_obj: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def count(self) -> int: ...
|
|
||||||
def union(self, *other_qs: Any, all: bool = ...) -> QuerySet[_T, _Row]: ...
|
|
||||||
def intersection(self, *other_qs: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def difference(self, *other_qs: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def select_for_update(self, nowait: bool = ..., skip_locked: bool = ..., of: Tuple = ...) -> QuerySet[_T, _Row]: ...
|
|
||||||
def select_related(self, *fields: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def prefetch_related(self, *lookups: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
# TODO: return type
|
|
||||||
def annotate(self, *args: Any, **kwargs: Any) -> QuerySet[Any, Any]: ...
|
|
||||||
def order_by(self, *field_names: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def distinct(self, *field_names: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
# extra() return type won't be supported any time soon
|
|
||||||
def extra(
|
|
||||||
self,
|
|
||||||
select: Optional[Dict[str, Any]] = ...,
|
|
||||||
where: Optional[List[str]] = ...,
|
|
||||||
params: Optional[List[Any]] = ...,
|
|
||||||
tables: Optional[List[str]] = ...,
|
|
||||||
order_by: Optional[Sequence[str]] = ...,
|
|
||||||
select_params: Optional[Sequence[Any]] = ...,
|
|
||||||
) -> QuerySet[Any, Any]: ...
|
|
||||||
def reverse(self) -> QuerySet[_T, _Row]: ...
|
|
||||||
def defer(self, *fields: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def only(self, *fields: Any) -> QuerySet[_T, _Row]: ...
|
|
||||||
def using(self, alias: Optional[str]) -> QuerySet[_T, _Row]: ...
|
|
||||||
@property
|
|
||||||
def ordered(self) -> bool: ...
|
|
||||||
@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 RawQuerySet(Iterable[_T], Sized):
|
class RawQuerySet(Iterable[_T], Sized):
|
||||||
query: RawQuery
|
query: RawQuery
|
||||||
@@ -184,7 +197,7 @@ class RawQuerySet(Iterable[_T], Sized):
|
|||||||
def using(self, alias: Optional[str]) -> RawQuerySet[_T]: ...
|
def using(self, alias: Optional[str]) -> RawQuerySet[_T]: ...
|
||||||
|
|
||||||
class Prefetch(object):
|
class Prefetch(object):
|
||||||
def __init__(self, lookup: str, queryset: Optional[QuerySet] = None, to_attr: Optional[str] = None) -> None: ...
|
def __init__(self, lookup: str, queryset: Optional[QuerySet] = ..., to_attr: Optional[str] = ...) -> None: ...
|
||||||
def __getstate__(self) -> Dict[str, Any]: ...
|
def __getstate__(self) -> Dict[str, Any]: ...
|
||||||
def add_prefix(self, prefix: str) -> None: ...
|
def add_prefix(self, prefix: str) -> None: ...
|
||||||
def get_current_prefetch_to(self, level: int) -> str: ...
|
def get_current_prefetch_to(self, level: int) -> str: ...
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user