mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 14:01:56 +08:00
Compare commits
100 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
304cb19de6 | ||
|
|
c57f4f7152 | ||
|
|
8a826fee1e | ||
|
|
37d85c2ca6 | ||
|
|
71fb0432f3 | ||
|
|
9288c34648 | ||
|
|
70050f28b9 | ||
|
|
4338c17970 | ||
|
|
91f789c38c | ||
|
|
0f5b45fba1 | ||
|
|
5b455b729a | ||
|
|
5c6be7ad12 | ||
|
|
5d0ee40ada | ||
|
|
77f15d7478 | ||
|
|
4f83d8d1bb | ||
|
|
b1a04d2f7d | ||
|
|
7c57143310 |
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
|
||||
45
README.md
45
README.md
@@ -7,7 +7,7 @@
|
||||
|
||||
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,24 +31,33 @@ 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)
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
black
|
||||
pytest-mypy-plugins
|
||||
pytest-mypy-plugins==1.0.3
|
||||
flake8
|
||||
isort==4.3.4
|
||||
-e .
|
||||
|
||||
1
django-sources
Submodule
1
django-sources
Submodule
Submodule django-sources added at 4d6449e125
@@ -1,7 +1,12 @@
|
||||
from typing import Any
|
||||
from typing import Any, NamedTuple
|
||||
from .utils.version import get_version as get_version
|
||||
|
||||
VERSION: Any
|
||||
__version__: str
|
||||
|
||||
def setup(set_prefix: bool = ...) -> None: ...
|
||||
|
||||
# Used by mypy_django_plugin when returning a QuerySet row that is a NamedTuple where the field names are unknown
|
||||
class _NamedTupleAnyAttr(NamedTuple):
|
||||
def __getattr__(self, item: str) -> Any: ...
|
||||
def __setattr__(self, item: str, value: Any) -> None: ...
|
||||
|
||||
@@ -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: ...
|
||||
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]: ...
|
||||
# it's not possible to support it in plugin properly now
|
||||
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Any]]: ...
|
||||
def get_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] = ...
|
||||
@@ -1,25 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
class SimpleAdminConfig(AppConfig):
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: Any
|
||||
path: str
|
||||
default_site: str = ...
|
||||
name: str = ...
|
||||
verbose_name: Any = ...
|
||||
def ready(self) -> None: ...
|
||||
|
||||
class AdminConfig(SimpleAdminConfig):
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: Any
|
||||
name: str
|
||||
path: str
|
||||
def ready(self) -> None: ...
|
||||
class AdminConfig(SimpleAdminConfig): ...
|
||||
|
||||
@@ -1,33 +1,7 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class AdminAuthenticationForm(AuthenticationForm):
|
||||
auto_id: str
|
||||
data: Dict[str, str]
|
||||
empty_permitted: bool
|
||||
error_class: type
|
||||
fields: Dict[Any, Any]
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
request: None
|
||||
user_cache: None
|
||||
error_messages: Any = ...
|
||||
required_css_class: str = ...
|
||||
def confirm_login_allowed(self, user: User) -> None: ...
|
||||
|
||||
class AdminPasswordChangeForm(PasswordChangeForm):
|
||||
auto_id: str
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: type
|
||||
fields: Dict[Any, Any]
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
user: Any
|
||||
required_css_class: str = ...
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
import collections
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Type
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
|
||||
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||
from django.db.models.fields import AutoField
|
||||
from django.forms.utils import ErrorDict, ErrorList
|
||||
from django.forms.boundfield import BoundField
|
||||
from django.forms.utils import ErrorDict
|
||||
from django.forms.widgets import Media, Widget
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
from django.forms.boundfield import BoundField
|
||||
from django import forms
|
||||
from django.db.models.fields import AutoField
|
||||
|
||||
ACTION_CHECKBOX_NAME: str
|
||||
|
||||
class ActionForm(forms.Form):
|
||||
auto_id: None
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
action: Any = ...
|
||||
select_across: Any = ...
|
||||
|
||||
@@ -36,8 +26,8 @@ class AdminForm:
|
||||
form: AdminPasswordChangeForm,
|
||||
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
||||
prepopulated_fields: Dict[Any, Any],
|
||||
readonly_fields: None = ...,
|
||||
model_admin: None = ...,
|
||||
readonly_fields: Any = ...,
|
||||
model_admin: Any = ...,
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[Fieldset]: ...
|
||||
@property
|
||||
@@ -137,7 +127,6 @@ class InlineAdminFormSet:
|
||||
|
||||
class InlineAdminForm(AdminForm):
|
||||
formset: Any = ...
|
||||
model_admin: Any = ...
|
||||
original: Any = ...
|
||||
show_url: Any = ...
|
||||
absolute_url: Any = ...
|
||||
@@ -152,7 +141,6 @@ class InlineAdminForm(AdminForm):
|
||||
model_admin: Optional[Any] = ...,
|
||||
view_on_site_url: Optional[Any] = ...,
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[InlineFieldset]: ...
|
||||
def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ...
|
||||
def pk_field(self) -> AdminField: ...
|
||||
def fk_field(self) -> AdminField: ...
|
||||
@@ -162,9 +150,6 @@ class InlineAdminForm(AdminForm):
|
||||
class InlineFieldset(Fieldset):
|
||||
formset: Any = ...
|
||||
def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ...
|
||||
def __iter__(self) -> Iterator[Fieldline]: ...
|
||||
|
||||
class AdminErrorList(forms.utils.ErrorList):
|
||||
data: List[Any]
|
||||
error_class: str
|
||||
def __init__(self, form: Any, inline_formsets: Any) -> None: ...
|
||||
|
||||
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: ...
|
||||
@@ -1,18 +1,10 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models.query import QuerySet
|
||||
from django.http.response import JsonResponse
|
||||
from django.views.generic.list import BaseListView
|
||||
|
||||
class AutocompleteJsonView(BaseListView):
|
||||
paginate_by: int = ...
|
||||
model_admin: ModelAdmin = ...
|
||||
term: Any = ...
|
||||
paginator_class: Any = ...
|
||||
object_list: Any = ...
|
||||
def get(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> JsonResponse: ...
|
||||
def get_paginator(self, *args: Any, **kwargs: Any) -> Paginator: ...
|
||||
def get_queryset(self) -> QuerySet: ...
|
||||
def has_perm(self, request: WSGIRequest, obj: None = ...) -> bool: ...
|
||||
|
||||
@@ -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,18 +1,12 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, 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 Media
|
||||
|
||||
from django import forms
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, ManyToManyRel
|
||||
from django.db.models.query_utils import Q
|
||||
from django.forms.fields import Field
|
||||
from django.forms.widgets import ChoiceWidget, Media, Widget, DateTimeBaseInput
|
||||
from django.http.request import QueryDict
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
|
||||
class FilteredSelectMultiple(forms.SelectMultiple):
|
||||
@property
|
||||
@@ -20,111 +14,36 @@ class FilteredSelectMultiple(forms.SelectMultiple):
|
||||
verbose_name: Any = ...
|
||||
is_stacked: Any = ...
|
||||
def __init__(self, verbose_name: str, is_stacked: bool, attrs: None = ..., choices: Tuple = ...) -> None: ...
|
||||
def get_context(
|
||||
self, name: str, value: Union[List[Any], str], attrs: Optional[Dict[str, str]]
|
||||
) -> Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[str, Union[int, str]],
|
||||
List[Tuple[None, List[Dict[str, Union[Dict[Any, Any], int, str]]], int]],
|
||||
bool,
|
||||
str,
|
||||
],
|
||||
],
|
||||
Dict[str, Union[Dict[str, Union[int, str]], List[str], bool, str]],
|
||||
],
|
||||
]: ...
|
||||
|
||||
class AdminDateWidget(forms.DateInput):
|
||||
attrs: Dict[str, str]
|
||||
input_type: str
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ...
|
||||
|
||||
class AdminTimeWidget(forms.TimeInput):
|
||||
attrs: Dict[str, str]
|
||||
input_type: str
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ...
|
||||
|
||||
class AdminSplitDateTime(forms.SplitDateTimeWidget):
|
||||
attrs: Dict[Any, Any]
|
||||
widgets: List[DateTimeBaseInput]
|
||||
template_name: str = ...
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
def get_context(
|
||||
self, name: str, value: Optional[Union[List[str], datetime]], attrs: Optional[Dict[str, Union[bool, str]]]
|
||||
) -> Dict[
|
||||
str,
|
||||
Union[
|
||||
Dict[
|
||||
str,
|
||||
Optional[
|
||||
Union[
|
||||
Dict[str, Union[bool, str]],
|
||||
List[Dict[str, Optional[Union[Dict[str, Union[bool, str]], bool, str]]]],
|
||||
bool,
|
||||
str,
|
||||
]
|
||||
],
|
||||
],
|
||||
str,
|
||||
],
|
||||
]: ...
|
||||
class AdminSplitDateTime(forms.SplitDateTimeWidget): ...
|
||||
class AdminRadioSelect(forms.RadioSelect): ...
|
||||
class AdminFileWidget(forms.ClearableFileInput): ...
|
||||
|
||||
class AdminRadioSelect(forms.RadioSelect):
|
||||
attrs: Dict[str, str]
|
||||
template_name: str = ...
|
||||
|
||||
class AdminFileWidget(forms.ClearableFileInput):
|
||||
attrs: Dict[Any, Any]
|
||||
template_name: str = ...
|
||||
|
||||
def url_params_from_lookup_dict(
|
||||
lookups: Union[
|
||||
Dict[str, Callable], Dict[str, List[str]], Dict[str, Tuple[str, str]], Dict[str, bool], Dict[str, str], Q
|
||||
]
|
||||
) -> Dict[str, str]: ...
|
||||
def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ...
|
||||
|
||||
class ForeignKeyRawIdWidget(forms.TextInput):
|
||||
attrs: Dict[Any, Any]
|
||||
template_name: str = ...
|
||||
rel: ManyToOneRel = ...
|
||||
admin_site: AdminSite = ...
|
||||
db: None = ...
|
||||
def __init__(self, rel: ForeignObjectRel, admin_site: AdminSite, attrs: None = ..., using: None = ...) -> None: ...
|
||||
def get_context(
|
||||
self, name: str, value: Optional[Union[List[int], int, str, UUID]], attrs: Optional[Dict[str, Union[bool, str]]]
|
||||
) -> Dict[str, Union[Dict[str, Optional[Union[Dict[str, Union[bool, str]], bool, str]]], str]]: ...
|
||||
def base_url_parameters(self) -> Dict[str, str]: ...
|
||||
def url_parameters(self) -> Dict[str, str]: ...
|
||||
def label_and_url_for_value(self, value: Union[int, str, UUID]) -> Tuple[str, str]: ...
|
||||
|
||||
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
|
||||
admin_site: AdminSite
|
||||
attrs: Dict[Any, Any]
|
||||
db: None
|
||||
rel: ManyToManyRel
|
||||
template_name: str = ...
|
||||
def get_context(
|
||||
self, name: str, value: Optional[List[int]], attrs: Optional[Dict[str, str]]
|
||||
) -> Dict[str, Union[Dict[str, Union[Dict[str, str], bool, str]], str]]: ...
|
||||
def url_parameters(self) -> Dict[Any, Any]: ...
|
||||
def label_and_url_for_value(self, value: List[int]) -> Tuple[str, str]: ...
|
||||
def value_from_datadict(self, data: QueryDict, files: MultiValueDict, name: str) -> None: ...
|
||||
def format_value(self, value: Optional[List[int]]) -> str: ...
|
||||
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ...
|
||||
|
||||
class RelatedFieldWidgetWrapper(forms.Widget):
|
||||
template_name: str = ...
|
||||
needs_multipart_form: bool = ...
|
||||
attrs: Dict[Any, Any] = ...
|
||||
choices: ModelChoiceIterator = ...
|
||||
widget: AutocompleteSelect = ...
|
||||
widget: forms.Widget = ...
|
||||
rel: ManyToOneRel = ...
|
||||
can_add_related: bool = ...
|
||||
can_change_related: bool = ...
|
||||
@@ -133,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] = ...,
|
||||
@@ -141,54 +60,22 @@ class RelatedFieldWidgetWrapper(forms.Widget):
|
||||
can_delete_related: bool = ...,
|
||||
can_view_related: bool = ...,
|
||||
) -> None: ...
|
||||
def __deepcopy__(
|
||||
self, memo: Dict[int, Union[List[Union[Field, Widget]], OrderedDict, Field, Widget]]
|
||||
) -> RelatedFieldWidgetWrapper: ...
|
||||
@property
|
||||
def is_hidden(self) -> bool: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ...
|
||||
def get_context(
|
||||
self, name: str, value: Optional[Union[int, str]], attrs: Optional[Dict[str, Union[bool, str]]]
|
||||
) -> Dict[str, Union[bool, str]]: ...
|
||||
def value_from_datadict(
|
||||
self, data: QueryDict, files: MultiValueDict, name: str
|
||||
) -> Optional[Union[List[str], str]]: ...
|
||||
def value_omitted_from_data(self, data: Dict[Any, Any], files: Dict[Any, Any], name: str) -> bool: ...
|
||||
def id_for_label(self, id_: str) -> str: ...
|
||||
|
||||
class AdminTextareaWidget(forms.Textarea):
|
||||
attrs: Dict[str, str]
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
class AdminTextInputWidget(forms.TextInput):
|
||||
attrs: Dict[str, str]
|
||||
input_type: str
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
class AdminEmailInputWidget(forms.EmailInput):
|
||||
attrs: Dict[str, str]
|
||||
input_type: str
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
class AdminURLFieldWidget(forms.URLInput):
|
||||
attrs: Dict[str, str]
|
||||
input_type: str
|
||||
template_name: str = ...
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
def get_context(
|
||||
self, name: str, value: Optional[str], attrs: Optional[Dict[str, str]]
|
||||
) -> Dict[str, Union[Dict[str, Optional[Union[Dict[str, str], bool, str]]], str]]: ...
|
||||
class AdminTextareaWidget(forms.Textarea): ...
|
||||
class AdminTextInputWidget(forms.TextInput): ...
|
||||
class AdminEmailInputWidget(forms.EmailInput): ...
|
||||
class AdminURLFieldWidget(forms.URLInput): ...
|
||||
|
||||
class AdminIntegerFieldWidget(forms.NumberInput):
|
||||
attrs: Dict[str, str]
|
||||
input_type: str
|
||||
class_name: str = ...
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
|
||||
class_name: str = ...
|
||||
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
|
||||
|
||||
class AdminUUIDInputWidget(forms.TextInput):
|
||||
def __init__(self, attrs: Optional[Dict[str, str]] = ...) -> None: ...
|
||||
|
||||
SELECT2_TRANSLATIONS: Any
|
||||
|
||||
@@ -208,12 +95,6 @@ class AutocompleteMixin:
|
||||
using: None = ...,
|
||||
) -> None: ...
|
||||
def get_url(self) -> str: ...
|
||||
def build_attrs(
|
||||
self, base_attrs: Dict[str, str], extra_attrs: Optional[Dict[str, Union[bool, str]]] = ...
|
||||
) -> Dict[str, Union[bool, str]]: ...
|
||||
def optgroups(
|
||||
self, name: str, value: List[str], attr: Dict[str, Union[bool, str]] = ...
|
||||
) -> List[Tuple[None, List[Dict[str, Union[Dict[str, bool], Set[str], int, str]]], int]]: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
|
||||
|
||||
@@ -1,55 +1,18 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
from typing import Any
|
||||
|
||||
from django.contrib.auth.models import User, Group
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields.related import ManyToManyField
|
||||
from django.db.models.options import Options
|
||||
from django.forms.models import ModelMultipleChoiceField
|
||||
from django.forms.fields import Field as FormField
|
||||
from django.forms.widgets import Widget
|
||||
from django.http.response import HttpResponse
|
||||
from django.urls.resolvers import URLPattern
|
||||
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
|
||||
csrf_protect_m: Any
|
||||
sensitive_post_parameters_m: Any
|
||||
|
||||
class GroupAdmin(admin.ModelAdmin):
|
||||
admin_site: AdminSite
|
||||
formfield_overrides: Any
|
||||
model: Type[Group]
|
||||
opts: Options
|
||||
search_fields: Any = ...
|
||||
ordering: Any = ...
|
||||
filter_horizontal: Any = ...
|
||||
def formfield_for_manytomany(
|
||||
self, db_field: ManyToManyField, request: WSGIRequest = ..., **kwargs: Any
|
||||
) -> ModelMultipleChoiceField: ...
|
||||
class GroupAdmin(admin.ModelAdmin): ...
|
||||
|
||||
class UserAdmin(admin.ModelAdmin):
|
||||
admin_site: AdminSite
|
||||
formfield_overrides: Dict[Type[Field], Dict[str, Type[Union[FormField, Widget]]]]
|
||||
model: Type[User]
|
||||
opts: Options
|
||||
add_form_template: str = ...
|
||||
change_user_password_template: Any = ...
|
||||
fieldsets: Any = ...
|
||||
add_fieldsets: Any = ...
|
||||
form: Any = ...
|
||||
add_form: Any = ...
|
||||
change_password_form: Any = ...
|
||||
list_display: Any = ...
|
||||
list_filter: Any = ...
|
||||
search_fields: Any = ...
|
||||
ordering: Any = ...
|
||||
filter_horizontal: Any = ...
|
||||
def get_fieldsets(self, request: WSGIRequest, obj: None = ...) -> Tuple[Tuple[None, Dict[str, Tuple[str]]]]: ...
|
||||
def get_form(self, request: Any, obj: Optional[Any] = ..., **kwargs: Any): ...
|
||||
def get_urls(self) -> List[URLPattern]: ...
|
||||
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
|
||||
def add_view(self, request: WSGIRequest, form_url: str = ..., extra_context: None = ...) -> Any: ...
|
||||
def user_change_password(self, request: WSGIRequest, id: str, form_url: str = ...) -> HttpResponse: ...
|
||||
def response_add(self, request: WSGIRequest, obj: User, post_url_continue: None = ...) -> HttpResponse: ...
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
from .checks import check_models_permissions, check_user_model
|
||||
from .management import create_permissions
|
||||
from .signals import user_logged_in
|
||||
|
||||
class AuthConfig(AppConfig):
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: Any
|
||||
path: str
|
||||
name: str = ...
|
||||
verbose_name: Any = ...
|
||||
def ready(self) -> None: ...
|
||||
class AuthConfig(AppConfig): ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, List
|
||||
|
||||
from django.core.checks.messages import CheckMessage
|
||||
|
||||
from .management import _get_builtin_permissions
|
||||
|
||||
def check_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.http.request import HttpRequest
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
class PermLookupDict:
|
||||
app_label: django.utils.safestring.SafeText
|
||||
user: SimpleLazyObject
|
||||
def __init__(self, user: SimpleLazyObject, app_label: str) -> None: ...
|
||||
app_label: str
|
||||
user: Any
|
||||
def __init__(self, user: Any, app_label: str) -> None: ...
|
||||
def __getitem__(self, perm_name: str) -> bool: ...
|
||||
def __iter__(self) -> Any: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
|
||||
class PermWrapper:
|
||||
user: SimpleLazyObject = ...
|
||||
def __init__(self, user: Union[AnonymousUser, User]) -> None: ...
|
||||
user: Any = ...
|
||||
def __init__(self, user: Any) -> None: ...
|
||||
def __getitem__(self, app_label: str) -> PermLookupDict: ...
|
||||
def __iter__(self) -> Any: ...
|
||||
def __contains__(self, perm_name: Union[bool, str]) -> bool: ...
|
||||
def __contains__(self, perm_name: Any) -> bool: ...
|
||||
|
||||
def auth(request: HttpRequest) -> Dict[str, Union[PermWrapper, AnonymousUser, User]]: ...
|
||||
def auth(request: HttpRequest) -> Dict[str, Any]: ...
|
||||
|
||||
@@ -1,44 +1,24 @@
|
||||
import collections
|
||||
import datetime
|
||||
from typing import Any, Dict, Iterator, List, Optional, Union, Type
|
||||
from typing import Any, Dict, Iterator, Optional
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import AbstractUser, User
|
||||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.forms.utils import ErrorList
|
||||
from django.http.request import QueryDict
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
|
||||
from django import forms
|
||||
|
||||
UserModel: Any
|
||||
|
||||
class ReadOnlyPasswordHashWidget(forms.Widget):
|
||||
attrs: Dict[Any, Any]
|
||||
template_name: str = ...
|
||||
|
||||
class ReadOnlyPasswordHashField(forms.Field):
|
||||
widget: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def bound_data(self, data: None, initial: str) -> str: ...
|
||||
def has_changed(self, initial: str, data: Optional[str]) -> bool: ...
|
||||
|
||||
class UsernameField(forms.CharField):
|
||||
def to_python(self, value: Optional[str]) -> str: ...
|
||||
class UsernameField(forms.CharField): ...
|
||||
|
||||
class UserCreationForm(forms.ModelForm):
|
||||
auto_id: str
|
||||
data: Dict[str, str]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
instance: User
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
error_messages: Any = ...
|
||||
password1: Any = ...
|
||||
password2: Any = ...
|
||||
@@ -46,30 +26,11 @@ class UserCreationForm(forms.ModelForm):
|
||||
def clean_password2(self) -> str: ...
|
||||
|
||||
class UserChangeForm(forms.ModelForm):
|
||||
auto_id: str
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[str, Optional[Union[List[Any], datetime.datetime, int, str]]]
|
||||
instance: User
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
password: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def clean_password(self) -> str: ...
|
||||
|
||||
class AuthenticationForm(forms.Form):
|
||||
auto_id: str
|
||||
data: QueryDict
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: MultiValueDict
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
username: Any = ...
|
||||
password: Any = ...
|
||||
error_messages: Any = ...
|
||||
@@ -82,21 +43,12 @@ class AuthenticationForm(forms.Form):
|
||||
def get_invalid_login_error(self) -> ValidationError: ...
|
||||
|
||||
class PasswordResetForm(forms.Form):
|
||||
auto_id: str
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
email: Any = ...
|
||||
def send_mail(
|
||||
self,
|
||||
subject_template_name: str,
|
||||
email_template_name: str,
|
||||
context: Dict[str, Union[AbstractBaseUser, str]],
|
||||
context: Dict[str, Any],
|
||||
from_email: Optional[str],
|
||||
to_email: str,
|
||||
html_email_template_name: Optional[str] = ...,
|
||||
@@ -116,15 +68,6 @@ class PasswordResetForm(forms.Form):
|
||||
) -> None: ...
|
||||
|
||||
class SetPasswordForm(forms.Form):
|
||||
auto_id: str
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
error_messages: Any = ...
|
||||
new_password1: Any = ...
|
||||
new_password2: Any = ...
|
||||
@@ -134,31 +77,10 @@ class SetPasswordForm(forms.Form):
|
||||
def save(self, commit: bool = ...) -> AbstractBaseUser: ...
|
||||
|
||||
class PasswordChangeForm(SetPasswordForm):
|
||||
auto_id: str
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
user: User
|
||||
error_messages: Any = ...
|
||||
old_password: Any = ...
|
||||
field_order: Any = ...
|
||||
def clean_old_password(self) -> str: ...
|
||||
|
||||
class AdminPasswordChangeForm(forms.Form):
|
||||
auto_id: str
|
||||
data: Dict[Any, Any]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[Any, Any]
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
error_messages: Any = ...
|
||||
required_css_class: str = ...
|
||||
password1: Any = ...
|
||||
@@ -167,5 +89,3 @@ class AdminPasswordChangeForm(forms.Form):
|
||||
def __init__(self, user: AbstractUser, *args: Any, **kwargs: Any) -> None: ...
|
||||
def clean_password2(self) -> str: ...
|
||||
def save(self, commit: bool = ...) -> AbstractUser: ...
|
||||
@property
|
||||
def changed_data(self) -> List[str]: ...
|
||||
|
||||
@@ -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] = ...
|
||||
@@ -1,15 +1,10 @@
|
||||
from typing import Any, Dict, Optional, Set, Type, Union
|
||||
from typing import Any, Optional, Set
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
from django.contrib.sites.requests import RequestSite
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.request import HttpRequest
|
||||
from django.http.response import HttpResponse, HttpResponseRedirect
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.views.generic.edit import FormView
|
||||
|
||||
@@ -20,29 +15,18 @@ class SuccessURLAllowedHostsMixin:
|
||||
def get_success_url_allowed_hosts(self) -> Set[str]: ...
|
||||
|
||||
class LoginView(SuccessURLAllowedHostsMixin, FormView):
|
||||
form_class: Any = ...
|
||||
authentication_form: Any = ...
|
||||
redirect_field_name: Any = ...
|
||||
template_name: str = ...
|
||||
redirect_authenticated_user: bool = ...
|
||||
extra_context: Any = ...
|
||||
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
def get_success_url(self) -> str: ...
|
||||
def get_redirect_url(self) -> str: ...
|
||||
def get_form_class(self) -> Type[AuthenticationForm]: ...
|
||||
def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[str, str], HttpRequest, MultiValueDict]]]: ...
|
||||
def form_valid(self, form: AuthenticationForm) -> HttpResponseRedirect: ...
|
||||
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ...
|
||||
|
||||
class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
|
||||
next_page: Any = ...
|
||||
redirect_field_name: Any = ...
|
||||
template_name: str = ...
|
||||
extra_context: Any = ...
|
||||
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
def post(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> TemplateResponse: ...
|
||||
def get_next_page(self) -> Optional[str]: ...
|
||||
def get_context_data(self, **kwargs: Any): ...
|
||||
|
||||
def logout_then_login(request: HttpRequest, login_url: Optional[str] = ...) -> HttpResponseRedirect: ...
|
||||
def redirect_to_login(
|
||||
@@ -56,55 +40,32 @@ class PasswordContextMixin:
|
||||
class PasswordResetView(PasswordContextMixin, FormView):
|
||||
email_template_name: str = ...
|
||||
extra_email_context: Any = ...
|
||||
form_class: Any = ...
|
||||
from_email: Any = ...
|
||||
html_email_template_name: Any = ...
|
||||
subject_template_name: str = ...
|
||||
success_url: Any = ...
|
||||
template_name: str = ...
|
||||
title: Any = ...
|
||||
token_generator: Any = ...
|
||||
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
def form_valid(self, form: PasswordResetForm) -> HttpResponseRedirect: ...
|
||||
|
||||
INTERNAL_RESET_URL_TOKEN: str
|
||||
INTERNAL_RESET_SESSION_TOKEN: str
|
||||
|
||||
class PasswordResetDoneView(PasswordContextMixin, TemplateView):
|
||||
template_name: str = ...
|
||||
title: Any = ...
|
||||
|
||||
class PasswordResetConfirmView(PasswordContextMixin, FormView):
|
||||
form_class: Any = ...
|
||||
post_reset_login: bool = ...
|
||||
post_reset_login_backend: Any = ...
|
||||
success_url: Any = ...
|
||||
template_name: str = ...
|
||||
title: Any = ...
|
||||
token_generator: Any = ...
|
||||
validlink: bool = ...
|
||||
user: Any = ...
|
||||
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
def get_user(self, uidb64: str) -> Optional[AbstractBaseUser]: ...
|
||||
def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[Any, Any], AbstractBaseUser, MultiValueDict]]]: ...
|
||||
def form_valid(self, form: SetPasswordForm) -> HttpResponseRedirect: ...
|
||||
def get_context_data(self, **kwargs: Any): ...
|
||||
|
||||
class PasswordResetCompleteView(PasswordContextMixin, TemplateView):
|
||||
template_name: str = ...
|
||||
title: Any = ...
|
||||
def get_context_data(self, **kwargs: Any): ...
|
||||
|
||||
class PasswordChangeView(PasswordContextMixin, FormView):
|
||||
form_class: Any = ...
|
||||
success_url: Any = ...
|
||||
template_name: str = ...
|
||||
title: Any = ...
|
||||
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
|
||||
def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[Any, Any], User, MultiValueDict]]]: ...
|
||||
def form_valid(self, form: PasswordChangeForm) -> HttpResponseRedirect: ...
|
||||
|
||||
class PasswordChangeDoneView(PasswordContextMixin, TemplateView):
|
||||
template_name: str = ...
|
||||
title: Any = ...
|
||||
def dispatch(self, *args: Any, **kwargs: Any) -> TemplateResponse: ...
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
from .management import create_contenttypes, inject_rename_contenttypes_operations
|
||||
|
||||
class ContentTypesConfig(AppConfig):
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: Any
|
||||
path: str
|
||||
name: str = ...
|
||||
verbose_name: Any = ...
|
||||
def ready(self) -> None: ...
|
||||
class ContentTypesConfig(AppConfig): ...
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from django.core.management import BaseCommand
|
||||
from django.core.management.base import CommandParser
|
||||
from django.db.models.deletion import Collector
|
||||
|
||||
from ...management import get_contenttypes_and_models
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
stderr: django.core.management.base.OutputWrapper
|
||||
stdout: django.core.management.base.OutputWrapper
|
||||
style: django.core.management.color.Style
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def handle(self, **options: Any) -> None: ...
|
||||
class Command(BaseCommand): ...
|
||||
|
||||
class NoFastDeleteCollector(Collector):
|
||||
data: collections.OrderedDict
|
||||
data: Dict[str, Any]
|
||||
dependencies: Dict[Any, Any]
|
||||
fast_deletes: List[Any]
|
||||
field_updates: Dict[Any, Any]
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any
|
||||
|
||||
from django import forms
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
class FlatpageForm(forms.ModelForm):
|
||||
auto_id: str
|
||||
data: Dict[str, Union[List[int], str]]
|
||||
empty_permitted: bool
|
||||
error_class: Type[ErrorList]
|
||||
fields: collections.OrderedDict
|
||||
files: Dict[Any, Any]
|
||||
initial: Dict[str, Union[List[django.contrib.sites.models.Site], int, str]]
|
||||
instance: django.contrib.flatpages.models.FlatPage
|
||||
is_bound: bool
|
||||
label_suffix: str
|
||||
url: Any = ...
|
||||
def clean_url(self) -> str: ...
|
||||
def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ...
|
||||
|
||||
@@ -9,5 +9,5 @@ class FlatPage(models.Model):
|
||||
enable_comments: models.BooleanField = ...
|
||||
template_name: models.CharField = ...
|
||||
registration_required: models.BooleanField = ...
|
||||
sites: models.ManyToManyField[Site] = ...
|
||||
sites: models.ManyToManyField[Site, Site] = ...
|
||||
def get_absolute_url(self) -> str: ...
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
from typing import Optional
|
||||
|
||||
from django.contrib.sitemaps import Sitemap
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
class FlatPageSitemap(Sitemap):
|
||||
def items(self) -> QuerySet: ...
|
||||
class FlatPageSitemap(Sitemap): ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
11
django-stubs/contrib/messages/constants.pyi
Normal file
11
django-stubs/contrib/messages/constants.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import Dict
|
||||
|
||||
DEBUG: int = ...
|
||||
INFO: int = ...
|
||||
SUCCESS: int = ...
|
||||
WARNING: int = ...
|
||||
ERROR: int = ...
|
||||
|
||||
DEFAULT_TAGS: Dict[int, str] = ...
|
||||
|
||||
DEFAULT_LEVELS: Dict[str, int] = ...
|
||||
@@ -16,7 +16,7 @@ class Message:
|
||||
def level_tag(self) -> str: ...
|
||||
|
||||
class BaseStorage:
|
||||
request: Any = ...
|
||||
request: HttpRequest = ...
|
||||
used: bool = ...
|
||||
added_new: bool = ...
|
||||
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
@@ -1,49 +1,20 @@
|
||||
import json
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any
|
||||
|
||||
from django.contrib.messages.storage.base import BaseStorage, Message
|
||||
from django.contrib.messages.storage.base import BaseStorage
|
||||
|
||||
class MessageEncoder(json.JSONEncoder):
|
||||
allow_nan: bool
|
||||
check_circular: bool
|
||||
ensure_ascii: bool
|
||||
indent: None
|
||||
item_separator: str
|
||||
key_separator: str
|
||||
skipkeys: bool
|
||||
sort_keys: bool
|
||||
message_key: str = ...
|
||||
def default(self, obj: Message) -> List[Union[int, str]]: ...
|
||||
|
||||
class MessageDecoder(json.JSONDecoder):
|
||||
def process_messages(
|
||||
self,
|
||||
obj: Union[
|
||||
Dict[
|
||||
str, Union[List[Union[Dict[str, List[Union[int, str]]], List[Union[int, str]]]], List[Union[int, str]]]
|
||||
],
|
||||
List[Union[List[Union[int, str]], str]],
|
||||
str,
|
||||
],
|
||||
) -> Union[
|
||||
Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]],
|
||||
List[Union[Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], Message]],
|
||||
List[Union[Message, str]],
|
||||
Message,
|
||||
str,
|
||||
]: ...
|
||||
def decode(
|
||||
self, s: str, **kwargs: Any
|
||||
) -> Union[
|
||||
List[Union[Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], Message]],
|
||||
List[Union[Message, str]],
|
||||
Message,
|
||||
]: ...
|
||||
def process_messages(self, obj: Any) -> Any: ...
|
||||
|
||||
class CookieStorage(BaseStorage):
|
||||
added_new: bool
|
||||
request: WSGIRequest
|
||||
used: bool
|
||||
cookie_name: str = ...
|
||||
max_cookie_size: int = ...
|
||||
not_finished: str = ...
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from django.contrib.messages.storage.base import BaseStorage
|
||||
|
||||
class FallbackStorage(BaseStorage):
|
||||
added_new: bool
|
||||
request: WSGIRequest
|
||||
used: bool
|
||||
storage_classes: Any = ...
|
||||
storages: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
from typing import Any, List, Optional, Union
|
||||
from typing import Any, List, Optional, Sequence, Union
|
||||
|
||||
from django.contrib.messages.storage.base import BaseStorage, Message
|
||||
from django.contrib.messages.storage.base import BaseStorage
|
||||
from django.http.request import HttpRequest
|
||||
|
||||
class SessionStorage(BaseStorage):
|
||||
added_new: bool
|
||||
request: WSGIRequest
|
||||
used: bool
|
||||
session_key: str = ...
|
||||
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
|
||||
def serialize_messages(self, messages: Union[List[Message], List[str]]) -> str: ...
|
||||
def deserialize_messages(
|
||||
self, data: Optional[Union[List[Any], str]]
|
||||
) -> Optional[Union[List[Message], List[str]]]: ...
|
||||
def serialize_messages(self, messages: Sequence[Any]) -> str: ...
|
||||
def deserialize_messages(self, data: Optional[Union[List[Any], str]]) -> Optional[List[Any]]: ...
|
||||
|
||||
@@ -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] = None
|
||||
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=None, *, config=None, invert=False, search_type="plain"): ...
|
||||
def __invert__(self: _T) -> _T: ...
|
||||
|
||||
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression):
|
||||
def __init__(self, lhs, connector, rhs, config, output_field=None) -> 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): ...
|
||||
@@ -1,8 +1,6 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
VALID_KEY_CHARS: Any
|
||||
|
||||
class CreateError(Exception): ...
|
||||
@@ -18,8 +16,8 @@ class SessionBase(Dict[str, Any]):
|
||||
def set_test_cookie(self) -> None: ...
|
||||
def test_cookie_worked(self) -> bool: ...
|
||||
def delete_test_cookie(self) -> None: ...
|
||||
def encode(self, session_dict: Dict[str, Model]) -> str: ...
|
||||
def decode(self, session_data: Union[bytes, str]) -> Dict[str, Model]: ...
|
||||
def encode(self, session_dict: Dict[str, Any]) -> str: ...
|
||||
def decode(self, session_data: Union[bytes, str]) -> Dict[str, Any]: ...
|
||||
def has_key(self, key: Any): ...
|
||||
def keys(self): ...
|
||||
def values(self): ...
|
||||
@@ -33,7 +31,7 @@ class SessionBase(Dict[str, Any]):
|
||||
def get_expire_at_browser_close(self) -> bool: ...
|
||||
def flush(self) -> None: ...
|
||||
def cycle_key(self) -> None: ...
|
||||
def exists(self, session_key: str) -> None: ...
|
||||
def exists(self, session_key: str) -> bool: ...
|
||||
def create(self) -> None: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def delete(self, session_key: Optional[Any] = ...) -> None: ...
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
|
||||
from django.contrib.sessions.serializers import JSONSerializer
|
||||
|
||||
KEY_PREFIX: str
|
||||
|
||||
class SessionStore(SessionBase):
|
||||
accessed: bool
|
||||
serializer: JSONSerializer
|
||||
cache_key_prefix: Any = ...
|
||||
def __init__(self, session_key: Optional[str] = ...) -> None: ...
|
||||
@property
|
||||
def cache_key(self) -> str: ...
|
||||
def load(self) -> Dict[str, str]: ...
|
||||
modified: bool = ...
|
||||
def create(self) -> None: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def exists(self, session_key: Optional[str]) -> bool: ...
|
||||
def delete(self, session_key: Optional[str] = ...) -> None: ...
|
||||
@classmethod
|
||||
def clear_expired(cls) -> None: ...
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.contrib.sessions.backends.db import SessionStore as DBStore
|
||||
|
||||
KEY_PREFIX: str
|
||||
|
||||
class SessionStore(DBStore):
|
||||
accessed: bool
|
||||
modified: bool
|
||||
serializer: Type[django.core.signing.JSONSerializer]
|
||||
cache_key_prefix: Any = ...
|
||||
def __init__(self, session_key: Optional[str] = ...) -> None: ...
|
||||
@property
|
||||
def cache_key(self) -> str: ...
|
||||
def load(self) -> Dict[str, str]: ...
|
||||
def exists(self, session_key: Optional[str]) -> bool: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def delete(self, session_key: Optional[str] = ...) -> None: ...
|
||||
def flush(self) -> None: ...
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
from typing import Dict, Optional, Type, Union
|
||||
from typing import Dict, Optional, Type
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.contrib.sessions.base_session import AbstractBaseSession
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.core.signing import Serializer
|
||||
from django.db.models.base import Model
|
||||
|
||||
class SessionStore(SessionBase):
|
||||
accessed: bool
|
||||
serializer: Type[Serializer]
|
||||
def __init__(self, session_key: Optional[str] = ...) -> None: ...
|
||||
@classmethod
|
||||
def get_model_class(cls) -> Type[Session]: ...
|
||||
def model(self) -> Type[AbstractBaseSession]: ...
|
||||
def load(self) -> Dict[str, Union[Model, int, str]]: ...
|
||||
def exists(self, session_key: Optional[str]) -> bool: ...
|
||||
modified: bool = ...
|
||||
def create(self) -> None: ...
|
||||
def create_model_instance(self, data: Dict[str, Model]) -> AbstractBaseSession: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def delete(self, session_key: Optional[str] = ...) -> None: ...
|
||||
@classmethod
|
||||
def clear_expired(cls) -> None: ...
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Optional
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
|
||||
class SessionStore(SessionBase):
|
||||
accessed: bool
|
||||
serializer: Type[django.core.signing.JSONSerializer]
|
||||
storage_path: str = ...
|
||||
file_prefix: str = ...
|
||||
def __init__(self, session_key: Optional[str] = ...) -> None: ...
|
||||
def load(self) -> Dict[str, Union[int, str]]: ...
|
||||
modified: bool = ...
|
||||
def create(self) -> None: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def exists(self, session_key: Optional[str]) -> bool: ...
|
||||
def delete(self, session_key: Optional[str] = ...) -> None: ...
|
||||
def clean(self) -> None: ...
|
||||
@classmethod
|
||||
def clear_expired(cls) -> None: ...
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
|
||||
class SessionStore(SessionBase):
|
||||
accessed: bool
|
||||
serializer: Type[django.core.signing.JSONSerializer]
|
||||
def load(self) -> Dict[str, Union[datetime, str]]: ...
|
||||
modified: bool = ...
|
||||
def create(self) -> None: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def exists(self, session_key: Optional[str] = ...) -> bool: ...
|
||||
def delete(self, session_key: Optional[str] = ...) -> None: ...
|
||||
def cycle_key(self) -> None: ...
|
||||
@classmethod
|
||||
def clear_expired(cls) -> None: ...
|
||||
class SessionStore(SessionBase): ...
|
||||
|
||||
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,10 +1,3 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
stderr: django.core.management.base.OutputWrapper
|
||||
stdout: django.core.management.base.OutputWrapper
|
||||
style: django.core.management.color.Style
|
||||
help: str = ...
|
||||
def handle(self, **options: Any) -> None: ...
|
||||
class Command(BaseCommand): ...
|
||||
|
||||
@@ -15,7 +15,7 @@ def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None:
|
||||
|
||||
class Sitemap:
|
||||
limit: int = ...
|
||||
protocol: Any = ...
|
||||
protocol: Optional[str] = ...
|
||||
def items(self) -> List[Any]: ...
|
||||
def location(self, obj: Model) -> str: ...
|
||||
@property
|
||||
@@ -29,7 +29,6 @@ class GenericSitemap(Sitemap):
|
||||
changefreq: Optional[str] = ...
|
||||
queryset: QuerySet = ...
|
||||
date_field: None = ...
|
||||
protocol: Optional[str] = ...
|
||||
def __init__(
|
||||
self,
|
||||
info_dict: Dict[str, Union[datetime, QuerySet, str]],
|
||||
@@ -37,7 +36,6 @@ class GenericSitemap(Sitemap):
|
||||
changefreq: Optional[str] = ...,
|
||||
protocol: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def items(self) -> QuerySet: ...
|
||||
def lastmod(self, item: Model) -> Optional[datetime]: ...
|
||||
|
||||
default_app_config: str
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
from typing import Any
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
class SitesConfig(AppConfig):
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: Any
|
||||
path: str
|
||||
name: str = ...
|
||||
verbose_name: Any = ...
|
||||
def ready(self) -> None: ...
|
||||
class SitesConfig(AppConfig): ...
|
||||
|
||||
@@ -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,15 +1,6 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
class StaticFilesConfig(AppConfig):
|
||||
apps: None
|
||||
label: str
|
||||
models: None
|
||||
models_module: None
|
||||
module: Any
|
||||
path: str
|
||||
name: str = ...
|
||||
verbose_name: Any = ...
|
||||
ignore_patterns: Any = ...
|
||||
def ready(self) -> None: ...
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
from typing import Any, Iterator, List, Optional, Tuple, Union, Mapping, overload
|
||||
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload
|
||||
|
||||
from django.contrib.staticfiles.storage import StaticFilesStorage
|
||||
from django.core.checks.messages import Error
|
||||
from django.core.files.storage import DefaultStorage, FileSystemStorage, Storage
|
||||
from django.core.files.storage import Storage
|
||||
from typing_extensions import Literal
|
||||
|
||||
searched_locations: Any
|
||||
|
||||
class BaseFinder:
|
||||
def check(self, **kwargs: Any) -> Any: ...
|
||||
def find(self, path: Any, all: bool = ...) -> None: ...
|
||||
def list(self, ignore_patterns: Any) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def find(self, path: str, all: bool = ...) -> Optional[Any]: ...
|
||||
def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
|
||||
|
||||
class FileSystemFinder(BaseFinder):
|
||||
locations: List[Any] = ...
|
||||
storages: Mapping[str, Any] = ...
|
||||
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
|
||||
def find_location(self, root: str, path: str, prefix: str = ...) -> Optional[str]: ...
|
||||
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ...
|
||||
|
||||
class AppDirectoriesFinder(BaseFinder):
|
||||
storage_class: Any = ...
|
||||
@@ -27,15 +23,11 @@ class AppDirectoriesFinder(BaseFinder):
|
||||
apps: List[str] = ...
|
||||
storages: Mapping[str, Any] = ...
|
||||
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ...
|
||||
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
|
||||
def find_in_app(self, app: str, path: str) -> Optional[str]: ...
|
||||
|
||||
class BaseStorageFinder(BaseFinder):
|
||||
storage: Storage = ...
|
||||
def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
|
||||
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, DefaultStorage]]: ...
|
||||
|
||||
class DefaultStorageFinder(BaseStorageFinder): ...
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
|
||||
|
||||
@@ -7,9 +7,6 @@ class StaticFilesHandler(WSGIHandler):
|
||||
application: WSGIHandler = ...
|
||||
base_url: Any = ...
|
||||
def __init__(self, application: WSGIHandler) -> None: ...
|
||||
def load_middleware(self) -> None: ...
|
||||
def get_base_url(self) -> str: ...
|
||||
def file_path(self, url: str) -> str: ...
|
||||
def serve(self, request: WSGIRequest) -> Any: ...
|
||||
def get_response(self, request: WSGIRequest) -> Any: ...
|
||||
def __call__(self, environ: Any, start_response: Any): ...
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
stderr: django.core.management.base.OutputWrapper
|
||||
stdout: django.core.management.base.OutputWrapper
|
||||
help: str = ...
|
||||
requires_system_checks: bool = ...
|
||||
copied_files: Any = ...
|
||||
symlinked_files: Any = ...
|
||||
unmodified_files: Any = ...
|
||||
post_processed_files: Any = ...
|
||||
storage: Any = ...
|
||||
style: django.core.management.color.Style = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def local(self) -> bool: ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
interactive: Any = ...
|
||||
verbosity: Any = ...
|
||||
symlink: Any = ...
|
||||
@@ -26,7 +20,6 @@ class Command(BaseCommand):
|
||||
post_process: Any = ...
|
||||
def set_options(self, **options: Any) -> None: ...
|
||||
def collect(self) -> Dict[str, List[str]]: ...
|
||||
def handle(self, **options: Any) -> Optional[str]: ...
|
||||
def log(self, msg: str, level: int = ...) -> None: ...
|
||||
def is_local_storage(self) -> bool: ...
|
||||
def clear_dir(self, path: str) -> None: ...
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
from typing import Any, Optional
|
||||
from django.core.management.base import LabelCommand
|
||||
|
||||
from django.core.management.base import CommandParser, LabelCommand
|
||||
|
||||
class Command(LabelCommand):
|
||||
stderr: django.core.management.base.OutputWrapper
|
||||
stdout: django.core.management.base.OutputWrapper
|
||||
style: django.core.management.color.Style
|
||||
help: str = ...
|
||||
label: str = ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def handle_label(self, path: str, **options: Any) -> str: ...
|
||||
class Command(LabelCommand): ...
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
from typing import Any, Optional
|
||||
from django.core.management.commands.runserver import Command as RunserverCommand # type: ignore
|
||||
|
||||
from django.contrib.staticfiles.handlers import StaticFilesHandler
|
||||
from django.core.management.base import CommandParser
|
||||
from django.core.management.commands.runserver import Command as RunserverCommand
|
||||
|
||||
class Command(RunserverCommand):
|
||||
stderr: django.core.management.base.OutputWrapper
|
||||
stdout: django.core.management.base.OutputWrapper
|
||||
style: django.core.management.color.Style
|
||||
help: str = ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def get_handler(self, *args: Any, **options: Any) -> StaticFilesHandler: ...
|
||||
class Command(RunserverCommand): ...
|
||||
|
||||
@@ -20,7 +20,6 @@ class HashedFilesMixin:
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def file_hash(self, name: str, content: File = ...) -> str: ...
|
||||
def hashed_name(self, name: str, content: Optional[File] = ..., filename: Optional[str] = ...) -> str: ...
|
||||
def url(self, name: SafeText, force: bool = ...) -> str: ...
|
||||
def url_converter(self, name: str, hashed_files: OrderedDict, template: str = ...) -> Callable: ...
|
||||
def post_process(
|
||||
self, paths: OrderedDict, dry_run: bool = ..., **options: Any
|
||||
@@ -33,16 +32,13 @@ class ManifestFilesMixin(HashedFilesMixin):
|
||||
manifest_version: str = ...
|
||||
manifest_name: str = ...
|
||||
manifest_strict: bool = ...
|
||||
hashed_files: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def read_manifest(self) -> Any: ...
|
||||
def load_manifest(self) -> OrderedDict: ...
|
||||
def post_process(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def save_manifest(self) -> None: ...
|
||||
def stored_name(self, name: str) -> str: ...
|
||||
|
||||
class _MappingCache:
|
||||
cache: django.core.cache.DefaultCacheProxy = ...
|
||||
cache: Any = ...
|
||||
def __init__(self, cache: Any) -> None: ...
|
||||
def __setitem__(self, key: Any, value: Any) -> None: ...
|
||||
def __getitem__(self, key: Any): ...
|
||||
@@ -51,9 +47,7 @@ class _MappingCache:
|
||||
def get(self, key: Any, default: Optional[Any] = ...): ...
|
||||
|
||||
class CachedFilesMixin(HashedFilesMixin):
|
||||
hashed_files: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def hash_key(self, name: str) -> str: ...
|
||||
|
||||
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): ...
|
||||
class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ...
|
||||
|
||||
@@ -4,4 +4,4 @@ from django.urls.resolvers import URLPattern
|
||||
|
||||
urlpatterns: 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
|
||||
|
||||
|
||||
22
django-stubs/core/cache/backends/base.pyi
vendored
22
django-stubs/core/cache/backends/base.pyi
vendored
@@ -1,5 +1,4 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional, Union
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Union
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
@@ -9,7 +8,7 @@ class CacheKeyWarning(RuntimeWarning): ...
|
||||
DEFAULT_TIMEOUT: Any
|
||||
MEMCACHE_MAX_KEY_LENGTH: int
|
||||
|
||||
def default_key_func(key: Union[int, str], key_prefix: str, version: Union[int, str]) -> str: ...
|
||||
def default_key_func(key: Any, key_prefix: str, version: Any) -> str: ...
|
||||
def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ...
|
||||
|
||||
class BaseCache:
|
||||
@@ -17,9 +16,9 @@ class BaseCache:
|
||||
key_prefix: str = ...
|
||||
version: int = ...
|
||||
key_func: Callable = ...
|
||||
def __init__(self, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
|
||||
def __init__(self, params: Dict[str, Any]) -> None: ...
|
||||
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
|
||||
def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> str: ...
|
||||
def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ...
|
||||
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
|
||||
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
@@ -27,19 +26,14 @@ class BaseCache:
|
||||
def delete(self, key: Any, version: Optional[Any] = ...) -> None: ...
|
||||
def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ...
|
||||
def get_or_set(
|
||||
self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> Optional[Union[int, str]]: ...
|
||||
self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> Optional[Any]: ...
|
||||
def has_key(self, key: Any, version: Optional[Any] = ...): ...
|
||||
def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def set_many(
|
||||
self,
|
||||
data: Union[Dict[str, bytes], Dict[str, int], Dict[str, str], OrderedDict],
|
||||
timeout: Any = ...,
|
||||
version: Optional[Union[int, str]] = ...,
|
||||
) -> List[Any]: ...
|
||||
def delete_many(self, keys: Union[Dict[str, str], List[str]], version: None = ...) -> None: ...
|
||||
def set_many(self, data: Dict[str, Any], timeout: Any = ..., version: Optional[Any] = ...) -> List[Any]: ...
|
||||
def delete_many(self, keys: Iterable[Any], version: Optional[Any] = ...) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def validate_key(self, key: str) -> None: ...
|
||||
def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
|
||||
23
django-stubs/core/cache/backends/db.pyi
vendored
23
django-stubs/core/cache/backends/db.pyi
vendored
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
@@ -16,24 +16,7 @@ class Options:
|
||||
def __init__(self, table: str) -> None: ...
|
||||
|
||||
class BaseDatabaseCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
cache_model_class: Any = ...
|
||||
def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
|
||||
def __init__(self, table: str, params: Dict[str, Any]) -> None: ...
|
||||
|
||||
class DatabaseCache(BaseDatabaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def get(self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...) -> Any: ...
|
||||
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def add(
|
||||
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> bool: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
|
||||
def clear(self) -> None: ...
|
||||
class DatabaseCache(BaseDatabaseCache): ...
|
||||
|
||||
15
django-stubs/core/cache/backends/dummy.pyi
vendored
15
django-stubs/core/cache/backends/dummy.pyi
vendored
@@ -1,19 +1,6 @@
|
||||
from typing import Any, Dict, Optional, Union, Callable
|
||||
from typing import Any
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class DummyCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def __init__(self, host: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
def add(self, key: str, value: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def get(self, key: str, default: Optional[str] = ..., version: Optional[int] = ...) -> Optional[str]: ...
|
||||
def set(
|
||||
self, key: str, value: Union[Dict[str, Any], int, str], timeout: Any = ..., version: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: None = ...) -> None: ...
|
||||
def has_key(self, key: str, version: None = ...) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
|
||||
19
django-stubs/core/cache/backends/filebased.pyi
vendored
19
django-stubs/core/cache/backends/filebased.pyi
vendored
@@ -1,22 +1,7 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class FileBasedCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
cache_suffix: str = ...
|
||||
def __init__(self, dir: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
|
||||
def add(
|
||||
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> bool: ...
|
||||
def get(
|
||||
self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...
|
||||
) -> Optional[str]: ...
|
||||
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
def __init__(self, dir: str, params: Dict[str, Any]) -> None: ...
|
||||
|
||||
@@ -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,17 +1,15 @@
|
||||
from ctypes import Structure, c_int64, c_ulong, c_void_p
|
||||
from io import BufferedRandom, TextIOWrapper
|
||||
from typing import Union
|
||||
from ctypes import Structure, Union
|
||||
from typing import Any
|
||||
|
||||
LOCK_SH: int
|
||||
LOCK_NB: int
|
||||
LOCK_EX: int
|
||||
ULONG_PTR = c_int64
|
||||
ULONG_PTR = c_ulong
|
||||
PVOID = c_void_p
|
||||
ULONG_PTR: Any = ...
|
||||
PVOID: Any = ...
|
||||
|
||||
class _OFFSET(Structure): ...
|
||||
class _OFFSET_UNION(Union): ...
|
||||
class OVERLAPPED(Structure): ...
|
||||
|
||||
def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ...
|
||||
def unlock(f: Union[BufferedRandom, int]) -> bool: ...
|
||||
def lock(f: Any, flags: int) -> bool: ...
|
||||
def unlock(f: Any) -> bool: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from typing import Any, List, Optional, Tuple
|
||||
|
||||
from .backends.base import BaseEmailBackend
|
||||
from .message import (
|
||||
BadHeaderError as BadHeaderError,
|
||||
DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE,
|
||||
@@ -12,7 +11,7 @@ from .message import (
|
||||
)
|
||||
from .utils import CachedDnsName as CachedDnsName, DNS_NAME as DNS_NAME
|
||||
|
||||
def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> BaseEmailBackend: ...
|
||||
def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> Any: ...
|
||||
def send_mail(
|
||||
subject: str,
|
||||
message: str,
|
||||
@@ -21,7 +20,7 @@ def send_mail(
|
||||
fail_silently: bool = ...,
|
||||
auth_user: Optional[str] = ...,
|
||||
auth_password: Optional[str] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> int: ...
|
||||
def send_mass_mail(
|
||||
@@ -29,20 +28,20 @@ def send_mass_mail(
|
||||
fail_silently: bool = ...,
|
||||
auth_user: Optional[str] = ...,
|
||||
auth_password: Optional[str] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
) -> int: ...
|
||||
def mail_admins(
|
||||
subject: str,
|
||||
message: str,
|
||||
fail_silently: bool = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def mail_managers(
|
||||
subject: str,
|
||||
message: str,
|
||||
fail_silently: bool = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
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: ...
|
||||
@@ -1,11 +1,8 @@
|
||||
from email._policybase import Policy
|
||||
from email._policybase import Policy # type: ignore
|
||||
from email.mime.message import MIMEMessage
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union, Sequence
|
||||
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
|
||||
|
||||
utf8_charset: Any
|
||||
utf8_charset_qp: Any
|
||||
@@ -20,16 +17,13 @@ def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str,
|
||||
def split_addr(addr: str, encoding: str) -> Tuple[str, str]: ...
|
||||
def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ...
|
||||
|
||||
class MIMEMixin:
|
||||
def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ...
|
||||
def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ...
|
||||
class MIMEMixin: ...
|
||||
|
||||
class SafeMIMEMessage(MIMEMixin, MIMEMessage):
|
||||
defects: List[Any]
|
||||
epilogue: None
|
||||
policy: Policy
|
||||
preamble: None
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
|
||||
class SafeMIMEText(MIMEMixin, MIMEText):
|
||||
defects: List[Any]
|
||||
@@ -38,8 +32,6 @@ class SafeMIMEText(MIMEMixin, MIMEText):
|
||||
preamble: None
|
||||
encoding: str = ...
|
||||
def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ...
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
def set_payload(self, payload: str, charset: str = ...) -> None: ...
|
||||
|
||||
class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
|
||||
defects: List[Any]
|
||||
@@ -50,7 +42,6 @@ class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
|
||||
def __init__(
|
||||
self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any
|
||||
) -> None: ...
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
|
||||
class EmailMessage:
|
||||
content_subtype: str = ...
|
||||
@@ -65,7 +56,7 @@ class EmailMessage:
|
||||
body: str = ...
|
||||
attachments: List[Any] = ...
|
||||
extra_headers: Dict[Any, Any] = ...
|
||||
connection: None = ...
|
||||
connection: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
subject: str = ...,
|
||||
@@ -73,14 +64,15 @@ class EmailMessage:
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[Union[Sequence[str], str]] = ...,
|
||||
bcc: Optional[Union[Sequence[str], str]] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ...,
|
||||
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 = ...) -> BaseEmailBackend: ...
|
||||
def message(self) -> MIMEMixin: ...
|
||||
def get_connection(self, fail_silently: bool = ...) -> Any: ...
|
||||
# TODO: when typeshed gets more types for email.Message, move it to MIMEMessage, now it has too many false-positives
|
||||
def message(self) -> Any: ...
|
||||
def recipients(self) -> List[str]: ...
|
||||
def send(self, fail_silently: bool = ...) -> int: ...
|
||||
def attach(
|
||||
@@ -92,16 +84,6 @@ class EmailMessage:
|
||||
def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ...
|
||||
|
||||
class EmailMultiAlternatives(EmailMessage):
|
||||
attachments: List[Any]
|
||||
bcc: List[Any]
|
||||
body: SafeText
|
||||
cc: List[Any]
|
||||
connection: None
|
||||
extra_headers: Dict[Any, Any]
|
||||
from_email: str
|
||||
reply_to: List[Any]
|
||||
subject: str
|
||||
to: List[str]
|
||||
alternative_subtype: str = ...
|
||||
alternatives: Any = ...
|
||||
def __init__(
|
||||
@@ -111,7 +93,7 @@ class EmailMultiAlternatives(EmailMessage):
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[List[str]] = ...,
|
||||
bcc: Optional[List[str]] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
connection: Optional[Any] = ...,
|
||||
attachments: None = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
alternatives: Optional[List[Tuple[str, str]]] = ...,
|
||||
|
||||
@@ -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] = ...
|
||||
|
||||
@@ -42,10 +42,14 @@ class BaseCommand:
|
||||
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] = ...
|
||||
3
django-stubs/core/management/commands/runserver.pyi
Normal file
3
django-stubs/core/management/commands/runserver.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class Command(BaseCommand): ...
|
||||
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): ...
|
||||
@@ -1,16 +1,13 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class TemplateCommand(BaseCommand):
|
||||
requires_system_checks: bool = ...
|
||||
url_schemes: Any = ...
|
||||
rewrite_template_suffixes: Any = ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
app_or_project: Any = ...
|
||||
paths_to_remove: Any = ...
|
||||
verbosity: Any = ...
|
||||
def handle(self, app_or_project: Any, name: Any, target: Optional[Any] = ..., **options: Any): ...
|
||||
def handle_template(self, template: Any, subdir: Any): ...
|
||||
def validate_name(self, name: Any, app_or_project: Any) -> None: ...
|
||||
def download(self, url: Any): ...
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
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: ...
|
||||
@@ -28,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[List[Tuple[AppConfig, None]], List[Tuple[str, List[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: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from re import RegexFlag
|
||||
from typing import Any, Dict, List, Optional, Union, Pattern
|
||||
from typing import Any, Dict, List, Optional, Union, Pattern, Collection
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.files.base import File
|
||||
@@ -38,7 +38,7 @@ class URLValidator(RegexValidator):
|
||||
tld_re: Any = ...
|
||||
host_re: Any = ...
|
||||
schemes: Any = ...
|
||||
def __init__(self, schemes: Optional[List[str]] = ..., **kwargs: Any) -> None: ...
|
||||
def __init__(self, schemes: Optional[Collection[str]] = ..., **kwargs: Any) -> None: ...
|
||||
|
||||
integer_validator: Any
|
||||
|
||||
@@ -52,7 +52,7 @@ class EmailValidator:
|
||||
literal_regex: Any = ...
|
||||
domain_whitelist: Any = ...
|
||||
def __init__(
|
||||
self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[List[str]] = ...
|
||||
self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[Collection[str]] = ...
|
||||
) -> None: ...
|
||||
def __call__(self, value: Optional[str]) -> None: ...
|
||||
def validate_domain_part(self, domain_part: str) -> bool: ...
|
||||
@@ -119,7 +119,10 @@ class FileExtensionValidator:
|
||||
code: str = ...
|
||||
allowed_extensions: List[str] = ...
|
||||
def __init__(
|
||||
self, allowed_extensions: Optional[List[str]] = ..., message: Optional[str] = ..., code: Optional[str] = ...
|
||||
self,
|
||||
allowed_extensions: Optional[Collection[str]] = ...,
|
||||
message: Optional[str] = ...,
|
||||
code: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, value: File) -> None: ...
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user