mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-11 06:21:58 +08:00
Compare commits
112 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3881df188c | ||
|
|
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 | ||
|
|
b4cd9757b0 | ||
|
|
1b6c337aef | ||
|
|
bc42cc2fa1 | ||
|
|
62dac1d468 | ||
|
|
409c01eb24 | ||
|
|
a0a2ecaf46 | ||
|
|
4c21855641 | ||
|
|
6466c57c69 | ||
|
|
0bb41bc791 | ||
|
|
8894de0a04 | ||
|
|
a019fe9715 | ||
|
|
a97d76020c | ||
|
|
ae8e42dd53 | ||
|
|
64049b60b0 | ||
|
|
b6a5ccabdf | ||
|
|
e6d7a570e8 | ||
|
|
6332620443 | ||
|
|
df021f6baa | ||
|
|
57796077c6 | ||
|
|
46c48b504f | ||
|
|
4dfa363521 | ||
|
|
5b2aacddba | ||
|
|
2c001fd8a7 | ||
|
|
a0db24c764 | ||
|
|
39fb48b08a | ||
|
|
d7d379e1cd | ||
|
|
6962b42cba | ||
|
|
df77299c2f | ||
|
|
b86d33c718 | ||
|
|
fa57fb0cbf | ||
|
|
248504c25a | ||
|
|
fee4aad3d0 | ||
|
|
fc9843bea6 | ||
|
|
5bb1bc250d | ||
|
|
1721c997be | ||
|
|
bba6f769b5 | ||
|
|
07a9bcd4cb | ||
|
|
6ece759ca0 | ||
|
|
caf69ec1c9 | ||
|
|
f2e79d3bfb | ||
|
|
bfa77efef5 | ||
|
|
4f935edd47 | ||
|
|
03b59b872d | ||
|
|
0e72b2e6fc | ||
|
|
b81fbdeaa9 | ||
|
|
dc6101b569 | ||
|
|
d53121baae | ||
|
|
3c3122a93f | ||
|
|
7b1b1b6bfe | ||
|
|
2cb1f257eb | ||
|
|
b11a9a85f9 | ||
|
|
9c5a6be9a7 | ||
|
|
a9c1bcbbc6 | ||
|
|
f365297baf | ||
|
|
6859ec94b6 | ||
|
|
335c5765c3 | ||
|
|
b397ec04a9 | ||
|
|
f7db296e8b | ||
|
|
2f6af159f7 | ||
|
|
2799646723 | ||
|
|
d8230a4147 | ||
|
|
861c6653fd | ||
|
|
db7b46589f | ||
|
|
90cab6c5bf | ||
|
|
25165de80f | ||
|
|
2295b14214 | ||
|
|
a77d5b27d8 | ||
|
|
4e1c32f6a3 | ||
|
|
ea1294bd30 | ||
|
|
79d691732d | ||
|
|
629ba954b4 | ||
|
|
0e60b70ae4 | ||
|
|
dd5b98faf0 | ||
|
|
e634a5d460 | ||
|
|
d7d7e6c66e | ||
|
|
b66727657d | ||
|
|
86642e3ddd | ||
|
|
952e1c3ee9 | ||
|
|
5dd6eccdb5 | ||
|
|
fd06816cbb | ||
|
|
aeb435c8b3 | ||
|
|
13d19017b7 | ||
|
|
28a3f126ee |
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!
|
||||
-->
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -5,6 +5,7 @@ out/
|
||||
/django
|
||||
.idea/
|
||||
.mypy_cache/
|
||||
django-sources
|
||||
build/
|
||||
dist/
|
||||
dist/
|
||||
pip-wheel-metadata/
|
||||
.pytest_cache/
|
||||
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
[submodule "django-sources"]
|
||||
path = django-sources
|
||||
url = https://github.com/django/django.git
|
||||
branch = stable/2.2.x
|
||||
27
.travis.yml
27
.travis.yml
@@ -10,16 +10,18 @@ jobs:
|
||||
set -e
|
||||
pytest
|
||||
|
||||
- name: Run plugin test suite with python 3.6
|
||||
python: 3.6
|
||||
script: |
|
||||
set -e
|
||||
pytest
|
||||
|
||||
- name: Typecheck Django test suite
|
||||
- name: Typecheck Django test suite with python 3.7
|
||||
python: 3.7
|
||||
script: 'python ./scripts/typecheck_tests.py'
|
||||
|
||||
- name: Typecheck Django test suite with python 3.6
|
||||
python: 3.6
|
||||
script: 'python ./scripts/typecheck_tests.py'
|
||||
|
||||
- name: Mypy for plugin code
|
||||
python: 3.7
|
||||
script: 'mypy ./mypy_django_plugin'
|
||||
|
||||
- name: Lint with black
|
||||
python: 3.7
|
||||
script: 'black --check --line-length=120 django-stubs/'
|
||||
@@ -36,13 +38,4 @@ before_install: |
|
||||
# Upgrade pip, setuptools, and wheel
|
||||
pip install -U pip setuptools wheel
|
||||
install: |
|
||||
pip install -r ./dev-requirements.txt
|
||||
pip install -r ./scripts/typecheck-tests-requirements.txt
|
||||
|
||||
#deploy:
|
||||
# provider: pypi
|
||||
# user: "mkurnikov"
|
||||
# password:
|
||||
# secure: 0E+hkaIdtpEtyL1KZeglunZ5/PKjouFfa8ljakAwoig7VNUL+2sO/bTyg38wRQl0NvzDzEHSMEt1bzg4Tq7b7Zp6nLuewG/w7mGLzqaOlTySiPEfRsg8s6uO2KrTn7g9VhlXH6UtyTXoQdMt6aE8+bt/GmEesanS57NB2mhwmylFgQwlJFu4LfIv/+aGmc4eLeGI2Qhvs9QYf7qvYlLQldgFh8mAckQEEvaBg35sf+puypZgf4nkx1k/dfG9wnFWZU8PJ41LbMw/Wj+k/9NpF8ePwiAr0fvRMErZd8nvoiWjQQjhzgrLVHhXEP5pTHh3zjDuGFMWyKuBhC6WLsG4qOQz/HvxeYvNI+jaTp15BgxtefG/pCNDUl/8GlCde7xVt7xzEcYNJSRaZPY2oofEFSd9qDnr4kqmyCXpNsaHRHvkL61bFjXUcfOsMMYvQCC6N2Jjb7S97RbnDdkOZO/lnFhVANT2rigsaXlSlWyN6f7ApxDNvu6Ehu5yrx6IjlPZJ0sI9vvY3IoS6Fik7w9E6zjNVjbmUn1D4MKFP4v5ppNASOqYcZeLd42j8rjEp0gIc3ccz9aUIT9q8VqSXSdUbqA6SVwvHXIVPxJMXj0bqWBG1iKs0cPBuzRVpRrwkENWCSWElDAewM1qFEnK0LppyoYFbqoQ8F5FG0+re7QttKQ=
|
||||
# on:
|
||||
# tags: true
|
||||
pip install -r ./dev-requirements.txt
|
||||
54
README.md
54
README.md
@@ -2,12 +2,12 @@
|
||||
|
||||
# pep484 stubs for Django framework
|
||||
|
||||
[](https://travis-ci.org/mkurnikov/django-stubs)
|
||||
[](https://travis-ci.org/typeddjango/django-stubs)
|
||||
[](http://mypy-lang.org/)
|
||||
|
||||
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns.
|
||||
|
||||
Supports Python 3.6/3.7, and Django 2.1.x series.
|
||||
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.
|
||||
|
||||
@@ -17,6 +17,10 @@ Could be run on earlier versions of Django, but expect some missing imports warn
|
||||
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.
|
||||
|
||||
To make mypy aware of the plugin, you need to add
|
||||
|
||||
```
|
||||
@@ -27,27 +31,41 @@ plugins =
|
||||
|
||||
in your `mypy.ini` file.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file. Default is `./mypy_django.ini`
|
||||
|
||||
Config file format (.ini):
|
||||
Plugin requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified inside `mypy.ini` file.
|
||||
```
|
||||
[mypy_django_plugin]
|
||||
[mypy]
|
||||
strict_optional = True
|
||||
|
||||
# specify settings module to use for django.conf.settings, this setting
|
||||
# could also be specified with DJANGO_SETTINGS_MODULE environment variable
|
||||
# (it also takes priority over config file)
|
||||
django_settings = mysettings.local
|
||||
|
||||
# if True, all unknown settings in django.conf.settings will fallback to Any,
|
||||
# specify it if your settings are loaded dynamically to avoid false positives
|
||||
ignore_missing_settings = True
|
||||
; this one is new
|
||||
[mypy.plugins.django-stubs]
|
||||
django_settings_module = mysettings
|
||||
```
|
||||
where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes)
|
||||
|
||||
Do you have trouble with mypy / the django plugin not finding your settings module? Try adding the root path of your project to your PYTHONPATH environment variable. If you use pipenv you can add the following to an `.env` file in your project root which pipenv will run automatically before executing any commands.:
|
||||
```
|
||||
PYTHONPATH=${PYTHONPATH}:${PWD}
|
||||
```
|
||||
|
||||
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()`.
|
||||
|
||||
In other words, if your `manage.py runserver` crashes, mypy will crash too.
|
||||
|
||||
## 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
|
||||
```
|
||||
class MyUserManager(models.Manager['MyUser']):
|
||||
pass
|
||||
class MyUser(models.Model):
|
||||
objects = UserManager()
|
||||
```
|
||||
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`.
|
||||
|
||||
## To get help
|
||||
|
||||
We have Gitter here https://gitter.im/mypy-django/Lobby.
|
||||
|
||||
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.
|
||||
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
black
|
||||
pytest-mypy-plugins
|
||||
pytest-mypy-plugins==1.0.3
|
||||
psycopg2
|
||||
flake8
|
||||
isort==4.3.4
|
||||
-e .
|
||||
|
||||
1
django-sources
Submodule
1
django-sources
Submodule
Submodule django-sources added at 4d6449e125
@@ -1,5 +1,6 @@
|
||||
import collections
|
||||
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict
|
||||
import threading
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict, Dict
|
||||
|
||||
from django.db.migrations.state import AppConfigStub
|
||||
from django.db.models.base import Model
|
||||
@@ -7,22 +8,24 @@ from django.db.models.base import Model
|
||||
from .config import AppConfig
|
||||
|
||||
class Apps:
|
||||
all_models: collections.defaultdict = ...
|
||||
app_configs: collections.OrderedDict = ...
|
||||
all_models: "Dict[str, OrderedDict[str, Type[Model]]]" = ...
|
||||
app_configs: "OrderedDict[str, AppConfig]" = ...
|
||||
stored_app_configs: List[Any] = ...
|
||||
apps_ready: bool = ...
|
||||
ready_event: threading.Event = ...
|
||||
loading: bool = ...
|
||||
_pending_operations: DefaultDict[Tuple[str, str], List]
|
||||
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
|
||||
models_ready: bool = ...
|
||||
ready: bool = ...
|
||||
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
|
||||
def populate(self, installed_apps: Union[List[AppConfigStub], List[str], Tuple] = ...) -> None: ...
|
||||
def check_apps_ready(self) -> None: ...
|
||||
def check_models_ready(self) -> None: ...
|
||||
def get_app_configs(self) -> Iterable[AppConfig]: ...
|
||||
def get_app_config(self, app_label: str) -> AppConfig: ...
|
||||
# it's not possible to support it in plugin properly now
|
||||
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[Model]: ...
|
||||
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 is_installed(self, app_name: str) -> bool: ...
|
||||
def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ...
|
||||
|
||||
@@ -2,10 +2,16 @@ from typing import Any
|
||||
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
# explicit dependency on standard settings to make it loaded
|
||||
from . import global_settings
|
||||
|
||||
ENVIRONMENT_VARIABLE: str = ...
|
||||
DEFAULT_CONTENT_TYPE_DEPRECATED_MSG: str = ...
|
||||
FILE_CHARSET_DEPRECATED_MSG: str = ...
|
||||
|
||||
# required for plugin to be able to distinguish this specific instance of LazySettings from others
|
||||
class _DjangoConfLazyObject(LazyObject): ...
|
||||
class _DjangoConfLazyObject(LazyObject):
|
||||
def __getattr__(self, item: Any) -> Any: ...
|
||||
|
||||
class LazySettings(_DjangoConfLazyObject):
|
||||
configured: bool
|
||||
@@ -18,3 +24,6 @@ class Settings:
|
||||
def is_overridden(self, setting: str) -> bool: ...
|
||||
|
||||
class UserSettingsHolder: ...
|
||||
|
||||
class SettingsReference(str):
|
||||
def __init__(self, value: str, setting_name: str) -> None: ...
|
||||
|
||||
@@ -5,14 +5,11 @@ by the DJANGO_SETTINGS_MODULE environment variable.
|
||||
|
||||
# This is defined here as a do-nothing function because we can't import
|
||||
# django.utils.translation -- that module depends on the settings.
|
||||
from typing import Any, Dict, List, Optional, Pattern, Tuple, Protocol, Union, Callable, TYPE_CHECKING, Sequence
|
||||
from typing import Any, Dict, List, Optional, Pattern, Protocol, Sequence, Tuple, Union
|
||||
|
||||
####################
|
||||
# CORE #
|
||||
####################
|
||||
if TYPE_CHECKING:
|
||||
from django.db.models.base import Model
|
||||
|
||||
DEBUG: bool = ...
|
||||
|
||||
# Whether the framework should propagate raw exceptions rather than catching
|
||||
@@ -153,7 +150,7 @@ FORCE_SCRIPT_NAME = None
|
||||
# ]
|
||||
DISALLOWED_USER_AGENTS: List[Pattern] = ...
|
||||
|
||||
ABSOLUTE_URL_OVERRIDES: Dict[str, Callable[[Model], str]] = ...
|
||||
ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ...
|
||||
|
||||
# List of compiled regular expression objects representing URLs that need not
|
||||
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples:
|
||||
|
||||
3
django-stubs/conf/locale/__init__.pyi
Normal file
3
django-stubs/conf/locale/__init__.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Dict, Any
|
||||
|
||||
LANG_INFO: Dict[str, Any] = ...
|
||||
23
django-stubs/contrib/admin/tests.pyi
Normal file
23
django-stubs/contrib/admin/tests.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
from typing import Any, Callable
|
||||
|
||||
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
|
||||
from django.test.selenium import SeleniumTestCase
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
class CSPMiddleware(MiddlewareMixin): ...
|
||||
|
||||
class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
|
||||
def wait_until(self, callback: Callable, timeout: int = ...) -> None: ...
|
||||
def wait_for_popup(self, num_windows: int = ..., timeout: int = ...) -> None: ...
|
||||
def wait_for(self, css_selector: str, timeout: int = ...) -> None: ...
|
||||
def wait_for_text(self, css_selector: str, text: str, timeout: int = ...) -> None: ...
|
||||
def wait_for_value(self, css_selector: str, text: str, timeout: int = ...) -> None: ...
|
||||
def wait_until_visible(self, css_selector: str, timeout: int = ...) -> None: ...
|
||||
def wait_until_invisible(self, css_selector: str, timeout: int = ...) -> None: ...
|
||||
def wait_page_loaded(self) -> None: ...
|
||||
def admin_login(self, username: str, password: str, login_url: str = ...) -> None: ...
|
||||
def get_css_value(self, selector: str, attribute: str) -> Any: ...
|
||||
def get_select_option(self, selector: str, value: Any) -> Any: ...
|
||||
def assertSelectOptions(self, selector: str, values: Any) -> None: ...
|
||||
def assertSelectedOptions(self, selector: str, values: Any) -> None: ...
|
||||
def has_css_class(self, selector: str, klass: str) -> bool: ...
|
||||
@@ -2,7 +2,7 @@ from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.contrib.admin.filters import ListFilter, SimpleListFilter
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.contrib.admin.options import ModelAdmin, IS_POPUP_VAR as IS_POPUP_VAR, TO_FIELD_VAR as TO_FIELD_VAR
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
||||
from typing import Any, Dict, Optional, Tuple, Union
|
||||
from uuid import UUID
|
||||
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel
|
||||
from django.forms.models import ModelChoiceIterator
|
||||
from django.forms.widgets import ChoiceWidget, Media
|
||||
from django.forms.widgets import Media
|
||||
|
||||
from django import forms
|
||||
|
||||
@@ -43,7 +43,7 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ...
|
||||
class RelatedFieldWidgetWrapper(forms.Widget):
|
||||
template_name: str = ...
|
||||
choices: ModelChoiceIterator = ...
|
||||
widget: AutocompleteSelect = ...
|
||||
widget: forms.Widget = ...
|
||||
rel: ManyToOneRel = ...
|
||||
can_add_related: bool = ...
|
||||
can_change_related: bool = ...
|
||||
@@ -52,7 +52,7 @@ class RelatedFieldWidgetWrapper(forms.Widget):
|
||||
admin_site: AdminSite = ...
|
||||
def __init__(
|
||||
self,
|
||||
widget: ChoiceWidget,
|
||||
widget: forms.Widget,
|
||||
rel: ForeignObjectRel,
|
||||
admin_site: AdminSite,
|
||||
can_add_related: Optional[bool] = ...,
|
||||
@@ -74,6 +74,9 @@ class AdminIntegerFieldWidget(forms.NumberInput):
|
||||
|
||||
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
|
||||
|
||||
class AdminUUIDInputWidget(forms.TextInput):
|
||||
def __init__(self, attrs: Optional[Dict[str, str]] = ...) -> None: ...
|
||||
|
||||
SELECT2_TRANSLATIONS: Any
|
||||
|
||||
class AutocompleteMixin:
|
||||
|
||||
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] = ...
|
||||
@@ -1,16 +1,20 @@
|
||||
from typing import Any, Optional, Tuple, List, overload
|
||||
from typing import Any, Optional, Tuple, List, overload, TypeVar
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
from django.db import models
|
||||
|
||||
class BaseUserManager(models.Manager):
|
||||
_T = TypeVar("_T", bound=Model)
|
||||
|
||||
class BaseUserManager(models.Manager[_T]):
|
||||
@classmethod
|
||||
def normalize_email(cls, email: Optional[str]) -> str: ...
|
||||
def make_random_password(self, length: int = ..., allowed_chars: str = ...) -> str: ...
|
||||
def get_by_natural_key(self, username: Optional[str]) -> AbstractBaseUser: ...
|
||||
def get_by_natural_key(self, username: Optional[str]) -> _T: ...
|
||||
|
||||
class AbstractBaseUser(models.Model):
|
||||
password: models.CharField = ...
|
||||
last_login: Optional[models.DateTimeField] = ...
|
||||
last_login: models.DateTimeField = ...
|
||||
is_active: models.BooleanField = ...
|
||||
REQUIRED_FIELDS: List[str] = ...
|
||||
class Meta: ...
|
||||
|
||||
@@ -23,7 +23,7 @@ class BasePasswordHasher:
|
||||
memory_cost: int = ...
|
||||
parallelism: int = ...
|
||||
digest: Any = ...
|
||||
iterations: Optional[int] = ...
|
||||
iterations: int = ...
|
||||
def salt(self) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def encode(self, password: str, salt: str) -> Any: ...
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import getpass as getpass
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class NotRunningInTTYException(Exception): ...
|
||||
class Command(BaseCommand): ...
|
||||
|
||||
class Command(BaseCommand):
|
||||
stdin: Any
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from typing import Any, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
|
||||
from django.contrib.auth.validators import UnicodeUsernameValidator
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.manager import EmptyManager
|
||||
|
||||
from django.contrib.auth.validators import UnicodeUsernameValidator
|
||||
from django.db import models
|
||||
|
||||
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
|
||||
@@ -27,13 +28,15 @@ class Group(models.Model):
|
||||
permissions: models.ManyToManyField = models.ManyToManyField(Permission)
|
||||
def natural_key(self): ...
|
||||
|
||||
class UserManager(BaseUserManager):
|
||||
_T = TypeVar("_T", bound=Model)
|
||||
|
||||
class UserManager(BaseUserManager[_T]):
|
||||
def create_user(
|
||||
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
|
||||
) -> AbstractUser: ...
|
||||
) -> _T: ...
|
||||
def create_superuser(
|
||||
self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any
|
||||
) -> AbstractBaseUser: ...
|
||||
) -> _T: ...
|
||||
|
||||
class PermissionsMixin(models.Model):
|
||||
is_superuser: models.BooleanField = ...
|
||||
@@ -41,8 +44,8 @@ class PermissionsMixin(models.Model):
|
||||
user_permissions: models.ManyToManyField = models.ManyToManyField(Permission)
|
||||
def get_group_permissions(self, obj: None = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, obj: Optional[str] = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: Union[Tuple[str, Any], str], obj: Optional[str] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Union[List[str], Set[str], Tuple[str]], obj: None = ...) -> bool: ...
|
||||
def has_perm(self, perm: str, obj: Optional[str] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: None = ...) -> bool: ...
|
||||
def has_module_perms(self, app_label: str) -> bool: ...
|
||||
|
||||
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
|
||||
@@ -80,7 +83,7 @@ class AnonymousUser:
|
||||
def get_group_permissions(self, obj: None = ...) -> Set[Any]: ...
|
||||
def get_all_permissions(self, obj: Any = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: str, obj: None = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: None = ...) -> bool: ...
|
||||
def has_module_perms(self, module: str) -> bool: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
|
||||
@@ -2,21 +2,20 @@ from pathlib import Path, PosixPath
|
||||
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.db.models.base import Model
|
||||
|
||||
_UserModel = Model
|
||||
|
||||
class PasswordValidator(Protocol):
|
||||
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...): ...
|
||||
def password_changed(self, password: str, user: Optional[_UserModel] = ...): ...
|
||||
|
||||
def get_default_password_validators() -> List[PasswordValidator]: ...
|
||||
def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ...
|
||||
def validate_password(
|
||||
password: str,
|
||||
user: Optional[AbstractBaseUser] = ...,
|
||||
password_validators: Optional[Sequence[PasswordValidator]] = ...,
|
||||
password: str, user: Optional[_UserModel] = ..., password_validators: Optional[Sequence[PasswordValidator]] = ...
|
||||
) -> None: ...
|
||||
def password_changed(
|
||||
password: str,
|
||||
user: Optional[AbstractBaseUser] = ...,
|
||||
password_validators: Optional[Sequence[PasswordValidator]] = ...,
|
||||
password: str, user: Optional[_UserModel] = ..., password_validators: Optional[Sequence[PasswordValidator]] = ...
|
||||
) -> None: ...
|
||||
def password_validators_help_texts(password_validators: Optional[Sequence[PasswordValidator]] = ...) -> List[str]: ...
|
||||
|
||||
@@ -25,7 +24,7 @@ password_validators_help_text_html: Any
|
||||
class MinimumLengthValidator:
|
||||
min_length: int = ...
|
||||
def __init__(self, min_length: int = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
|
||||
class UserAttributeSimilarityValidator:
|
||||
@@ -33,16 +32,16 @@ class UserAttributeSimilarityValidator:
|
||||
user_attributes: Sequence[str] = ...
|
||||
max_similarity: float = ...
|
||||
def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
|
||||
class CommonPasswordValidator:
|
||||
DEFAULT_PASSWORD_LIST_PATH: Path = ...
|
||||
passwords: Set[str] = ...
|
||||
def __init__(self, password_list_path: Union[PosixPath, str] = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
|
||||
class NumericPasswordValidator:
|
||||
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
|
||||
def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
|
||||
def get_help_text(self) -> str: ...
|
||||
|
||||
3
django-stubs/contrib/auth/urls.pyi
Normal file
3
django-stubs/contrib/auth/urls.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Any, List
|
||||
|
||||
urlpatterns: List[Any] = ...
|
||||
@@ -7,6 +7,7 @@ from django.db.models.fields.related import ForeignObject
|
||||
from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor
|
||||
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
|
||||
@@ -14,6 +15,10 @@ from django.db.models.query_utils import FilteredRelation, PathInfo
|
||||
from django.db.models.sql.where import WhereNode
|
||||
|
||||
class GenericForeignKey(FieldCacheMixin):
|
||||
# django-stubs implementation only fields
|
||||
_pyi_private_set_type: Union[Any, Combinable]
|
||||
_pyi_private_get_type: Any
|
||||
# attributes
|
||||
auto_created: bool = ...
|
||||
concrete: bool = ...
|
||||
editable: bool = ...
|
||||
@@ -44,36 +49,21 @@ class GenericForeignKey(FieldCacheMixin):
|
||||
def get_prefetch_queryset(
|
||||
self, instances: Union[List[Model], QuerySet], queryset: Optional[QuerySet] = ...
|
||||
) -> Tuple[List[Model], Callable, Callable, bool, str, bool]: ...
|
||||
def __get__(
|
||||
self, instance: Optional[Model], cls: Type[Model] = ...
|
||||
) -> Optional[Union[GenericForeignKey, Model]]: ...
|
||||
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Optional[Any]: ...
|
||||
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
||||
|
||||
class GenericRel(ForeignObjectRel):
|
||||
field: GenericRelation
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]]
|
||||
model: Type[Model]
|
||||
multiple: bool
|
||||
on_delete: Callable
|
||||
parent_link: bool
|
||||
related_name: str
|
||||
related_query_name: None
|
||||
symmetrical: bool
|
||||
def __init__(
|
||||
self,
|
||||
field: GenericRelation,
|
||||
to: Union[Type[Model], str],
|
||||
related_name: None = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class GenericRelation(ForeignObject):
|
||||
auto_created: bool = ...
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
rel_class: Any = ...
|
||||
mti_inherited: bool = ...
|
||||
object_id_field_name: Any = ...
|
||||
@@ -90,23 +80,16 @@ class GenericRelation(ForeignObject):
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ...
|
||||
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
|
||||
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
||||
def value_to_string(self, obj: Model) -> str: ...
|
||||
model: Any = ...
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def get_internal_type(self) -> str: ...
|
||||
def get_content_type(self) -> ContentType: ...
|
||||
def get_extra_restriction(
|
||||
self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str
|
||||
) -> WhereNode: ...
|
||||
def bulk_related_objects(self, objs: List[Model], using: str = ...) -> QuerySet: ...
|
||||
|
||||
class ReverseGenericManyToOneDescriptor(ReverseManyToOneDescriptor):
|
||||
field: GenericRelation
|
||||
rel: GenericRel
|
||||
def related_manager_cls(self): ...
|
||||
class ReverseGenericManyToOneDescriptor(ReverseManyToOneDescriptor): ...
|
||||
|
||||
def create_generic_related_manager(superclass: Any, rel: Any): ...
|
||||
|
||||
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,13 +1,12 @@
|
||||
from typing import Any, List, Optional, Union
|
||||
|
||||
from django.contrib.messages.storage.base import BaseStorage
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.request import HttpRequest
|
||||
|
||||
class MessageFailure(Exception): ...
|
||||
|
||||
def add_message(
|
||||
request: Optional[WSGIRequest],
|
||||
request: Optional[HttpRequest],
|
||||
level: int,
|
||||
message: str,
|
||||
extra_tags: str = ...,
|
||||
@@ -16,12 +15,12 @@ def add_message(
|
||||
def get_messages(request: HttpRequest) -> Union[List[Any], BaseStorage]: ...
|
||||
def get_level(request: HttpRequest) -> int: ...
|
||||
def set_level(request: HttpRequest, level: int) -> bool: ...
|
||||
def debug(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
|
||||
def info(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
|
||||
def debug(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
|
||||
def info(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
|
||||
def success(
|
||||
request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
|
||||
request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
|
||||
) -> None: ...
|
||||
def warning(
|
||||
request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
|
||||
request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
|
||||
) -> None: ...
|
||||
def error(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
|
||||
def error(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from django.forms.forms import Form
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.forms.forms import BaseForm
|
||||
from django.http.response import HttpResponse
|
||||
|
||||
class SuccessMessageMixin:
|
||||
success_message: str = ...
|
||||
def form_valid(self, form: Form) -> HttpResponseRedirect: ...
|
||||
def form_valid(self, form: BaseForm) -> HttpResponse: ...
|
||||
def get_success_message(self, cleaned_data: Dict[str, str]) -> str: ...
|
||||
|
||||
@@ -4,8 +4,15 @@ from .ranges import (
|
||||
RangeField as RangeField,
|
||||
IntegerRangeField as IntegerRangeField,
|
||||
BigIntegerRangeField as BigIntegerRangeField,
|
||||
DecimalRangeField as DecimalRangeField,
|
||||
FloatRangeField as FloatRangeField,
|
||||
DateRangeField as DateRangeField,
|
||||
DateTimeRangeField as DateTimeRangeField,
|
||||
)
|
||||
from .hstore import HStoreField as HStoreField
|
||||
from .citext import (
|
||||
CICharField as CICharField,
|
||||
CIEmailField as CIEmailField,
|
||||
CIText as CIText,
|
||||
CITextField as CITextField,
|
||||
)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from json import JSONEncoder
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Optional, Type
|
||||
|
||||
from django.db.models import Field
|
||||
from django.db.models.lookups import Transform
|
||||
from .mixins import CheckFieldDefaultMixin
|
||||
|
||||
class JsonAdapter(object):
|
||||
class JsonAdapter:
|
||||
encoder: Any = ...
|
||||
def __init__(self, adapted: Any, dumps: Optional[Any] = ..., encoder: Optional[Any] = ...) -> None: ...
|
||||
def dumps(self, obj: Any): ...
|
||||
@@ -15,12 +16,17 @@ class JSONField(CheckFieldDefaultMixin, Field):
|
||||
default_error_messages: Any = ...
|
||||
encoder: Any = ...
|
||||
def __init__(
|
||||
self, verbose_name: None = ..., name: None = ..., encoder: Optional[Type[JSONEncoder]] = ..., **kwargs: Any
|
||||
self,
|
||||
verbose_name: Optional[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
encoder: Optional[Type[JSONEncoder]] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def db_type(self, connection: Any): ...
|
||||
def deconstruct(self) -> Tuple[None, str, List[Any], Dict[str, Union[Type[JSONEncoder], bool]]]: ...
|
||||
def get_transform(self, name: Any): ...
|
||||
def get_prep_value(self, value: Any): ...
|
||||
def validate(self, value: Any, model_instance: Any) -> None: ...
|
||||
def value_to_string(self, obj: Any): ...
|
||||
def formfield(self, **kwargs: Any): ...
|
||||
|
||||
class KeyTransform(Transform):
|
||||
operator: str = ...
|
||||
nested_operator: str = ...
|
||||
def __init__(self, key_name: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class KeyTextTransform(KeyTransform): ...
|
||||
|
||||
@@ -18,6 +18,9 @@ class IntegerRangeField(RangeField):
|
||||
class BigIntegerRangeField(RangeField):
|
||||
def __get__(self, instance, owner) -> NumericRange: ...
|
||||
|
||||
class DecimalRangeField(RangeField):
|
||||
def __get__(self, instance, owner) -> NumericRange: ...
|
||||
|
||||
class FloatRangeField(RangeField):
|
||||
def __get__(self, instance, owner) -> NumericRange: ...
|
||||
|
||||
|
||||
4
django-stubs/contrib/postgres/functions.pyi
Normal file
4
django-stubs/contrib/postgres/functions.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.db.models import Func
|
||||
|
||||
class RandomUUID(Func): ...
|
||||
class TransactionNow(Func): ...
|
||||
29
django-stubs/contrib/postgres/indexes.pyi
Normal file
29
django-stubs/contrib/postgres/indexes.pyi
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.db.models import Index
|
||||
|
||||
class PostgresIndex(Index):
|
||||
@property
|
||||
def max_name_length(self) -> int: ...
|
||||
|
||||
class BrinIndex(PostgresIndex):
|
||||
def __init__(
|
||||
self, *, autosummarize: Optional[bool] = ..., pages_per_range: Optional[int] = ..., **kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
class BTreeIndex(PostgresIndex):
|
||||
def __init__(self, *, fillfactor: Optional[int] = ..., **kwargs: Any): ...
|
||||
|
||||
class GinIndex(PostgresIndex):
|
||||
def __init__(
|
||||
self, *, fastupdate: Optional[bool] = ..., gin_pending_list_limit: Optional[int] = ..., **kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
class GistIndex(PostgresIndex):
|
||||
def __init__(self, *, buffering: Optional[bool] = ..., fillfactor: Optional[int] = ..., **kwargs: Any) -> None: ...
|
||||
|
||||
class HashIndex(PostgresIndex):
|
||||
def __init__(self, *, fillfactor: Optional[int] = ..., **kwargs: Any) -> None: ...
|
||||
|
||||
class SpGistIndex(PostgresIndex):
|
||||
def __init__(self, *, fillfactor: Optional[int] = ..., **kwargs: Any) -> None: ...
|
||||
47
django-stubs/contrib/postgres/search.pyi
Normal file
47
django-stubs/contrib/postgres/search.pyi
Normal file
@@ -0,0 +1,47 @@
|
||||
from typing import Any, Dict, Optional, TypeVar, Union
|
||||
|
||||
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value
|
||||
from django.db.models.lookups import Lookup
|
||||
|
||||
from django.db.models import Field
|
||||
|
||||
class SearchVectorExact(Lookup): ...
|
||||
class SearchVectorField(Field): ...
|
||||
class SearchQueryField(Field): ...
|
||||
|
||||
class SearchVectorCombinable:
|
||||
ADD: str = ...
|
||||
|
||||
class SearchVector(SearchVectorCombinable, Func):
|
||||
config: Optional[Any] = ...
|
||||
def __init__(self, *expressions: Union[str, Combinable], **extra: Any): ...
|
||||
|
||||
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
|
||||
def __init__(self, lhs, connector, rhs, config, output_field: Optional[Field, str] = ...): ...
|
||||
|
||||
_T = TypeVar("_T", bound="SearchQueryCombinable")
|
||||
|
||||
class SearchQueryCombinable:
|
||||
BITAND: str = ...
|
||||
BITOR: str = ...
|
||||
def __or__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
||||
def __ror__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
||||
def __and__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
||||
def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ...
|
||||
|
||||
class SearchQuery(SearchQueryCombinable, Value):
|
||||
SEARCH_TYPES: Dict[str, str] = {"plain": "plainto_tsquery", "phrase": "phraseto_tsquery", "raw": "to_tsquery"}
|
||||
def __init__(self, value, output_field=..., *, config=..., invert=False, search_type="plain"): ...
|
||||
def __invert__(self: _T) -> _T: ...
|
||||
|
||||
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression):
|
||||
def __init__(self, lhs, connector, rhs, config, output_field=...) -> None: ...
|
||||
|
||||
class SearchRank(Func):
|
||||
def __init__(self, vector, query, **extra: Any) -> None: ...
|
||||
|
||||
class TrigramBase(Func):
|
||||
def __init__(self, expression, string, **extra: Any) -> None: ...
|
||||
|
||||
class TrigramSimilarity(TrigramBase): ...
|
||||
class TrigramDistance(TrigramBase): ...
|
||||
5
django-stubs/contrib/postgres/signals.pyi
Normal file
5
django-stubs/contrib/postgres/signals.pyi
Normal file
@@ -0,0 +1,5 @@
|
||||
from typing import Any, Tuple
|
||||
|
||||
def get_hstore_oids(connection_alias: str) -> Tuple[Any, ...]: ...
|
||||
def get_citext_oids(connection_alias: str) -> Tuple[Any, ...]: ...
|
||||
def register_type_handlers(connection: Any, **kwargs: Any) -> None: ...
|
||||
17
django-stubs/contrib/postgres/validators.pyi
Normal file
17
django-stubs/contrib/postgres/validators.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Any, Dict, Iterable, Mapping, Optional
|
||||
|
||||
from django.core.validators import MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator
|
||||
|
||||
class ArrayMaxLengthValidator(MaxLengthValidator): ...
|
||||
class ArrayMinLengthValidator(MinLengthValidator): ...
|
||||
|
||||
class KeysValidator:
|
||||
messages: Dict[str, str] = ...
|
||||
strict: bool = ...
|
||||
def __init__(
|
||||
self, keys: Iterable[str], strict: bool = ..., messages: Optional[Mapping[str, str]] = ...
|
||||
) -> None: ...
|
||||
def __call__(self, value: Any) -> None: ...
|
||||
|
||||
class RangeMaxValueValidator(MaxValueValidator): ...
|
||||
class RangeMinValueValidator(MinValueValidator): ...
|
||||
4
django-stubs/contrib/sessions/exceptions.pyi
Normal file
4
django-stubs/contrib/sessions/exceptions.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.core.exceptions import SuspiciousOperation
|
||||
|
||||
class InvalidSessionKey(SuspiciousOperation): ...
|
||||
class SuspiciousSession(SuspiciousOperation): ...
|
||||
@@ -1,15 +1,6 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
from django.db.models.query import QuerySet
|
||||
from typing import Optional
|
||||
|
||||
from django.db import models
|
||||
|
||||
class CurrentSiteManager(models.Manager):
|
||||
creation_counter: int
|
||||
model: None
|
||||
name: None
|
||||
use_in_migrations: bool = ...
|
||||
def __init__(self, field_name: Optional[str] = ...) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def get_queryset(self) -> QuerySet: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -23,6 +23,6 @@ class Command(BaseCommand):
|
||||
def log(self, msg: str, level: int = ...) -> None: ...
|
||||
def is_local_storage(self) -> bool: ...
|
||||
def clear_dir(self, path: str) -> None: ...
|
||||
def delete_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> bool: ...
|
||||
def link_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> None: ...
|
||||
def copy_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> None: ...
|
||||
def delete_file(self, path: str, prefixed_path: str, source_storage: Storage) -> bool: ...
|
||||
def link_file(self, path: str, prefixed_path: str, source_storage: Storage) -> None: ...
|
||||
def copy_file(self, path: str, prefixed_path: str, source_storage: Storage) -> None: ...
|
||||
|
||||
@@ -2,6 +2,6 @@ from typing import Any, List, Optional
|
||||
|
||||
from django.urls.resolvers import URLPattern
|
||||
|
||||
urlpatterns: Any
|
||||
urlpatterns: List[Any] = ...
|
||||
|
||||
def staticfiles_urlpatterns(prefix: None = ...) -> List[URLPattern]: ...
|
||||
def staticfiles_urlpatterns(prefix: Optional[str] = ...) -> List[URLPattern]: ...
|
||||
|
||||
6
django-stubs/core/cache/__init__.pyi
vendored
6
django-stubs/core/cache/__init__.pyi
vendored
@@ -1,7 +1,11 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, Union
|
||||
|
||||
from .backends.base import BaseCache as BaseCache
|
||||
from .backends.base import (
|
||||
BaseCache as BaseCache,
|
||||
CacheKeyWarning as CacheKeyWarning,
|
||||
InvalidCacheBackendError as InvalidCacheBackendError,
|
||||
)
|
||||
|
||||
DEFAULT_CACHE_ALIAS: str
|
||||
|
||||
|
||||
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
|
||||
|
||||
class LocMemCache(BaseCache):
|
||||
default_timeout: int
|
||||
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: ...
|
||||
def __init__(self, name: str, params: Dict[str, Any]) -> 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,3 +1,5 @@
|
||||
from .messages import Warning as Warning, Info as Info, Debug as Debug, Error as Error, Critical as Critical
|
||||
|
||||
from .registry import run_checks as run_checks, Tags as Tags, register as register
|
||||
|
||||
from . import model_checks as model_checks
|
||||
|
||||
7
django-stubs/core/checks/translation.pyi
Normal file
7
django-stubs/core/checks/translation.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
from typing import Any, List
|
||||
|
||||
from . import Error
|
||||
|
||||
E001: Error = ...
|
||||
|
||||
def check_setting_language_code(app_configs: Any, **kwargs: Any) -> List[Error]: ...
|
||||
@@ -1,32 +1,38 @@
|
||||
import types
|
||||
from io import StringIO
|
||||
from typing import Any, Iterator, Optional, Union
|
||||
from typing import Any, IO, Iterator, Optional, Type, TypeVar, Union
|
||||
|
||||
from django.core.files.utils import FileProxyMixin
|
||||
|
||||
class File(FileProxyMixin):
|
||||
_T = TypeVar("_T", bound="File")
|
||||
|
||||
class File(FileProxyMixin, IO[Any]):
|
||||
DEFAULT_CHUNK_SIZE: Any = ...
|
||||
file: StringIO = ...
|
||||
name: Optional[str] = ...
|
||||
name: str = ...
|
||||
mode: str = ...
|
||||
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
def size(self) -> int: ...
|
||||
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[Union[bytes, bytearray]]: ...
|
||||
def multiple_chunks(self, chunk_size: Optional[Any] = ...): ...
|
||||
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
|
||||
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
|
||||
def __iter__(self) -> Iterator[Union[bytes, str]]: ...
|
||||
def __enter__(self) -> File: ...
|
||||
def __exit__(self, exc_type: None, exc_value: None, tb: None) -> None: ...
|
||||
def open(self, mode: Optional[str] = ...) -> File: ...
|
||||
def __next__(self) -> Union[bytes, str]: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(
|
||||
self,
|
||||
exc_type: Optional[Type[BaseException]],
|
||||
exc_value: Optional[BaseException],
|
||||
tb: Optional[types.TracebackType],
|
||||
) -> bool: ...
|
||||
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
class ContentFile(File):
|
||||
file: StringIO
|
||||
size: Any = ...
|
||||
def __init__(self, content: Union[bytes, str], name: Optional[str] = ...) -> None: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def open(self, mode: Optional[str] = ...) -> ContentFile: ...
|
||||
def close(self) -> None: ...
|
||||
def write(self, data: str) -> int: ...
|
||||
|
||||
def endswith_cr(line: bytes) -> bool: ...
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, Union
|
||||
from typing import Any, IO, Union
|
||||
|
||||
from django.core.files import File
|
||||
|
||||
@@ -11,4 +10,4 @@ class ImageFile(File):
|
||||
@property
|
||||
def height(self) -> int: ...
|
||||
|
||||
def get_image_dimensions(file_or_path: Union[BytesIO, str], close: bool = ...) -> Any: ...
|
||||
def get_image_dimensions(file_or_path: Union[str, IO[bytes]], close: bool = ...) -> Any: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, IO, List, Optional, Tuple
|
||||
from typing import Any, IO, List, Optional, Tuple, Type
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.utils.functional import LazyObject
|
||||
@@ -13,7 +13,7 @@ class Storage:
|
||||
def path(self, name: str) -> str: ...
|
||||
def delete(self, name: str) -> None: ...
|
||||
def exists(self, name: str) -> bool: ...
|
||||
def listdir(self, path: Any) -> Optional[Tuple[List[str], List[str]]]: ...
|
||||
def listdir(self, path: str) -> Tuple[List[str], List[str]]: ...
|
||||
def size(self, name: str) -> int: ...
|
||||
def url(self, name: Optional[str]) -> str: ...
|
||||
def get_accessed_time(self, name: str) -> datetime: ...
|
||||
@@ -21,6 +21,7 @@ class Storage:
|
||||
def get_modified_time(self, name: str) -> datetime: ...
|
||||
|
||||
class FileSystemStorage(Storage):
|
||||
OS_OPEN_FLAGS: int = ...
|
||||
def __init__(
|
||||
self,
|
||||
location: Optional[str] = ...,
|
||||
@@ -42,3 +43,5 @@ class FileSystemStorage(Storage):
|
||||
class DefaultStorage(LazyObject): ...
|
||||
|
||||
default_storage: Any
|
||||
|
||||
def get_storage_class(import_path: Optional[str] = ...) -> Type[Storage]: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, Dict, IO, Iterator, Optional, Union
|
||||
from django.core.files import temp as tempfile
|
||||
from typing import Any, Dict, IO, Optional, Union
|
||||
|
||||
from django.core.files.base import File
|
||||
|
||||
class UploadedFile(File):
|
||||
@@ -39,8 +39,6 @@ class InMemoryUploadedFile(UploadedFile):
|
||||
charset: Optional[str],
|
||||
content_type_extra: Dict[str, str] = ...,
|
||||
) -> None: ...
|
||||
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
|
||||
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
|
||||
|
||||
class SimpleUploadedFile(InMemoryUploadedFile):
|
||||
def __init__(self, name: str, content: Optional[Union[bytes, str]], content_type: str = ...) -> None: ...
|
||||
|
||||
@@ -23,9 +23,14 @@ class FileUploadHandler:
|
||||
content_type_extra = ... # type: Optional[Dict[str, str]]
|
||||
request = ... # type: Optional[HttpRequest]
|
||||
field_name = ... # type: str
|
||||
def __init__(self, request: HttpRequest = None) -> None: ...
|
||||
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
|
||||
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]]]: ...
|
||||
def new_file(
|
||||
self,
|
||||
@@ -33,15 +38,15 @@ class FileUploadHandler:
|
||||
file_name: str,
|
||||
content_type: str,
|
||||
content_length: Optional[int],
|
||||
charset: str = None,
|
||||
content_type_extra: Dict[str, str] = None,
|
||||
charset: Optional[str] = ...,
|
||||
content_type_extra: Optional[Dict[str, str]] = ...,
|
||||
) -> None: ...
|
||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
||||
def upload_complete(self) -> None: ...
|
||||
|
||||
class TemporaryFileUploadHandler(FileUploadHandler):
|
||||
def __init__(self, request: HttpRequest = None) -> None: ...
|
||||
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
|
||||
file = ... # type: TemporaryUploadedFile
|
||||
def new_file(
|
||||
self,
|
||||
@@ -49,8 +54,8 @@ class TemporaryFileUploadHandler(FileUploadHandler):
|
||||
file_name: str,
|
||||
content_type: str,
|
||||
content_length: Optional[int],
|
||||
charset: str = None,
|
||||
content_type_extra: Dict[str, str] = None,
|
||||
charset: Optional[str] = ...,
|
||||
content_type_extra: Optional[Dict[str, str]] = ...,
|
||||
) -> None: ...
|
||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
||||
@@ -59,7 +64,12 @@ class MemoryFileUploadHandler(FileUploadHandler):
|
||||
activated = ... # type: bool
|
||||
file = ... # type: IO[bytes]
|
||||
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]]]: ...
|
||||
def new_file(
|
||||
self,
|
||||
@@ -67,8 +77,8 @@ class MemoryFileUploadHandler(FileUploadHandler):
|
||||
file_name: str,
|
||||
content_type: str,
|
||||
content_length: Optional[int],
|
||||
charset: str = None,
|
||||
content_type_extra: Dict[str, str] = None,
|
||||
charset: Optional[str] = ...,
|
||||
content_type_extra: Optional[Dict[str, str]] = ...,
|
||||
) -> None: ...
|
||||
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
|
||||
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
|
||||
|
||||
@@ -6,10 +6,6 @@ from django.http.response import HttpResponse, HttpResponseBase
|
||||
logger: Any
|
||||
|
||||
class BaseHandler:
|
||||
_view_middleware: None = ...
|
||||
_template_response_middleware: None = ...
|
||||
_exception_middleware: None = ...
|
||||
_middleware_chain: None = ...
|
||||
def load_middleware(self) -> None: ...
|
||||
def make_view_atomic(self, view: Callable) -> Callable: ...
|
||||
def get_exception_response(self, request: Any, resolver: Any, status_code: Any, exception: Any): ...
|
||||
|
||||
0
django-stubs/core/mail/backends/__init__.pyi
Normal file
0
django-stubs/core/mail/backends/__init__.pyi
Normal file
16
django-stubs/core/mail/backends/base.pyi
Normal file
16
django-stubs/core/mail/backends/base.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
import types
|
||||
from typing import Any, TypeVar, Type, Iterable
|
||||
|
||||
from django.core.mail.message import EmailMessage
|
||||
|
||||
_T = TypeVar("_T", bound="BaseEmailBackend")
|
||||
|
||||
class BaseEmailBackend:
|
||||
def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ...
|
||||
def open(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(
|
||||
self, exc_type: Type[BaseException], exc_value: BaseException, traceback: types.TracebackType
|
||||
) -> None: ...
|
||||
def send_messages(self, email_messages: Iterable[EmailMessage]) -> int: ...
|
||||
@@ -65,13 +65,14 @@ class EmailMessage:
|
||||
to: Optional[Union[Sequence[str], str]] = ...,
|
||||
bcc: Optional[Union[Sequence[str], str]] = ...,
|
||||
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]] = ...,
|
||||
cc: Optional[Union[Sequence[str], str]] = ...,
|
||||
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
|
||||
) -> None: ...
|
||||
def get_connection(self, fail_silently: bool = ...) -> Any: ...
|
||||
def message(self) -> MIMEMixin: ...
|
||||
# TODO: when typeshed gets more types for email.Message, move it to MIMEMessage, now it has too many false-positives
|
||||
def message(self) -> Any: ...
|
||||
def recipients(self) -> List[str]: ...
|
||||
def send(self, fail_silently: bool = ...) -> int: ...
|
||||
def attach(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
from typing import Any, Dict, List, Tuple, Union
|
||||
|
||||
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
|
||||
from .base import BaseCommand as BaseCommand, CommandError as CommandError
|
||||
|
||||
def find_commands(management_dir: str) -> List[str]: ...
|
||||
def load_command_class(app_name: str, name: str) -> BaseCommand: ...
|
||||
def get_commands() -> Dict[str, str]: ...
|
||||
def call_command(command_name: Union[Tuple[str], BaseCommand, str], *args: Any, **options: Any) -> Optional[str]: ...
|
||||
def call_command(command_name: Union[Tuple[str], BaseCommand, str], *args: Any, **options: Any) -> str: ...
|
||||
|
||||
class ManagementUtility:
|
||||
argv: List[str] = ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from argparse import ArgumentParser, HelpFormatter, Namespace
|
||||
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.core.management.color import Style
|
||||
@@ -36,16 +36,20 @@ class BaseCommand:
|
||||
output_transaction: bool = ...
|
||||
requires_migrations_checks: bool = ...
|
||||
requires_system_checks: bool = ...
|
||||
base_stealth_options: Any = ...
|
||||
stealth_options: Any = ...
|
||||
base_stealth_options: Tuple[str, ...] = ...
|
||||
stealth_options: Tuple[str, ...] = ...
|
||||
stdout: OutputWrapper = ...
|
||||
stderr: OutputWrapper = ...
|
||||
style: Style = ...
|
||||
def __init__(
|
||||
self, stdout: Optional[StringIO] = ..., stderr: Optional[StringIO] = ..., no_color: bool = ...
|
||||
self,
|
||||
stdout: Optional[StringIO] = ...,
|
||||
stderr: Optional[StringIO] = ...,
|
||||
no_color: bool = ...,
|
||||
force_color: bool = ...,
|
||||
) -> None: ...
|
||||
def get_version(self) -> str: ...
|
||||
def create_parser(self, prog_name: str, subcommand: str) -> CommandParser: ...
|
||||
def create_parser(self, prog_name: str, subcommand: str, **kwargs: Any) -> CommandParser: ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def print_help(self, prog_name: str, subcommand: str) -> None: ...
|
||||
def run_from_argv(self, argv: List[str]) -> None: ...
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
from collections import Callable
|
||||
|
||||
def supports_color() -> bool: ...
|
||||
|
||||
class Style: ...
|
||||
class Style:
|
||||
def DEBUG(self, text: str) -> str: ...
|
||||
def INFO(self, text: str) -> str: ...
|
||||
def SUCCESS(self, text: str) -> str: ...
|
||||
def WARNING(self, text: str) -> str: ...
|
||||
def ERROR(self, text: str) -> str: ...
|
||||
|
||||
def make_style(config_string: str = ...) -> Style: ...
|
||||
def no_style(): ...
|
||||
def no_style() -> Style: ...
|
||||
def color_style() -> Style: ...
|
||||
|
||||
0
django-stubs/core/management/commands/__init__.pyi
Normal file
0
django-stubs/core/management/commands/__init__.pyi
Normal file
4
django-stubs/core/management/commands/dumpdata.pyi
Normal file
4
django-stubs/core/management/commands/dumpdata.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class ProxyModelWarning(Warning): ...
|
||||
class Command(BaseCommand): ...
|
||||
19
django-stubs/core/management/commands/loaddata.pyi
Normal file
19
django-stubs/core/management/commands/loaddata.pyi
Normal file
@@ -0,0 +1,19 @@
|
||||
import zipfile
|
||||
from typing import Iterable, List, Optional, Tuple
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
READ_STDIN: str = ...
|
||||
|
||||
class Command(BaseCommand):
|
||||
missing_args_message: str = ...
|
||||
def loaddata(self, fixture_labels: Iterable[str]) -> None: ...
|
||||
def load_label(self, fixture_label: str) -> None: ...
|
||||
def find_fixtures(self, fixture_label: str) -> List[Optional[str]]: ...
|
||||
@property
|
||||
def fixture_dirs(self) -> List[str]: ...
|
||||
def parse_name(self, fixture_name: str) -> Tuple[str, str, str]: ...
|
||||
|
||||
class SingleZipReader(zipfile.ZipFile): ...
|
||||
|
||||
def humanize(dirname: str) -> str: ...
|
||||
45
django-stubs/core/management/commands/makemessages.pyi
Normal file
45
django-stubs/core/management/commands/makemessages.pyi
Normal file
@@ -0,0 +1,45 @@
|
||||
import os
|
||||
import re
|
||||
from typing import Any, Pattern, Type, Optional
|
||||
|
||||
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 = ...
|
||||
STATUS_OK: int = ...
|
||||
NO_LOCALE_DIR: Any = ...
|
||||
|
||||
def check_programs(*programs: str) -> None: ...
|
||||
|
||||
class TranslatableFile:
|
||||
dirpath: str
|
||||
file_name: str
|
||||
locale_dir: str
|
||||
def __init__(self, dirpath: str, file_name: str, locale_dir: Optional[str]) -> None: ...
|
||||
|
||||
class BuildFile:
|
||||
"""
|
||||
Represent the state of a translatable file during the build process.
|
||||
"""
|
||||
|
||||
def __init__(self, command: BaseCommand, domain: str, translatable: TranslatableFile) -> None: ...
|
||||
@property
|
||||
def is_templatized(self) -> bool: ...
|
||||
@property
|
||||
def path(self) -> str: ...
|
||||
@property
|
||||
def work_path(self) -> str: ...
|
||||
def preprocess(self) -> None: ...
|
||||
def postprocess_messages(self, msgs: str) -> str: ...
|
||||
def cleanup(self) -> None: ...
|
||||
|
||||
def normalize_eols(raw_contents: str) -> str: ...
|
||||
def write_pot_file(potfile: str, msgs: str) -> None: ...
|
||||
|
||||
class Command(BaseCommand):
|
||||
translatable_file_class: Type[TranslatableFile] = ...
|
||||
build_file_class: Type[BuildFile] = ...
|
||||
7
django-stubs/core/management/commands/runserver.pyi
Normal file
7
django-stubs/core/management/commands/runserver.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
default_addr: str = ...
|
||||
default_addr_ipv6: str = ...
|
||||
default_port: int = ...
|
||||
protocol: str = ...
|
||||
3
django-stubs/core/management/commands/testserver.pyi
Normal file
3
django-stubs/core/management/commands/testserver.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class Command(BaseCommand): ...
|
||||
@@ -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 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 parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ...
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, Iterable
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Type, Union
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from .base import (
|
||||
Serializer as Serializer,
|
||||
Deserializer as Deserializer,
|
||||
SerializerDoesNotExist as SerializerDoesNotExist,
|
||||
SerializationError as SerializationError,
|
||||
DeserializationError as DeserializationError,
|
||||
DeserializedObject,
|
||||
Deserializer as Deserializer,
|
||||
M2MDeserializationError as M2MDeserializationError,
|
||||
SerializationError as SerializationError,
|
||||
Serializer as Serializer,
|
||||
SerializerDoesNotExist as SerializerDoesNotExist,
|
||||
)
|
||||
|
||||
BUILTIN_SERIALIZERS: Any
|
||||
|
||||
class BadSerializer:
|
||||
internal_use_only: bool = ...
|
||||
exception: ModuleNotFoundError = ...
|
||||
def __init__(self, exception: ImportError) -> None: ...
|
||||
exception: BaseException = ...
|
||||
def __init__(self, exception: BaseException) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
|
||||
def register_serializer(format: str, serializer_module: str, serializers: Optional[Dict[str, Any]] = ...) -> None: ...
|
||||
@@ -27,10 +26,6 @@ def get_serializer(format: str) -> Union[Type[Serializer], BadSerializer]: ...
|
||||
def get_serializer_formats() -> List[str]: ...
|
||||
def get_public_serializer_formats() -> List[str]: ...
|
||||
def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ...
|
||||
def serialize(
|
||||
format: str, queryset: Union[Iterator[Any], List[Model], QuerySet], **options: Any
|
||||
) -> Optional[Union[bytes, str]]: ...
|
||||
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
|
||||
def sort_dependencies(
|
||||
app_list: Union[Iterable[Tuple[AppConfig, None]], Iterable[Tuple[str, Iterable[Type[Model]]]]]
|
||||
) -> List[Type[Model]]: ...
|
||||
def serialize(format: str, queryset: Iterable[Model], **options: Any) -> Any: ...
|
||||
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Iterator[DeserializedObject]: ...
|
||||
def sort_dependencies(app_list: Iterable[Any]) -> List[Type[Model]]: ...
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date
|
||||
from io import BufferedReader, StringIO, TextIOWrapper
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Dict, Iterable, List, Mapping, Optional, Type, Union
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.management.base import OutputWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.related import ForeignKey, ManyToManyField
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class SerializerDoesNotExist(KeyError): ...
|
||||
class SerializationError(Exception): ...
|
||||
@@ -43,7 +43,7 @@ class Serializer:
|
||||
first: bool = ...
|
||||
def serialize(
|
||||
self,
|
||||
queryset: Union[Iterator[Any], List[Model], QuerySet],
|
||||
queryset: Iterable[Model],
|
||||
*,
|
||||
stream: Optional[Any] = ...,
|
||||
fields: Optional[Any] = ...,
|
||||
@@ -52,7 +52,7 @@ class Serializer:
|
||||
progress_output: Optional[Any] = ...,
|
||||
object_count: int = ...,
|
||||
**options: Any
|
||||
) -> Optional[Union[List[OrderedDict], bytes, str]]: ...
|
||||
) -> Any: ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def start_object(self, obj: Any) -> None: ...
|
||||
@@ -70,15 +70,18 @@ class Deserializer:
|
||||
def __next__(self) -> None: ...
|
||||
|
||||
class DeserializedObject:
|
||||
object: Model = ...
|
||||
m2m_data: Dict[Any, Any] = ...
|
||||
def __init__(self, obj: Model, m2m_data: Optional[Dict[str, List[int]]] = ...) -> None: ...
|
||||
object: Any = ...
|
||||
m2m_data: Dict[str, List[int]] = ...
|
||||
deferred_fields: Mapping[Field, Any]
|
||||
def __init__(
|
||||
self,
|
||||
obj: Model,
|
||||
m2m_data: Optional[Dict[str, List[int]]] = ...,
|
||||
deferred_fields: Optional[Mapping[Field, Any]] = ...,
|
||||
) -> None: ...
|
||||
def save(self, save_m2m: bool = ..., using: Optional[str] = ..., **kwargs: Any) -> None: ...
|
||||
def save_deferred_fields(self, using: Optional[str] = ...) -> None: ...
|
||||
|
||||
def build_instance(Model: Type[Model], data: Dict[str, Optional[Union[date, int, str, UUID]]], db: str) -> Model: ...
|
||||
def deserialize_m2m_values(
|
||||
field: ManyToManyField, field_value: Union[List[List[str]], List[int]], using: str
|
||||
) -> List[int]: ...
|
||||
def deserialize_fk_value(
|
||||
field: ForeignKey, field_value: Optional[Union[List[str], Tuple[str], int, str]], using: str
|
||||
) -> Optional[Union[int, str, UUID]]: ...
|
||||
def deserialize_m2m_values(field: ManyToManyField, field_value: Any, using: str) -> List[Any]: ...
|
||||
def deserialize_fk_value(field: ForeignKey, field_value: Any, using: str) -> Any: ...
|
||||
|
||||
@@ -27,4 +27,5 @@ class DefaultConnectionProxy:
|
||||
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||
def __delattr__(self, name: str) -> None: ...
|
||||
|
||||
def close_old_connections(**kwargs): ...
|
||||
def close_old_connections(**kwargs: Any) -> None: ...
|
||||
def reset_queries(**kwargs: Any) -> None: ...
|
||||
|
||||
@@ -25,7 +25,7 @@ class BaseDatabaseOperations:
|
||||
CURRENT_ROW: str = ...
|
||||
explain_prefix: Any = ...
|
||||
connection: Any = ...
|
||||
def __init__(self, connection: Union[DefaultConnectionProxy, BaseDatabaseWrapper]) -> None: ...
|
||||
def __init__(self, connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]]) -> None: ...
|
||||
def autoinc_sql(self, table: str, column: str) -> None: ...
|
||||
def bulk_batch_size(self, fields: Any, objs: Any): ...
|
||||
def cache_key_culling_sql(self) -> str: ...
|
||||
|
||||
17
django-stubs/db/backends/postgresql/base.pyi
Normal file
17
django-stubs/db/backends/postgresql/base.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import Dict, Tuple
|
||||
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
|
||||
def psycopg2_version() -> Tuple[int, ...]: ...
|
||||
|
||||
PSYCOPG2_VERSION: Tuple[int, ...] = ...
|
||||
|
||||
class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
operators: Dict[str, str] = ...
|
||||
pattern_esc: str = ...
|
||||
pattern_ops: Dict[str, str] = ...
|
||||
|
||||
# PostgreSQL backend-specific attributes.
|
||||
_named_cursor_idx: int = ...
|
||||
@property
|
||||
def pg_version(self) -> str: ...
|
||||
3
django-stubs/db/backends/postgresql/creation.pyi
Normal file
3
django-stubs/db/backends/postgresql/creation.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db.backends.base.creation import BaseDatabaseCreation
|
||||
|
||||
class DatabaseCreation(BaseDatabaseCreation): ...
|
||||
3
django-stubs/db/backends/postgresql/operations.pyi
Normal file
3
django-stubs/db/backends/postgresql/operations.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db.backends.base.operations import BaseDatabaseOperations
|
||||
|
||||
class DatabaseOperations(BaseDatabaseOperations): ...
|
||||
3
django-stubs/db/backends/signals.pyi
Normal file
3
django-stubs/db/backends/signals.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.dispatch import Signal
|
||||
|
||||
connection_created: Signal = ...
|
||||
@@ -1,9 +1,14 @@
|
||||
import types
|
||||
from datetime import date, datetime, time
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
|
||||
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple, Union, Type
|
||||
from uuid import UUID
|
||||
|
||||
logger: Any
|
||||
|
||||
# Python types that can be adapted to SQL.
|
||||
_SQLType = Union[None, bool, int, float, Decimal, str, bytes, datetime, UUID]
|
||||
|
||||
class CursorWrapper:
|
||||
cursor: Any = ...
|
||||
db: Any = ...
|
||||
@@ -12,13 +17,18 @@ class CursorWrapper:
|
||||
def __getattr__(self, attr: str) -> Any: ...
|
||||
def __iter__(self) -> None: ...
|
||||
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 execute(
|
||||
self, sql: str, params: Optional[Union[List[bool], List[datetime], List[float], Tuple]] = ...
|
||||
self, sql: str, params: Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]] = ...
|
||||
) -> Optional[Any]: ...
|
||||
def executemany(
|
||||
self, sql: str, param_list: Union[Iterator[Any], List[Tuple[Union[int, str]]]]
|
||||
self, sql: str, param_list: Sequence[Optional[Union[Sequence[_SQLType], Mapping[str, _SQLType]]]]
|
||||
) -> Optional[Any]: ...
|
||||
|
||||
class CursorDebugWrapper(CursorWrapper):
|
||||
|
||||
@@ -47,7 +47,7 @@ class MigrationGraph:
|
||||
def iterative_dfs(self, start: Any, forwards: bool = ...): ...
|
||||
def root_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ...
|
||||
def leaf_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ...
|
||||
def ensure_not_cyclic(self, start: Union[Tuple[str, str], Node], get_children: Callable) -> None: ...
|
||||
def ensure_not_cyclic(self) -> None: ...
|
||||
def make_state(
|
||||
self, nodes: Optional[Tuple[str, str]] = ..., at_end: bool = ..., real_apps: List[str] = ...
|
||||
) -> ProjectState: ...
|
||||
|
||||
@@ -8,7 +8,7 @@ MIGRATIONS_MODULE_NAME: str
|
||||
class MigrationLoader:
|
||||
connection: Any = ...
|
||||
disk_migrations: Dict[Tuple[str, str], Migration] = ...
|
||||
applied_migrations: None = ...
|
||||
applied_migrations: Set[Tuple[str, str]] = ...
|
||||
ignore_no_migrations: bool = ...
|
||||
def __init__(self, connection: Any, load: bool = ..., ignore_no_migrations: bool = ...) -> None: ...
|
||||
@classmethod
|
||||
|
||||
@@ -16,41 +16,7 @@ from .models import (
|
||||
DeleteModel as DeleteModel,
|
||||
RemoveIndex as RemoveIndex,
|
||||
RenameModel as RenameModel,
|
||||
AddConstraint as AddConstraint,
|
||||
RemoveConstraint as RemoveConstraint,
|
||||
)
|
||||
from .special import RunPython as RunPython, RunSQL as RunSQL, SeparateDatabaseAndState as SeparateDatabaseAndState
|
||||
from .fields import AddField, AlterField, RemoveField, RenameField
|
||||
from .models import (
|
||||
AddIndex,
|
||||
AlterIndexTogether,
|
||||
AlterModelManagers,
|
||||
AlterModelOptions,
|
||||
AlterModelTable,
|
||||
AlterOrderWithRespectTo,
|
||||
AlterUniqueTogether,
|
||||
CreateModel,
|
||||
DeleteModel,
|
||||
RemoveIndex,
|
||||
RenameModel,
|
||||
)
|
||||
from .special import RunPython, RunSQL, SeparateDatabaseAndState
|
||||
|
||||
__all__ = [
|
||||
"CreateModel",
|
||||
"DeleteModel",
|
||||
"AlterModelTable",
|
||||
"AlterUniqueTogether",
|
||||
"RenameModel",
|
||||
"AlterIndexTogether",
|
||||
"AlterModelOptions",
|
||||
"AddIndex",
|
||||
"RemoveIndex",
|
||||
"AddField",
|
||||
"RemoveField",
|
||||
"AlterField",
|
||||
"RenameField",
|
||||
"SeparateDatabaseAndState",
|
||||
"RunSQL",
|
||||
"RunPython",
|
||||
"AlterOrderWithRespectTo",
|
||||
"AlterModelManagers",
|
||||
]
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.db.models.fields import Field
|
||||
from .base import Operation
|
||||
|
||||
class FieldOperation(Operation):
|
||||
model_name: Any = ...
|
||||
model_name: str = ...
|
||||
model_name_lower: str
|
||||
name: Any = ...
|
||||
def __init__(self, model_name: str, name: str) -> None: ...
|
||||
name: str = ...
|
||||
def __init__(self, model_name: str, name: str, field: Optional[Field] = ...) -> None: ...
|
||||
def name_lower(self) -> str: ...
|
||||
def is_same_model_operation(self, operation: FieldOperation) -> bool: ...
|
||||
def is_same_field_operation(self, operation: AddField) -> bool: ...
|
||||
|
||||
class AddField(FieldOperation):
|
||||
field: Any = ...
|
||||
preserve_default: Any = ...
|
||||
field: Field = ...
|
||||
preserve_default: bool = ...
|
||||
def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ...
|
||||
|
||||
class RemoveField(FieldOperation): ...
|
||||
|
||||
@@ -4,6 +4,7 @@ from django.db.migrations.operations.base import Operation
|
||||
from django.db.models.indexes import Index
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class ModelOperation(Operation):
|
||||
@@ -78,3 +79,9 @@ class RemoveIndex(IndexOperation):
|
||||
model_name: str = ...
|
||||
name: str = ...
|
||||
def __init__(self, model_name: str, name: Union[str, Index]) -> None: ...
|
||||
|
||||
class AddConstraint(IndexOperation):
|
||||
def __init__(self, model_name: str, constraint: BaseConstraint): ...
|
||||
|
||||
class RemoveConstraint(IndexOperation):
|
||||
def __init__(self, model_name: str, name: str) -> None: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, Dict, List, Set, Tuple, Union
|
||||
from typing import Any, Callable, Dict, List, Set, Tuple, Union, Type
|
||||
|
||||
class BaseSerializer:
|
||||
value: Any = ...
|
||||
@@ -38,3 +38,9 @@ class TypeSerializer(BaseSerializer): ...
|
||||
class UUIDSerializer(BaseSerializer): ...
|
||||
|
||||
def serializer_factory(value: Any) -> BaseSerializer: ...
|
||||
|
||||
class Serializer:
|
||||
@classmethod
|
||||
def register(cls, type_: type, serializer: Type[BaseSerializer]) -> None: ...
|
||||
@classmethod
|
||||
def unregister(cls, type_: type) -> None: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union
|
||||
from typing import Any, DefaultDict, Dict, Iterator, List, Optional, Sequence, Tuple, Type, Union, Set
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.db.models.base import Model
|
||||
@@ -42,6 +42,9 @@ class ModelState:
|
||||
def name_lower(self) -> str: ...
|
||||
def render(self, apps: Apps) -> Any: ...
|
||||
|
||||
def get_related_models_tuples(model: Type[Model]) -> Set[Tuple[str, str]]: ...
|
||||
def get_related_models_recursive(model: Type[Model]) -> Set[Tuple[str, str]]: ...
|
||||
|
||||
class ProjectState:
|
||||
is_delayed: bool
|
||||
models: Dict[Any, Any]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any
|
||||
from typing import Any, Iterable, Union, Optional, List
|
||||
|
||||
COMPILED_REGEX_TYPE: Any
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Any, List, Set, Tuple, Union
|
||||
from typing import Any, List, Set, Tuple, Union, Type
|
||||
|
||||
from django.db.migrations.migration import Migration
|
||||
from django.db.migrations.operations.base import Operation
|
||||
from django.db.migrations.operations.models import CreateModel
|
||||
from django.db.migrations.serializer import BaseSerializer
|
||||
|
||||
class SettingsReference(str):
|
||||
def __init__(self, value: str, setting_name: str) -> None: ...
|
||||
@@ -21,7 +22,7 @@ class OperationWriter:
|
||||
class MigrationWriter:
|
||||
migration: Migration = ...
|
||||
needs_manual_porting: bool = ...
|
||||
def __init__(self, migration: Union[type, Migration]) -> None: ...
|
||||
def __init__(self, migration: Union[type, Migration], include_header: bool = ...) -> None: ...
|
||||
def as_string(self) -> str: ...
|
||||
@property
|
||||
def basedir(self) -> str: ...
|
||||
@@ -31,5 +32,9 @@ class MigrationWriter:
|
||||
def path(self) -> str: ...
|
||||
@classmethod
|
||||
def serialize(cls, value: Any) -> Tuple[str, Set[str]]: ...
|
||||
@classmethod
|
||||
def register_serializer(cls, type_: type, serializer: Type[BaseSerializer]) -> None: ...
|
||||
@classmethod
|
||||
def unregister_serializer(cls, type_: type) -> None: ...
|
||||
|
||||
MIGRATION_TEMPLATE: str
|
||||
|
||||
@@ -99,6 +99,10 @@ from .expressions import (
|
||||
ExpressionList as ExpressionList,
|
||||
Random as Random,
|
||||
Ref as Ref,
|
||||
Window as Window,
|
||||
WindowFrame as WindowFrame,
|
||||
RowRange as RowRange,
|
||||
ValueRange as ValueRange,
|
||||
)
|
||||
|
||||
from .manager import BaseManager as BaseManager, Manager as Manager
|
||||
@@ -118,3 +122,9 @@ from .aggregates import (
|
||||
from .indexes import Index as Index
|
||||
|
||||
from . import signals as signals
|
||||
|
||||
from .constraints import (
|
||||
BaseConstraint as BaseConstraint,
|
||||
CheckConstraint as CheckConstraint,
|
||||
UniqueConstraint as UniqueConstraint,
|
||||
)
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.db.models.expressions import Func
|
||||
from django.db.models.query_utils import Q
|
||||
|
||||
class Aggregate(Func):
|
||||
name: Any = ...
|
||||
filter_template: str = ...
|
||||
window_compatible: bool = ...
|
||||
filter: Any = ...
|
||||
def __init__(self, *args: Any, filter: Optional[Any] = ..., **kwargs: Any) -> None: ...
|
||||
def __init__(self, *expressions: Any, distinct: bool = ..., filter: Optional[Any] = ..., **extra: Any) -> None: ...
|
||||
|
||||
class Avg(Aggregate): ...
|
||||
|
||||
class Count(Aggregate):
|
||||
template: str = ...
|
||||
def __init__(self, expression: str, distinct: bool = ..., filter: Optional[Q] = ..., **extra: Any) -> None: ...
|
||||
|
||||
class Count(Aggregate): ...
|
||||
class Max(Aggregate): ...
|
||||
class Min(Aggregate): ...
|
||||
class StdDev(Aggregate): ...
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union, ClassVar, Sequence, Generic
|
||||
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, TypeVar, Union, ClassVar, Type
|
||||
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
class ModelBase(type): ...
|
||||
from django.core.checks.messages import CheckMessage
|
||||
|
||||
from django.db.models.options import Options
|
||||
|
||||
_Self = TypeVar("_Self", bound="Model")
|
||||
|
||||
class ModelBase(type): ...
|
||||
|
||||
class Model(metaclass=ModelBase):
|
||||
class DoesNotExist(Exception): ...
|
||||
class MultipleObjectsReturned(Exception): ...
|
||||
class Meta: ...
|
||||
_meta: Any
|
||||
_default_manager: Manager[Model]
|
||||
_meta: Options[Any]
|
||||
objects: Manager[Any]
|
||||
pk: Any = ...
|
||||
def __init__(self: _Self, *args, **kwargs) -> None: ...
|
||||
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
|
||||
@@ -36,6 +41,8 @@ class Model(metaclass=ModelBase):
|
||||
): ...
|
||||
def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> _Self: ...
|
||||
def get_deferred_fields(self) -> Set[str]: ...
|
||||
@classmethod
|
||||
def check(cls, **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def __getstate__(self) -> dict: ...
|
||||
|
||||
class ModelStateFieldsCacheDescriptor: ...
|
||||
|
||||
27
django-stubs/db/models/constraints.pyi
Normal file
27
django-stubs/db/models/constraints.pyi
Normal file
@@ -0,0 +1,27 @@
|
||||
from typing import Any, Optional, Sequence, Tuple, Type, TypeVar
|
||||
|
||||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query_utils import Q
|
||||
|
||||
_T = TypeVar("_T", bound="BaseConstraint")
|
||||
|
||||
class BaseConstraint:
|
||||
name: str
|
||||
def __init__(self, name: str) -> None: ...
|
||||
def constraint_sql(
|
||||
self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]
|
||||
) -> str: ...
|
||||
def create_sql(self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]) -> str: ...
|
||||
def remove_sql(self, model: Optional[Type[Model]], schema_editor: Optional[BaseDatabaseSchemaEditor]) -> str: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def clone(self: _T) -> _T: ...
|
||||
|
||||
class CheckConstraint(BaseConstraint):
|
||||
check: Q
|
||||
def __init__(self, *, check: Q, name: str) -> None: ...
|
||||
|
||||
class UniqueConstraint(BaseConstraint):
|
||||
fields: Tuple[str]
|
||||
condition: Optional[Q]
|
||||
def __init__(self, *, fields: Sequence[str], name: str, condition: Optional[Q] = ...): ...
|
||||
@@ -1,6 +1,10 @@
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, Iterable, Optional, Union
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
from django.db import IntegrityError
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.options import Options
|
||||
|
||||
def CASCADE(collector, field, sub_objs, using): ...
|
||||
def SET_NULL(collector, field, sub_objs, using): ...
|
||||
@@ -8,6 +12,10 @@ def SET_DEFAULT(collector, field, sub_objs, using): ...
|
||||
def DO_NOTHING(collector, field, sub_objs, using): ...
|
||||
def PROTECT(collector, field, sub_objs, using): ...
|
||||
def SET(value: Any) -> Callable: ...
|
||||
def get_candidate_relations_to_delete(opts: Options) -> Iterable[Field]: ...
|
||||
|
||||
class ProtectedError(IntegrityError): ...
|
||||
class Collector: ...
|
||||
|
||||
class Collector:
|
||||
def __init__(self, using: str) -> None: ...
|
||||
def can_fast_delete(self, objs: Union[Model, Iterable[Model]], from_field: Optional[Field] = ...) -> bool: ...
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union, Iterable
|
||||
|
||||
from django.db.models.lookups import Lookup
|
||||
from django.db.models.sql.compiler import SQLCompiler
|
||||
|
||||
from django.db.models import Q, QuerySet
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.query import _BaseQuerySet
|
||||
|
||||
_OutputField = Union[Field, str]
|
||||
|
||||
@@ -52,7 +53,6 @@ class BaseExpression:
|
||||
is_summary: bool = ...
|
||||
filterable: bool = ...
|
||||
window_compatible: bool = ...
|
||||
output_field: Any
|
||||
def __init__(self, output_field: Optional[_OutputField] = ...) -> None: ...
|
||||
def get_db_converters(self, connection: Any) -> List[Callable]: ...
|
||||
def get_source_expressions(self) -> List[Any]: ...
|
||||
@@ -126,7 +126,7 @@ class Subquery(Expression):
|
||||
template: str = ...
|
||||
queryset: QuerySet = ...
|
||||
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):
|
||||
negated: bool = ...
|
||||
@@ -184,10 +184,36 @@ class ExpressionWrapper(Expression):
|
||||
class Col(Expression):
|
||||
def __init__(self, alias: str, target: str, output_field: Optional[_OutputField] = ...): ...
|
||||
|
||||
class SimpleCol(Expression):
|
||||
contains_column_references: bool = ...
|
||||
def __init__(self, target: Field, output_field: Optional[_OutputField] = ...): ...
|
||||
|
||||
class Ref(Expression):
|
||||
def __init__(self, refs: str, source: Expression): ...
|
||||
|
||||
class ExpressionList(Func):
|
||||
def __init__(self, *expressions: Union[BaseExpression, Combinable], **extra: Any) -> None: ...
|
||||
|
||||
class Random(Expression): ...
|
||||
|
||||
class Ref(Expression):
|
||||
def __init__(self, refs: str, source: Expression): ...
|
||||
class Window(Expression):
|
||||
template: str = ...
|
||||
contains_aggregate: bool = ...
|
||||
contains_over_clause: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
expression: BaseExpression,
|
||||
partition_by: Optional[Union[str, Iterable[Union[BaseExpression, F]], F, BaseExpression]] = ...,
|
||||
order_by: Optional[Union[Sequence[Union[BaseExpression, F]], Union[BaseExpression, F]]] = ...,
|
||||
frame: Optional[WindowFrame] = ...,
|
||||
output_field: Optional[_OutputField] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class WindowFrame(Expression):
|
||||
template: str = ...
|
||||
frame_type: str = ...
|
||||
def __init__(self, start: Optional[int] = ..., end: Optional[int] = ...) -> None: ...
|
||||
def window_frame_start_end(self, connection: Any, start: Optional[int], end: Optional[int]) -> Tuple[int, int]: ...
|
||||
|
||||
class RowRange(WindowFrame): ...
|
||||
class ValueRange(WindowFrame): ...
|
||||
|
||||
@@ -1,11 +1,27 @@
|
||||
import decimal
|
||||
import uuid
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from typing import Any, Callable, Dict, Generic, Iterable, Optional, Tuple, Type, TypeVar, Union
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generic,
|
||||
Iterable,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
Sequence,
|
||||
List,
|
||||
overload,
|
||||
)
|
||||
|
||||
from django.core import checks
|
||||
|
||||
from django.db.models import Model
|
||||
from django.core.exceptions import FieldDoesNotExist as FieldDoesNotExist
|
||||
from django.db.models.expressions import Combinable
|
||||
from django.db.models.expressions import Combinable, Col
|
||||
from django.db.models.query_utils import RegisterLookupMixin
|
||||
from django.forms import Field as FormField, Widget
|
||||
|
||||
@@ -18,6 +34,7 @@ _FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||
_ValidatorCallable = Callable[..., None]
|
||||
_ErrorMessagesToOverride = Dict[str, Any]
|
||||
|
||||
_T = TypeVar("_T", bound="Field")
|
||||
# __set__ value type
|
||||
_ST = TypeVar("_ST")
|
||||
# __get__ return type
|
||||
@@ -30,10 +47,21 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
widget: Widget
|
||||
help_text: str
|
||||
db_table: str
|
||||
attname: str
|
||||
auto_created: bool
|
||||
primary_key: bool
|
||||
remote_field: Field
|
||||
max_length: Optional[int]
|
||||
max_length: int
|
||||
model: Type[Model]
|
||||
name: str
|
||||
verbose_name: str
|
||||
blank: bool = ...
|
||||
null: bool = ...
|
||||
editable: bool = ...
|
||||
choices: Optional[_FieldChoices] = ...
|
||||
db_column: Optional[str]
|
||||
column: str
|
||||
error_messages: _ErrorMessagesToOverride
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||
@@ -59,7 +87,15 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
def __set__(self, instance, value: _ST) -> None: ...
|
||||
def __get__(self, instance, owner) -> _GT: ...
|
||||
# class access
|
||||
@overload
|
||||
def __get__(self: _T, instance: None, owner) -> _T: ...
|
||||
# Model instance access
|
||||
@overload
|
||||
def __get__(self, instance: Model, owner) -> _GT: ...
|
||||
# non-Model instances
|
||||
@overload
|
||||
def __get__(self: _T, instance, owner) -> _T: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def set_attributes_from_name(self, name: str) -> None: ...
|
||||
def db_type(self, connection: Any) -> str: ...
|
||||
@@ -67,8 +103,28 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
|
||||
def get_prep_value(self, value: Any) -> Any: ...
|
||||
def get_internal_type(self) -> str: ...
|
||||
def formfield(self, **kwargs) -> FormField: ...
|
||||
def save_form_data(self, instance: Model, data: Any) -> None: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
|
||||
def to_python(self, value: Any) -> Any: ...
|
||||
def clean(self, value: Any, model_instance: Optional[Model]) -> Any: ...
|
||||
def get_choices(
|
||||
self,
|
||||
include_blank: bool = ...,
|
||||
blank_choice: _Choice = ...,
|
||||
limit_choices_to: Optional[Any] = ...,
|
||||
ordering: Sequence[str] = ...,
|
||||
) -> Sequence[Union[_Choice, _ChoiceNamedGroup]]: ...
|
||||
def has_default(self) -> bool: ...
|
||||
def get_default(self) -> Any: ...
|
||||
def check(self, **kwargs: Any) -> List[checks.Error]: ...
|
||||
@property
|
||||
def validators(self) -> List[_ValidatorCallable]: ...
|
||||
def validate(self, value: Any, model_instance: Model) -> None: ...
|
||||
def run_validators(self, value: Any) -> None: ...
|
||||
def get_col(self, alias: str, output_field: Optional[Field] = ...) -> Col: ...
|
||||
@property
|
||||
def cached_col(self) -> Col: ...
|
||||
def value_from_object(self, obj: Model) -> _GT: ...
|
||||
|
||||
class IntegerField(Field[_ST, _GT]):
|
||||
_pyi_private_set_type: Union[float, int, str, Combinable]
|
||||
@@ -89,6 +145,9 @@ class FloatField(Field[_ST, _GT]):
|
||||
class DecimalField(Field[_ST, _GT]):
|
||||
_pyi_private_set_type: Union[str, float, decimal.Decimal, Combinable]
|
||||
_pyi_private_get_type: decimal.Decimal
|
||||
# attributes
|
||||
max_digits: int = ...
|
||||
decimal_places: int = ...
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable
|
||||
from typing import Any, Callable, List, Optional, Type, Union, Tuple, Iterable, overload, TypeVar
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
from django.core.files.base import File
|
||||
from django.core.files.images import ImageFile
|
||||
from django.core.files.storage import FileSystemStorage, Storage
|
||||
@@ -34,6 +33,8 @@ class FileDescriptor:
|
||||
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Union[FieldFile, FileDescriptor]: ...
|
||||
|
||||
_T = TypeVar("_T", bound="Field")
|
||||
|
||||
class FileField(Field):
|
||||
storage: Any = ...
|
||||
upload_to: Union[str, Callable] = ...
|
||||
@@ -63,6 +64,15 @@ class FileField(Field):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
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: ...
|
||||
|
||||
class ImageFileDescriptor(FileDescriptor):
|
||||
@@ -82,4 +92,13 @@ class ImageField(FileField):
|
||||
height_field: Optional[str] = ...,
|
||||
**kwargs: Any
|
||||
) -> 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: ...
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
from typing import (
|
||||
Type,
|
||||
Union,
|
||||
TypeVar,
|
||||
Any,
|
||||
Generic,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
Optional,
|
||||
Dict,
|
||||
Callable,
|
||||
Tuple,
|
||||
Sequence,
|
||||
TYPE_CHECKING,
|
||||
Iterable,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
from uuid import UUID
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Field, Model, QuerySet
|
||||
from django.db.models.expressions import Combinable
|
||||
from django.db.models.fields.mixins import FieldCacheMixin
|
||||
from django.db.models.query_utils import PathInfo, Q
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Field, Model
|
||||
from django.db.models.fields.related_descriptors import (
|
||||
ReverseManyToOneDescriptor as ReverseManyToOneDescriptor,
|
||||
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor,
|
||||
ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
|
||||
ForwardOneToOneDescriptor as ForwardOneToOneDescriptor,
|
||||
ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
|
||||
ManyToManyDescriptor as ManyToManyDescriptor,
|
||||
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor,
|
||||
ReverseManyToOneDescriptor as ReverseManyToOneDescriptor,
|
||||
)
|
||||
from django.db.models.fields.reverse_related import (
|
||||
ForeignObjectRel as ForeignObjectRel,
|
||||
ManyToManyRel as ManyToManyRel,
|
||||
ManyToOneRel as ManyToOneRel,
|
||||
OneToOneRel as OneToOneRel,
|
||||
ManyToOneRel as ManyToOneRel,
|
||||
ManyToManyRel as ManyToManyRel,
|
||||
)
|
||||
from django.db.models.query_utils import PathInfo, Q
|
||||
|
||||
from django.db.models.expressions import Combinable
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from django.db.models.manager import RelatedManager
|
||||
|
||||
_T = TypeVar("_T", bound=models.Model)
|
||||
|
||||
_F = TypeVar("_F", bound=models.Field)
|
||||
_Choice = Tuple[Any, str]
|
||||
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
||||
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||
@@ -59,16 +59,13 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
|
||||
one_to_one: bool = ...
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
def related_model(self) -> Union[Type[Model], str]: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
opts: Any = ...
|
||||
def deconstruct(self) -> Tuple[Optional[str], str, List[Any], Dict[str, str]]: ...
|
||||
@property
|
||||
def related_model(self) -> Type[Model]: ...
|
||||
def get_forward_related_filter(self, obj: Model) -> Dict[str, Union[int, UUID]]: ...
|
||||
def get_reverse_related_filter(self, obj: Model) -> Q: ...
|
||||
@property
|
||||
def swappable_setting(self) -> Optional[str]: ...
|
||||
name: Any = ...
|
||||
verbose_name: Any = ...
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def do_related_class(self, other: Type[Model], cls: Type[Model]) -> None: ...
|
||||
def get_limit_choices_to(self) -> Dict[str, int]: ...
|
||||
@@ -76,16 +73,16 @@ class RelatedField(FieldCacheMixin, Field[_ST, _GT]):
|
||||
@property
|
||||
def target_field(self) -> Field: ...
|
||||
|
||||
class ForeignObject(RelatedField):
|
||||
class ForeignObject(RelatedField[_ST, _GT]):
|
||||
def __init__(
|
||||
self,
|
||||
to: Union[Type[Model], str],
|
||||
on_delete: Callable[..., None],
|
||||
from_fields: Sequence[str],
|
||||
to_fields: Sequence[str],
|
||||
rel: None = ...,
|
||||
rel: Optional[ForeignObjectRel] = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: None = ...,
|
||||
related_query_name: Optional[str] = ...,
|
||||
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
|
||||
parent_link: bool = ...,
|
||||
db_constraint: bool = ...,
|
||||
@@ -109,7 +106,7 @@ class ForeignObject(RelatedField):
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
|
||||
class ForeignKey(RelatedField[_ST, _GT]):
|
||||
class ForeignKey(ForeignObject[_ST, _GT]):
|
||||
_pyi_private_set_type: Union[Any, Combinable]
|
||||
_pyi_private_get_type: Any
|
||||
def __init__(
|
||||
@@ -144,6 +141,15 @@ class ForeignKey(RelatedField[_ST, _GT]):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
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]):
|
||||
_pyi_private_set_type: Union[Any, Combinable]
|
||||
@@ -180,19 +186,24 @@ class OneToOneField(RelatedField[_ST, _GT]):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
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]):
|
||||
_pyi_private_set_type: Sequence[Any]
|
||||
_pyi_private_get_type: RelatedManager[Any]
|
||||
|
||||
many_to_many: bool = ...
|
||||
many_to_one: bool = ...
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
rel_class: Any = ...
|
||||
description: Any = ...
|
||||
has_null_arg: Any = ...
|
||||
swappable: Any = ...
|
||||
swappable: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
to: Union[Type[_T], str],
|
||||
@@ -227,20 +238,23 @@ class ManyToManyField(RelatedField[_ST, _GT]):
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
def deconstruct(self) -> Tuple[Optional[str], str, List[Any], Dict[str, str]]: ...
|
||||
# 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_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
||||
m2m_db_table: Any = ...
|
||||
m2m_column_name: Any = ...
|
||||
m2m_reverse_name: Any = ...
|
||||
m2m_field_name: Any = ...
|
||||
m2m_reverse_field_name: Any = ...
|
||||
m2m_target_field_name: Any = ...
|
||||
m2m_reverse_target_field_name: Any = ...
|
||||
def contribute_to_related_class(self, cls: Type[Model], related: RelatedField) -> None: ...
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def value_from_object(self, obj: Model) -> List[Model]: ...
|
||||
def save_form_data(self, instance: Model, data: QuerySet) -> None: ...
|
||||
def m2m_db_table(self) -> str: ...
|
||||
def m2m_column_name(self) -> str: ...
|
||||
def m2m_reverse_name(self) -> str: ...
|
||||
def m2m_reverse_field_name(self) -> str: ...
|
||||
def m2m_target_field_name(self) -> str: ...
|
||||
def m2m_reverse_target_field_name(self) -> str: ...
|
||||
|
||||
def create_many_to_many_intermediary_model(field: Type[Field], klass: Type[Model]) -> Type[Model]: ...
|
||||
|
||||
@@ -10,13 +10,10 @@ from django.db.models.sql.where import WhereNode
|
||||
from .mixins import FieldCacheMixin
|
||||
|
||||
class ForeignObjectRel(FieldCacheMixin):
|
||||
hidden: bool
|
||||
many_to_many: bool
|
||||
many_to_one: bool
|
||||
name: str
|
||||
one_to_many: bool
|
||||
one_to_one: bool
|
||||
related_model: Type[Model]
|
||||
auto_created: bool = ...
|
||||
concrete: bool = ...
|
||||
editable: bool = ...
|
||||
@@ -43,6 +40,12 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
on_delete: Optional[Callable] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def hidden(self) -> bool: ...
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@property
|
||||
def related_model(self) -> Type[Model]: ...
|
||||
@property
|
||||
def remote_field(self) -> RelatedField: ...
|
||||
@property
|
||||
def target_field(self) -> AutoField: ...
|
||||
@@ -63,22 +66,6 @@ class ForeignObjectRel(FieldCacheMixin):
|
||||
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
|
||||
|
||||
class ManyToOneRel(ForeignObjectRel):
|
||||
field: RelatedField
|
||||
hidden: bool
|
||||
limit_choices_to: Any
|
||||
many_to_many: bool
|
||||
many_to_one: bool
|
||||
model: Union[Type[Model], str]
|
||||
multiple: bool
|
||||
name: str
|
||||
on_delete: Callable
|
||||
one_to_many: bool
|
||||
one_to_one: bool
|
||||
parent_link: bool
|
||||
related_model: Type[Model]
|
||||
related_name: Optional[str]
|
||||
related_query_name: Optional[str]
|
||||
symmetrical: bool
|
||||
def __init__(
|
||||
self,
|
||||
field: ForeignKey,
|
||||
@@ -91,25 +78,8 @@ class ManyToOneRel(ForeignObjectRel):
|
||||
on_delete: Callable = ...,
|
||||
) -> None: ...
|
||||
def get_related_field(self) -> Field: ...
|
||||
def set_field_name(self) -> None: ...
|
||||
|
||||
class OneToOneRel(ManyToOneRel):
|
||||
field_name: Optional[str]
|
||||
hidden: bool
|
||||
limit_choices_to: Dict[str, str]
|
||||
many_to_many: bool
|
||||
many_to_one: bool
|
||||
model: Union[Type[Model], str]
|
||||
name: str
|
||||
on_delete: Callable
|
||||
one_to_many: bool
|
||||
one_to_one: bool
|
||||
parent_link: bool
|
||||
related_model: Type[Model]
|
||||
related_name: Optional[str]
|
||||
related_query_name: Optional[str]
|
||||
symmetrical: bool
|
||||
multiple: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
field: OneToOneField,
|
||||
@@ -123,14 +93,8 @@ class OneToOneRel(ManyToOneRel):
|
||||
) -> None: ...
|
||||
|
||||
class ManyToManyRel(ForeignObjectRel):
|
||||
field_name: None
|
||||
multiple: bool
|
||||
name: str
|
||||
parent_link: bool
|
||||
related_model: Type[Model]
|
||||
through: Optional[Union[Type[Model], str]] = ...
|
||||
through_fields: Optional[Tuple[str, str]] = ...
|
||||
symmetrical: bool = ...
|
||||
db_constraint: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -17,6 +17,7 @@ from .text import (
|
||||
StrIndex as StrIndex,
|
||||
Replace as Replace,
|
||||
Substr as Substr,
|
||||
Reverse as Reverse,
|
||||
)
|
||||
|
||||
from .window import (
|
||||
@@ -44,6 +45,7 @@ from .datetime import (
|
||||
ExtractWeek as ExtractWeek,
|
||||
ExtractWeekDay as ExtractWeekDay,
|
||||
ExtractYear as ExtractYear,
|
||||
ExtractIsoYear as ExtractIsoYear,
|
||||
Trunc as Trunc,
|
||||
TruncDate as TruncDate,
|
||||
TruncDay as TruncDay,
|
||||
@@ -58,4 +60,28 @@ from .datetime import (
|
||||
Now as Now,
|
||||
)
|
||||
|
||||
from .comparison import Coalesce as Coalesce, Greatest as Greatest, Least as Least, Cast as Cast
|
||||
from .comparison import Coalesce as Coalesce, Greatest as Greatest, Least as Least, Cast as Cast, NullIf as NullIf
|
||||
|
||||
from .math import (
|
||||
Abs as Abs,
|
||||
ACos as ACos,
|
||||
ASin as ASin,
|
||||
ATan as ATan,
|
||||
ATan2 as ATan2,
|
||||
Ceil as Ceil,
|
||||
Cos as Cos,
|
||||
Cot as Cot,
|
||||
Degrees as Degrees,
|
||||
Floor as Floor,
|
||||
Exp as Exp,
|
||||
Ln as Ln,
|
||||
Log as Log,
|
||||
Mod as Mod,
|
||||
Pi as Pi,
|
||||
Power as Power,
|
||||
Radians as Radians,
|
||||
Round as Round,
|
||||
Sin as Sin,
|
||||
Sqrt as Sqrt,
|
||||
Tan as Tan,
|
||||
)
|
||||
|
||||
@@ -9,3 +9,4 @@ class Cast(Func):
|
||||
class Coalesce(Func): ...
|
||||
class Greatest(Func): ...
|
||||
class Least(Func): ...
|
||||
class NullIf(Func): ...
|
||||
|
||||
@@ -8,6 +8,7 @@ class TimezoneMixin:
|
||||
|
||||
class Extract(TimezoneMixin, Transform): ...
|
||||
class ExtractYear(Extract): ...
|
||||
class ExtractIsoYear(Extract): ...
|
||||
class ExtractMonth(Extract): ...
|
||||
class ExtractDay(Extract): ...
|
||||
class ExtractWeek(Extract): ...
|
||||
|
||||
25
django-stubs/db/models/functions/math.pyi
Normal file
25
django-stubs/db/models/functions/math.pyi
Normal file
@@ -0,0 +1,25 @@
|
||||
from django.db.models.expressions import Func
|
||||
from django.db.models.functions.mixins import FixDecimalInputMixin, NumericOutputFieldMixin
|
||||
from django.db.models.lookups import Transform
|
||||
|
||||
class Abs(Transform): ...
|
||||
class ACos(NumericOutputFieldMixin, Transform): ...
|
||||
class ASin(NumericOutputFieldMixin, Transform): ...
|
||||
class ATan(NumericOutputFieldMixin, Transform): ...
|
||||
class ATan2(NumericOutputFieldMixin, Func): ...
|
||||
class Ceil(Transform): ...
|
||||
class Cos(NumericOutputFieldMixin, Transform): ...
|
||||
class Cot(NumericOutputFieldMixin, Transform): ...
|
||||
class Degrees(NumericOutputFieldMixin, Transform): ...
|
||||
class Exp(NumericOutputFieldMixin, Transform): ...
|
||||
class Floor(Transform): ...
|
||||
class Ln(NumericOutputFieldMixin, Transform): ...
|
||||
class Log(FixDecimalInputMixin, NumericOutputFieldMixin, Func): ...
|
||||
class Mod(FixDecimalInputMixin, NumericOutputFieldMixin, Func): ...
|
||||
class Pi(NumericOutputFieldMixin, Func): ...
|
||||
class Power(NumericOutputFieldMixin, Func): ...
|
||||
class Radians(NumericOutputFieldMixin, Transform): ...
|
||||
class Round(Transform): ...
|
||||
class Sin(NumericOutputFieldMixin, Transform): ...
|
||||
class Sqrt(NumericOutputFieldMixin, Transform): ...
|
||||
class Tan(NumericOutputFieldMixin, Transform): ...
|
||||
3
django-stubs/db/models/functions/mixins.pyi
Normal file
3
django-stubs/db/models/functions/mixins.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
class FixDecimalInputMixin: ...
|
||||
class FixDurationInputMixin: ...
|
||||
class NumericOutputFieldMixin: ...
|
||||
@@ -25,13 +25,15 @@ class Length(Transform): ...
|
||||
class Lower(Transform): ...
|
||||
|
||||
class LPad(BytesToCharFieldConversionMixin, Func):
|
||||
def __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ...
|
||||
def __init__(
|
||||
self, expression: str, length: Optional[Union[Length, int]], fill_text: Value = ..., **extra: Any
|
||||
) -> None: ...
|
||||
|
||||
class LTrim(Transform): ...
|
||||
class Ord(Transform): ...
|
||||
|
||||
class Repeat(BytesToCharFieldConversionMixin, Func):
|
||||
def __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ...
|
||||
def __init__(self, expression: Union[Value, str], number: Optional[Union[Length, int]], **extra: Any) -> None: ...
|
||||
|
||||
class Replace(Func):
|
||||
def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ...
|
||||
@@ -52,3 +54,4 @@ class Substr(Func):
|
||||
|
||||
class Trim(Transform): ...
|
||||
class Upper(Transform): ...
|
||||
class Reverse(Transform): ...
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, List, Optional, Sequence, Tuple, Type
|
||||
|
||||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||
from django.db.backends.ddl_references import Statement
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query_utils import Q
|
||||
|
||||
class Index:
|
||||
model: Type[Model]
|
||||
suffix: str = ...
|
||||
max_name_length: int = ...
|
||||
fields: List[str] = ...
|
||||
fields_orders: List[Tuple[str, str]] = ...
|
||||
fields: Sequence[str] = ...
|
||||
fields_orders: Sequence[Tuple[str, str]] = ...
|
||||
name: str = ...
|
||||
db_tablespace: Optional[str] = ...
|
||||
def __init__(self, *, fields: Any = ..., name: Optional[Any] = ..., db_tablespace: Optional[Any] = ...) -> None: ...
|
||||
opclasses: Sequence[str] = ...
|
||||
condition: Optional[Q] = ...
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
fields: Sequence[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
db_tablespace: Optional[str] = ...,
|
||||
opclasses: Sequence[str] = ...,
|
||||
condition: Optional[Q] = ...
|
||||
) -> None: ...
|
||||
def check_name(self) -> List[str]: ...
|
||||
def create_sql(
|
||||
self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ...
|
||||
) -> Statement: ...
|
||||
def remove_sql(self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor) -> str: ...
|
||||
def deconstruct(self) -> Tuple[str, Tuple, Dict[str, Union[List[str], str]]]: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def clone(self) -> Index: ...
|
||||
def set_name_with_model(self, model: Type[Model]) -> None: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union, Iterable
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple, Type, Union, Mapping
|
||||
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.models.expressions import Combinable, Expression, Func
|
||||
@@ -10,22 +10,21 @@ from django.db.models.sql.query import Query
|
||||
from django.utils.datastructures import OrderedSet
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
from django.db.models import lookups
|
||||
from django.db.models.fields import TextField, related_lookups, Field
|
||||
from django.db.models.fields import TextField, related_lookups
|
||||
|
||||
class Lookup:
|
||||
lookup_name: Any = ...
|
||||
lookup_name: str = ...
|
||||
prepare_rhs: bool = ...
|
||||
can_use_none_as_rhs: bool = ...
|
||||
lhs: Any = ...
|
||||
rhs: Any = ...
|
||||
bilateral_transforms: Any = ...
|
||||
bilateral_transforms: List[Type[Transform]] = ...
|
||||
def __init__(self, lhs: Union[Expression, TextField, related_lookups.MultiColSource], rhs: Any) -> None: ...
|
||||
def apply_bilateral_transforms(self, value: Expression) -> Transform: ...
|
||||
def batch_process_rhs(
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, rhs: Optional[OrderedSet] = ...
|
||||
) -> Tuple[List[str], List[str]]: ...
|
||||
def get_source_expressions(self) -> List[Expression]: ...
|
||||
lhs: Any = ...
|
||||
def set_source_expressions(self, new_exprs: List[Expression]) -> None: ...
|
||||
def get_prep_lookup(self) -> Any: ...
|
||||
def get_db_prep_lookup(self, value: Union[int, str], connection: DatabaseWrapper) -> Tuple[str, List[SafeText]]: ...
|
||||
@@ -36,20 +35,16 @@ class Lookup:
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper
|
||||
) -> Tuple[str, Union[List[Union[int, str]], Tuple[int, int]]]: ...
|
||||
def rhs_is_direct_value(self) -> bool: ...
|
||||
def relabeled_clone(
|
||||
self, relabels: Union[Dict[Optional[str], str], OrderedDict]
|
||||
) -> Union[BuiltinLookup, FieldGetDbPrepValueMixin]: ...
|
||||
def relabeled_clone(self, relabels: Mapping[str, str]) -> Union[BuiltinLookup, FieldGetDbPrepValueMixin]: ...
|
||||
def get_group_by_cols(self) -> List[Expression]: ...
|
||||
def as_sql(self, compiler: Any, connection: Any) -> None: ...
|
||||
def as_sql(self, compiler: Any, connection: Any) -> Any: ...
|
||||
def contains_aggregate(self) -> bool: ...
|
||||
def contains_over_clause(self) -> bool: ...
|
||||
@property
|
||||
def is_summary(self): ...
|
||||
def is_summary(self) -> bool: ...
|
||||
|
||||
class Transform(RegisterLookupMixin, Func):
|
||||
bilateral: bool = ...
|
||||
arity: int = ...
|
||||
output_field: Field
|
||||
@property
|
||||
def lhs(self) -> Expression: ...
|
||||
def get_bilateral_transforms(self) -> List[Type[Transform]]: ...
|
||||
@@ -61,122 +56,51 @@ class FieldGetDbPrepValueMixin:
|
||||
get_db_prep_lookup_value_is_iterable: bool = ...
|
||||
|
||||
class FieldGetDbPrepValueIterableMixin(FieldGetDbPrepValueMixin):
|
||||
get_db_prep_lookup_value_is_iterable: bool = ...
|
||||
def get_prep_lookup(self) -> Iterable[Any]: ...
|
||||
def resolve_expression_parameter(
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, sql: str, param: Optional[Union[Combinable, int, str]]
|
||||
) -> Tuple[str, List[None]]: ...
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, sql: str, param: Any
|
||||
) -> Any: ...
|
||||
|
||||
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Type[lookups.Transform]]
|
||||
lookup_name: str = ...
|
||||
|
||||
class IExact(BuiltinLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Type[lookups.Transform]]
|
||||
lookup_name: str = ...
|
||||
class Exact(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||
class IExact(BuiltinLookup): ...
|
||||
class GreaterThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||
class GreaterThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||
class LessThan(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||
class LessThanOrEqual(FieldGetDbPrepValueMixin, BuiltinLookup): ...
|
||||
|
||||
class IntegerFieldFloatRounding:
|
||||
rhs: Any = ...
|
||||
def get_prep_lookup(self) -> Union[Combinable, Query, int]: ...
|
||||
def get_prep_lookup(self) -> Any: ...
|
||||
|
||||
class IntegerGreaterThanOrEqual(IntegerFieldFloatRounding, GreaterThanOrEqual): ...
|
||||
class IntegerLessThan(IntegerFieldFloatRounding, LessThan): ...
|
||||
|
||||
class In(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Type[lookups.Transform]]
|
||||
lookup_name: str = ...
|
||||
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
|
||||
def split_parameter_list_as_sql(self, compiler: Any, connection: Any): ...
|
||||
|
||||
class PatternLookup(BuiltinLookup):
|
||||
param_pattern: str = ...
|
||||
prepare_rhs: bool = ...
|
||||
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
|
||||
|
||||
class Contains(PatternLookup):
|
||||
bilateral_transforms: List[Type[lookups.Transform]]
|
||||
lookup_name: str = ...
|
||||
|
||||
class IContains(Contains):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class StartsWith(PatternLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
param_pattern: str = ...
|
||||
|
||||
class IStartsWith(StartsWith):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class EndsWith(PatternLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
param_pattern: str = ...
|
||||
|
||||
class IEndsWith(EndsWith):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup):
|
||||
bilateral_transforms: List[Type[lookups.Transform]]
|
||||
lookup_name: str = ...
|
||||
|
||||
class IsNull(BuiltinLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
prepare_rhs: bool = ...
|
||||
|
||||
class Regex(BuiltinLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
prepare_rhs: bool = ...
|
||||
|
||||
class IRegex(Regex):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
class Contains(PatternLookup): ...
|
||||
class IContains(Contains): ...
|
||||
class StartsWith(PatternLookup): ...
|
||||
class IStartsWith(StartsWith): ...
|
||||
class EndsWith(PatternLookup): ...
|
||||
class IEndsWith(EndsWith): ...
|
||||
class Range(FieldGetDbPrepValueIterableMixin, BuiltinLookup): ...
|
||||
class IsNull(BuiltinLookup): ...
|
||||
class Regex(BuiltinLookup): ...
|
||||
class IRegex(Regex): ...
|
||||
|
||||
class YearLookup(Lookup):
|
||||
def year_lookup_bounds(self, connection: DatabaseWrapper, year: int) -> List[str]: ...
|
||||
|
||||
class YearComparisonLookup(YearLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
def get_rhs_op(self, connection: DatabaseWrapper, rhs: str) -> str: ...
|
||||
def get_bound(self, start: datetime, finish: datetime) -> Any: ...
|
||||
|
||||
class YearExact(YearLookup, Exact):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class YearGt(YearComparisonLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class YearGte(YearComparisonLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class YearLt(YearComparisonLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
|
||||
class YearLte(YearComparisonLookup):
|
||||
bilateral_transforms: List[Any]
|
||||
lookup_name: str = ...
|
||||
class YearExact(YearLookup, Exact): ...
|
||||
class YearGt(YearComparisonLookup): ...
|
||||
class YearGte(YearComparisonLookup): ...
|
||||
class YearLt(YearComparisonLookup): ...
|
||||
class YearLte(YearComparisonLookup): ...
|
||||
|
||||
@@ -5,13 +5,13 @@ from django.db.models.query import QuerySet
|
||||
|
||||
_T = TypeVar("_T", bound=Model, covariant=True)
|
||||
|
||||
class BaseManager(QuerySet[_T, _T]):
|
||||
class BaseManager(QuerySet[_T]):
|
||||
creation_counter: int = ...
|
||||
auto_created: bool = ...
|
||||
use_in_migrations: bool = ...
|
||||
def __new__(cls: Type[BaseManager], *args: Any, **kwargs: Any) -> BaseManager: ...
|
||||
model: Optional[Any] = ...
|
||||
name: Optional[Any] = ...
|
||||
name: str = ...
|
||||
model: Type[Model] = ...
|
||||
db: str
|
||||
def __init__(self) -> None: ...
|
||||
def deconstruct(self) -> Tuple[bool, str, None, Tuple, Dict[str, int]]: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
@@ -21,7 +21,7 @@ class BaseManager(QuerySet[_T, _T]):
|
||||
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
|
||||
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
|
||||
def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ...
|
||||
def get_queryset(self) -> QuerySet[_T, _T]: ...
|
||||
def get_queryset(self) -> QuerySet[_T]: ...
|
||||
|
||||
class Manager(BaseManager[_T]): ...
|
||||
|
||||
@@ -35,8 +35,4 @@ class ManagerDescriptor:
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Manager: ...
|
||||
|
||||
class EmptyManager(Manager):
|
||||
creation_counter: int
|
||||
name: None
|
||||
model: Optional[Type[Model]] = ...
|
||||
def __init__(self, model: Type[Model]) -> None: ...
|
||||
def get_queryset(self) -> QuerySet: ...
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user