1 Commits

Author SHA1 Message Date
Maxim Kurnikov
984337c304 wip 1 2019-01-30 18:11:07 +03:00
464 changed files with 6024 additions and 13229 deletions

View File

@@ -1,10 +0,0 @@
# Check http://editorconfig.org for more information
# This is the main config file for this project:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
trim_trailing_whitespace = true

View File

@@ -1,35 +0,0 @@
---
name: Bug
about: Create a report of something is not working
labels: 'bug'
---
# Bug report
<!--
Hi, thanks for submitting a bug. We appreciate that.
But, we will need some information about what's wrong to help you.
-->
## What's wrong
<!--
Describe what is not working.
Please, attach a traceback.
We would also appreciate a failing test case.
That is EXTREMELY helpful!
-->
## How is that should be
<!-- Describe how it should work. -->
## System information
- OS:
- `python` version:
- `django` version:
- `mypy` version:
- `django-stubs` version:

View File

@@ -1,29 +0,0 @@
# I have made things!
<!--
Hi, thanks for submitting a Pull Request. We appreciate it.
Please, fill in all the required information
to make our review and merging processes easier.
Cheers!
-->
## Related issues
<!--
Mark what issues this Pull Request closes or references.
Format is:
- Closes #issue-number
- Refs #issue-number
Example. Refs #0
Documentation: https://blog.github.com/2013-05-14-closing-issues-via-pull-requests/
-->
<!--
If you have any feedback, just write it here.
It can be whatever you want!
-->

7
.gitignore vendored
View File

@@ -5,10 +5,7 @@ out/
/django
.idea/
.mypy_cache/
django-sources
build/
dist/
pip-wheel-metadata/
.pytest_cache/
/.envrc
/.direnv
django-sources/
django-sources-typed/

View File

@@ -1,52 +1,32 @@
language: python
# cache package wheels (1 cache per python version)
cache: pip
# newer python versions are available only on xenial (while some older only on trusty) Ubuntu distribution
dist: xenial
sudo: required
jobs:
include:
- name: Run plugin test suite with python 3.7
python: 3.7
script: 'pytest'
- name: Typecheck Django 3.0 test suite with python 3.7
- name: "Typecheck Django test suite"
python: 3.7
script: |
python ./scripts/typecheck_tests.py --django_version=3.0
python ./scripts/typecheck_tests.py
- name: Typecheck Django 3.0 test suite with python 3.6
python: 3.6
script: |
python ./scripts/typecheck_tests.py --django_version=3.0
- name: Typecheck Django 2.2 test suite with python 3.7
- name: "Run plugin test suite with python 3.7"
python: 3.7
script: |
python ./scripts/typecheck_tests.py --django_version=2.2
set -e
pytest
- name: Mypy for plugin code
- name: "Lint with black"
python: 3.7
script: 'mypy ./mypy_django_plugin'
- name: Lint with black
python: 3.7
script: 'black --check django-stubs/'
- name: Lint plugin code with flake8
python: 3.7
script: 'flake8'
- name: Lint stubs with flake8-pyi and check for unused imports
python: 3.7
script: 'flake8 --config flake8-pyi.ini'
- name: Lint plugin code with isort
python: 3.7
script: 'isort --check --diff'
script: |
black --check --line-length=120 django-stubs/
before_install: |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y
sudo apt-get update
sudo apt-get install -y binutils libproj-dev gdal-bin
# 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

View File

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

View File

@@ -2,84 +2,31 @@
# pep484 stubs for Django framework
[![Build Status](https://travis-ci.com/typeddjango/django-stubs.svg?branch=master)](https://travis-ci.com/typeddjango/django-stubs)
[![Build Status](https://travis-ci.org/mkurnikov/django-stubs.svg?branch=master)](https://travis-ci.org/mkurnikov/django-stubs)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Gitter](https://badges.gitter.im/mypy-django/Lobby.svg)](https://gitter.im/mypy-django/Lobby)
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns.
Could be run on earlier versions of Django, but expect some missing imports warnings.
## Installation
```bash
```
pip install django-stubs
```
## Mypy compatibility
| django-stubs | mypy version | django version | python version
| ------------ | ---- | ---- | ---- |
| 1.3.0 | 0.750 | 2.2.x | ^3.6
| 1.2.0 | 0.730 | 2.2.x | ^3.6
| 1.1.0 | 0.720 | 2.2.x | ^3.6
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
## Configuration
To make mypy aware of the plugin, you need to add
```ini
```
[mypy]
plugins =
mypy_django_plugin.main
```
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
Plugin also requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified.
```ini
[mypy]
strict_optional = True
# This one is new:
[mypy.plugins.django-stubs]
django_settings_module = mysettings
```
Where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes)
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
In other words, if your `manage.py runserver` crashes, mypy will crash too.
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
## Notes
Type implementation monkey-patches Django to add `__class_getitem__` to the `Manager` class.
If you would use Python3.7 and do that too in your code, you can make things like
```python
class MyUserManager(models.Manager['MyUser']):
pass
class MyUser(models.Model):
objects = MyUserManager()
```
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`.
in your `mypy.ini` file.
Also, it uses value of `DJANGO_SETTINGS_MODULE` from the environment, so set it before execution, otherwise some features will not work.
## To get help
We have Gitter here: <https://gitter.im/mypy-django/Lobby>
We have Gitter here https://gitter.im/mypy-django/Lobby.
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.

View File

@@ -1,8 +1,3 @@
black
pytest-mypy-plugins==1.2.0
psycopg2
flake8==3.7.9
flake8-pyi==19.3.0
isort==4.3.21
gitpython==3.0.5
-e git+https://github.com/mkurnikov/pytest-mypy-plugins.git#egg=pytest-mypy-plugins
-e .

View File

@@ -1,12 +1,6 @@
from typing import Any, NamedTuple
from .utils.version import get_version as get_version
from typing import Any
from django.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: ...

View File

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

View File

@@ -1,37 +1,35 @@
import threading
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
import collections
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable
from django.db.migrations.state import AppConfigStub
from django.db.models.base import Model
from .config import AppConfig
class Apps:
all_models: Dict[str, Dict[str, Type[Model]]] = ...
app_configs: Dict[str, AppConfig] = ...
all_models: collections.defaultdict = ...
app_configs: collections.OrderedDict = ...
stored_app_configs: List[Any] = ...
apps_ready: bool = ...
ready_event: threading.Event = ...
loading: bool = ...
_pending_operations: Dict[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[Iterable[Union[AppConfig, str]]] = ...) -> None: ...
def populate(self, installed_apps: Iterable[Union[AppConfig, str]] = ...) -> None: ...
def populate(self, installed_apps: Union[List[AppConfigStub], List[str], Tuple] = ...) -> None: ...
def check_apps_ready(self) -> None: ...
def check_models_ready(self) -> None: ...
def get_app_configs(self) -> Iterable[AppConfig]: ...
def get_app_config(self, app_label: str) -> AppConfig: ...
# it's not possible to support it in plugin properly now
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Model]: ...
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]: ...
def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ...
def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ...
def set_available_apps(self, available: Iterable[str]) -> None: ...
def set_available_apps(self, available: List[str]) -> None: ...
def unset_available_apps(self) -> None: ...
def set_installed_apps(self, installed: Iterable[str]) -> None: ...
def set_installed_apps(self, installed: Union[List[str], Tuple[str]]) -> None: ...
def unset_installed_apps(self) -> None: ...
def clear_cache(self) -> None: ...
def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ...

View File

@@ -2,16 +2,8 @@ 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):
def __getattr__(self, item: Any) -> Any: ...
class _DjangoConfLazyObject(LazyObject): ...
class LazySettings(_DjangoConfLazyObject):
configured: bool
@@ -19,11 +11,5 @@ class LazySettings(_DjangoConfLazyObject):
settings: LazySettings = ...
class Settings:
def __init__(self, settings_module: str): ...
def is_overridden(self, setting: str) -> bool: ...
class Settings: ...
class UserSettingsHolder: ...
class SettingsReference(str):
def __init__(self, value: str, setting_name: str) -> None: ...

View File

@@ -1,504 +0,0 @@
"""
Default Django settings. Override these with settings in the module pointed to
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, Protocol, Sequence, Tuple, Union
####################
# CORE #
####################
DEBUG: bool = ...
# Whether the framework should propagate raw exceptions rather than catching
# them. This is useful under some testing situations and should never be used
# on a live site.
DEBUG_PROPAGATE_EXCEPTIONS: bool = ...
# People who get code error notifications.
# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
ADMINS: List[Tuple[str, str]] = ...
# List of IP addresses, as strings, that:
# * See debug comments, when DEBUG is true
# * Receive x-headers
INTERNAL_IPS: List[str] = ...
# Hosts/domain names that are valid for this site.
# "*" matches anything, ".example.com" matches example.com and all subdomains
ALLOWED_HOSTS: List[str] = ...
# Local time zone for this installation. All choices can be found here:
# https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all
# systems may support all possibilities). When USE_TZ is True, this is
# interpreted as the default user time zone.
TIME_ZONE: str = ...
# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ: bool = ...
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE: str = ...
# Languages we provide translations for, out of the box.
LANGUAGES: List[Tuple[str, str]] = ...
# Languages using BiDi (right-to-left) layout
LANGUAGES_BIDI: List[str] = ...
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N: bool = ...
LOCALE_PATHS: List[str] = ...
# Settings for language cookie
LANGUAGE_COOKIE_NAME: str = ...
LANGUAGE_COOKIE_AGE: Optional[int] = ...
LANGUAGE_COOKIE_DOMAIN: Optional[str] = ...
LANGUAGE_COOKIE_PATH: str = ...
# If you set this to True, Django will format dates, numbers and calendars
# according to user current locale.
USE_L10N: bool = ...
# Not-necessarily-technical managers of the site. They get broken link
# notifications and other various emails.
MANAGERS = ADMINS
# Default content type and charset to use for all HttpResponse objects, if a
# MIME type isn't manually specified. These are used to construct the
# Content-Type header.
DEFAULT_CONTENT_TYPE: str = ...
DEFAULT_CHARSET: str = ...
# Encoding of files read from disk (template and initial SQL files).
FILE_CHARSET: str = ...
# Email address that error messages come from.
SERVER_EMAIL: str = ...
# Database connection info. If left empty, will default to the dummy backend.
DATABASES: Dict[str, Dict[str, Any]] = ...
# Classes used to implement DB routing behavior.
class Router(Protocol):
def allow_migrate(self, db, app_label, **hints): ...
DATABASE_ROUTERS: List[Union[str, Router]] = ...
# The email backend to use. For possible shortcuts see django.core.mail.
# The default is to use the SMTP backend.
# Third-party backends can be specified by providing a Python path
# to a module that defines an EmailBackend class.
EMAIL_BACKEND: str = ...
# Host for sending email.
EMAIL_HOST: str = ...
# Port for sending email.
EMAIL_PORT: int = ...
# Whether to send SMTP 'Date' header in the local time zone or in UTC.
EMAIL_USE_LOCALTIME: bool = ...
# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER: str = ...
EMAIL_HOST_PASSWORD: str = ...
EMAIL_USE_TLS: bool = ...
EMAIL_USE_SSL: bool = ...
EMAIL_SSL_CERTFILE: Optional[str] = ...
EMAIL_SSL_KEYFILE: Optional[str] = ...
EMAIL_TIMEOUT: Optional[int] = ...
# List of strings representing installed apps.
INSTALLED_APPS: List[str] = ...
TEMPLATES: List[Dict[str, Any]] = ...
# Default form rendering class.
FORM_RENDERER: str = ...
# Default email address to use for various automated correspondence from
# the site managers.
DEFAULT_FROM_EMAIL: str = ...
# Subject-line prefix for email messages send with django.core.mail.mail_admins
# or ...mail_managers. Make sure to include the trailing space.
EMAIL_SUBJECT_PREFIX: str = ...
# Whether to append trailing slashes to URLs.
APPEND_SLASH: bool = ...
# Whether to prepend the "www." subdomain to URLs that don't have it.
PREPEND_WWW: bool = ...
# Override the server-derived value of SCRIPT_NAME
FORCE_SCRIPT_NAME = None
# List of compiled regular expression objects representing User-Agent strings
# that are not allowed to visit any page, systemwide. Use this for bad
# robots/crawlers. Here are a few examples:
# import re
# DISALLOWED_USER_AGENTS = [
# re.compile(r'^NaverBot.*'),
# re.compile(r'^EmailSiphon.*'),
# re.compile(r'^SiteSucker.*'),
# re.compile(r'^sohu-search'),
# ]
DISALLOWED_USER_AGENTS: List[Pattern] = ...
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:
# import re
# IGNORABLE_404_URLS = [
# re.compile(r'^/apple-touch-icon.*\.png$'),
# re.compile(r'^/favicon.ico$'),
# re.compile(r'^/robots.txt$'),
# re.compile(r'^/phpmyadmin/'),
# re.compile(r'\.(cgi|php|pl)$'),
# ]
IGNORABLE_404_URLS: List[Pattern] = ...
# A secret key for this particular Django installation. Used in secret-key
# hashing algorithms. Set this in your settings, or Django will complain
# loudly.
SECRET_KEY: str = ...
# Default file storage mechanism that holds media.
DEFAULT_FILE_STORAGE: str = ...
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT: str = ...
# URL that handles the media served from MEDIA_ROOT.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL: str = ...
# Absolute path to the directory static files should be collected to.
# Example: "/var/www/example.com/static/"
STATIC_ROOT: Optional[str] = ...
# URL that handles the static files served from STATIC_ROOT.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL: Optional[str] = ...
# List of upload handler classes to be applied in order.
FILE_UPLOAD_HANDLERS: List[str] = ...
# Maximum size, in bytes, of a request before it will be streamed to the
# file system instead of into memory.
FILE_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB
# Maximum size in bytes of request data (excluding file uploads) that will be
# read before a SuspiciousOperation (RequestDataTooBig) is raised.
DATA_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB
# Maximum number of GET/POST parameters that will be read before a
# SuspiciousOperation (TooManyFieldsSent) is raised.
DATA_UPLOAD_MAX_NUMBER_FIELDS: int = ...
# Directory in which upload streamed files will be temporarily saved. A value of
# `None` will make Django use the operating system's default temporary directory
# (i.e. "/tmp" on *nix systems).
FILE_UPLOAD_TEMP_DIR: Optional[str] = ...
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https://docs.python.org/library/os.html#files-and-directories.
FILE_UPLOAD_PERMISSIONS = None
# The numeric mode to assign to newly-created directories, when uploading files.
# The value should be a mode as you'd pass to os.chmod;
# see https://docs.python.org/library/os.html#files-and-directories.
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
# Python module path where user will place custom format definition.
# The directory where this setting is pointing should contain subdirectories
# named as the locales, containing a formats.py file
# (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use)
FORMAT_MODULE_PATH: Optional[str] = ...
# Default formatting for date objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT: str = ...
# Default formatting for datetime objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATETIME_FORMAT: str = ...
# Default formatting for time objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
TIME_FORMAT: str = ...
# Default formatting for date objects when only the year and month are relevant.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
YEAR_MONTH_FORMAT: str = ...
# Default formatting for date objects when only the month and day are relevant.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
MONTH_DAY_FORMAT: str = ...
# Default short formatting for date objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATE_FORMAT: str = ...
# Default short formatting for datetime objects.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATETIME_FORMAT: str = ...
# Default formats to be used when parsing dates from input boxes, in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
DATE_INPUT_FORMATS: List[str] = ...
# Default formats to be used when parsing times from input boxes, in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
TIME_INPUT_FORMATS: List[str] = ... # '14:30:59' # '14:30:59.000200' # '14:30'
# Default formats to be used when parsing dates and times from input boxes,
# in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
DATETIME_INPUT_FORMATS: List[str] = ...
# First day of week, to be used on calendars
# 0 means Sunday, 1 means Monday...
FIRST_DAY_OF_WEEK: int = ...
# Decimal separator symbol
DECIMAL_SEPARATOR: str = ...
# Boolean that sets whether to add thousand separator when formatting numbers
USE_THOUSAND_SEPARATOR: bool = ...
# Number of digits that will be together, when splitting them by
# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
NUMBER_GROUPING: int = ...
# Thousand separator symbol
THOUSAND_SEPARATOR: str = ...
# The tablespaces to use for each model when not specified otherwise.
DEFAULT_TABLESPACE: str = ...
DEFAULT_INDEX_TABLESPACE: str = ...
# Default X-Frame-Options header value
X_FRAME_OPTIONS: str = ...
USE_X_FORWARDED_HOST: bool = ...
USE_X_FORWARDED_PORT: bool = ...
# The Python dotted path to the WSGI application that Django's internal server
# (runserver) will use. If `None`, the return value of
# 'django.core.wsgi.get_wsgi_application' is used, thus preserving the same
# behavior as previous versions of Django. Otherwise this should point to an
# actual WSGI application object.
WSGI_APPLICATION: Optional[str] = ...
# If your Django app is behind a proxy that sets a header to specify secure
# connections, AND that proxy ensures that user-submitted headers with the
# same name are ignored (so that people can't spoof it), set this value to
# a tuple of (header_name, header_value). For any requests that come in with
# that header/value, request.is_secure() will return True.
# WARNING! Only set this if you fully understand what you're doing. Otherwise,
# you may be opening yourself up to a security risk.
SECURE_PROXY_SSL_HEADER: Optional[Tuple[str, str]] = ...
##############
# MIDDLEWARE #
##############
# List of middleware to use. Order is important; in the request phase, these
# middleware will be applied in the order given, and in the response
# phase the middleware will be applied in reverse order.
MIDDLEWARE: List[str] = ...
############
# SESSIONS #
############
# Cache to store session data if using the cache session backend.
SESSION_CACHE_ALIAS = "default"
# Cookie name. This can be whatever you want.
SESSION_COOKIE_NAME = "sessionid"
# Age of cookie, in seconds (default: 2 weeks).
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
# A string like "example.com", or None for standard domain cookie.
SESSION_COOKIE_DOMAIN: Optional[str] = ...
# Whether the session cookie should be secure (https:// only).
SESSION_COOKIE_SECURE = False
# The path of the session cookie.
SESSION_COOKIE_PATH = "/"
# Whether to use the non-RFC standard httpOnly flag (IE, FF3+, others)
SESSION_COOKIE_HTTPONLY = True
# Whether to set the flag restricting cookie leaks on cross-site requests.
# This can be 'Lax', 'Strict', or None to disable the flag.
SESSION_COOKIE_SAMESITE: Optional[str] = ...
# Whether to save the session data on every request.
SESSION_SAVE_EVERY_REQUEST = False
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
# The module to store session data
SESSION_ENGINE = "django.contrib.sessions.backends.db"
# Directory to store session files if using the file session module. If None,
# the backend will use a sensible default.
SESSION_FILE_PATH: Optional[str] = ...
# class to serialize session data
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
#########
# CACHE #
#########
# The cache backends to use.
CACHES: Dict[str, Dict[str, Any]] = ...
CACHE_MIDDLEWARE_KEY_PREFIX = ""
CACHE_MIDDLEWARE_SECONDS = 600
CACHE_MIDDLEWARE_ALIAS = "default"
##################
# AUTHENTICATION #
##################
AUTH_USER_MODEL: str = ...
AUTHENTICATION_BACKENDS: Sequence[str] = ...
LOGIN_URL = "/accounts/login/"
LOGIN_REDIRECT_URL: str = ...
LOGOUT_REDIRECT_URL: Optional[str] = ...
# The number of days a password reset link is valid for
PASSWORD_RESET_TIMEOUT_DAYS = 3
# the first hasher in this list is the preferred algorithm. any
# password using different algorithms will be converted automatically
# upon login
PASSWORD_HASHERS: List[str] = ...
AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] = ...
###########
# SIGNING #
###########
SIGNING_BACKEND = "django.core.signing.TimestampSigner"
########
# CSRF #
########
# Dotted path to callable to be used as view when a request is
# rejected by the CSRF middleware.
CSRF_FAILURE_VIEW = "django.views.csrf.csrf_failure"
# Settings for CSRF cookie.
CSRF_COOKIE_NAME = "csrftoken"
CSRF_COOKIE_AGE = 60 * 60 * 24 * 7 * 52
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_PATH = "/"
CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_SAMESITE: Optional[str] = ...
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
CSRF_TRUSTED_ORIGINS: List[str] = ...
CSRF_USE_SESSIONS = False
############
# MESSAGES #
############
# Class to use as messages backend
MESSAGE_STORAGE = "django.contrib.messages.storage.fallback.FallbackStorage"
# Default values of MESSAGE_LEVEL and MESSAGE_TAGS are defined within
# django.contrib.messages to avoid imports in this settings file.
###########
# LOGGING #
###########
# The callable to use to configure logging
LOGGING_CONFIG = "logging.config.dictConfig"
# Custom logging configuration.
LOGGING: Dict[str, Any] = ...
# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
DEFAULT_EXCEPTION_REPORTER_FILTER = "django.views.debug.SafeExceptionReporterFilter"
###########
# TESTING #
###########
# The name of the class to use to run the test suite
TEST_RUNNER = "django.test.runner.DiscoverRunner"
# Apps that don't need to be serialized at test database creation time
# (only apps with migrations are to start with)
TEST_NON_SERIALIZED_APPS: List[str] = ...
############
# FIXTURES #
############
# The list of directories to search for fixtures
FIXTURE_DIRS: List[str] = ...
###############
# STATICFILES #
###############
# A list of locations of additional static files
STATICFILES_DIRS: List[str] = ...
# The default file storage backend used during the build process
STATICFILES_STORAGE: str = ...
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS: List[str] = ...
##############
# MIGRATIONS #
##############
# Migration module overrides for apps, by app label.
MIGRATION_MODULES: Dict[str, str] = ...
#################
# SYSTEM CHECKS #
#################
# List of all issues generated by system checks that should be silenced. Light
# issues like warnings, infos or debugs will not generate a message. Silencing
# serious issues like errors and criticals does not result in hiding the
# message, but Django will not stop you from e.g. running server.
SILENCED_SYSTEM_CHECKS: List[str] = ...
#######################
# SECURITY MIDDLEWARE #
#######################
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_REDIRECT_EXEMPT: List[str] = ...
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False

View File

@@ -1,3 +0,0 @@
from typing import Dict, Any
LANG_INFO: Dict[str, Any] = ...

View File

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

View File

@@ -1,5 +1,5 @@
from .decorators import register as register
from .filters import (
from django.contrib.admin.decorators import register as register
from django.contrib.admin.filters import (
AllValuesFieldListFilter as AllValuesFieldListFilter,
BooleanFieldListFilter as BooleanFieldListFilter,
ChoicesFieldListFilter as ChoicesFieldListFilter,
@@ -10,15 +10,14 @@ from .filters import (
RelatedOnlyFieldListFilter as RelatedOnlyFieldListFilter,
SimpleListFilter as SimpleListFilter,
)
from .helpers import ACTION_CHECKBOX_NAME as ACTION_CHECKBOX_NAME
from .options import (
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME as ACTION_CHECKBOX_NAME
from django.contrib.admin.options import (
HORIZONTAL as HORIZONTAL,
VERTICAL as VERTICAL,
ModelAdmin as ModelAdmin,
StackedInline as StackedInline,
TabularInline as TabularInline,
)
from .sites import AdminSite as AdminSite, site as site
from . import checks as checks
from django.contrib.admin.sites import AdminSite as AdminSite, site as site
def autodiscover() -> None: ...

View File

@@ -1,6 +1,25 @@
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): ...
class AdminConfig(SimpleAdminConfig):
apps: None
label: str
models: None
models_module: None
module: Any
name: str
path: str
def ready(self) -> None: ...

View File

@@ -1,20 +1,21 @@
from typing import Any, List, Union, Iterable, Optional
from typing import Any, List, Union
from django.contrib.admin.options import BaseModelAdmin
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin
from django.core.checks.messages import Error
from django.apps.config import AppConfig
_CheckError = Union[str, Error]
def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[_CheckError]: ...
def check_admin_app(app_configs: None, **kwargs: Any) -> List[_CheckError]: ...
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
class BaseModelAdminChecks:
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
class ModelAdminChecks(BaseModelAdminChecks): ...
class InlineModelAdminChecks(BaseModelAdminChecks): ...
class ModelAdminChecks(BaseModelAdminChecks):
def check(self, admin_obj: ModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
class InlineModelAdminChecks(BaseModelAdminChecks):
def check(self, inline_obj: InlineModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
def must_be(type: Any, option: Any, obj: Any, id: Any): ...
def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any): ...

View File

@@ -1,5 +1,3 @@
from typing import Any, Callable, Optional, Type
from typing import Any, Callable, Optional
from django.db.models.base import Model
def register(*models: Type[Model], site: Optional[Any] = ...) -> Callable: ...
def register(*models: Any, site: Optional[Any] = ...) -> Callable: ...

View File

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

View File

@@ -1,7 +1,33 @@
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 = ...

View File

@@ -1,17 +1,27 @@
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Iterable
import collections
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Type
from django import forms
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.forms.boundfield import BoundField
from django.forms.utils import ErrorDict
from django.db.models.fields import AutoField
from django.forms.utils import ErrorDict, ErrorList
from django.forms.widgets import Media, Widget
from django.utils.safestring import SafeText
from django import forms
from django.db.models.fields import AutoField
from django.forms.boundfield import BoundField
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 = ...
@@ -26,8 +36,8 @@ class AdminForm:
form: AdminPasswordChangeForm,
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
prepopulated_fields: Dict[Any, Any],
readonly_fields: Optional[Iterable[Any]] = ...,
model_admin: Any = ...,
readonly_fields: None = ...,
model_admin: None = ...,
) -> None: ...
def __iter__(self) -> Iterator[Fieldset]: ...
@property
@@ -47,7 +57,7 @@ class Fieldset:
self,
form: Any,
name: Optional[Any] = ...,
readonly_fields: Optional[Iterable[Any]] = ...,
readonly_fields: Any = ...,
fields: Any = ...,
classes: Any = ...,
description: Optional[Any] = ...,
@@ -64,7 +74,7 @@ class Fieldline:
model_admin: Any = ...
readonly_fields: Any = ...
def __init__(
self, form: Any, field: Any, readonly_fields: Optional[Iterable[Any]] = ..., model_admin: Optional[Any] = ...
self, form: Any, field: Any, readonly_fields: Optional[Any] = ..., model_admin: Optional[Any] = ...
) -> None: ...
def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ...
def errors(self) -> SafeText: ...
@@ -127,6 +137,7 @@ class InlineAdminFormSet:
class InlineAdminForm(AdminForm):
formset: Any = ...
model_admin: Any = ...
original: Any = ...
show_url: Any = ...
absolute_url: Any = ...
@@ -141,6 +152,7 @@ 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: ...
@@ -150,6 +162,9 @@ 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: ...

View File

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

View File

@@ -1,13 +1,13 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
from django.contrib.admin.filters import ListFilter
from django.contrib.admin.models import LogEntry
from django.contrib.admin.sites import AdminSite
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import Error
from django.core.handlers.wsgi import WSGIRequest
from django.core.paginator import Paginator
from django.db.models.base import Model
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
@@ -16,9 +16,7 @@ from django.db.models.query import QuerySet
from django.forms.fields import TypedChoiceField
from django.forms.models import ModelChoiceField, ModelMultipleChoiceField
from django.forms.widgets import Media
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase, HttpResponseRedirect, JsonResponse
from django.template.response import TemplateResponse
from django.urls.resolvers import URLPattern
from django.utils.safestring import SafeText
@@ -56,58 +54,59 @@ class BaseModelAdmin:
show_full_result_count: bool = ...
checks_class: Any = ...
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
def formfield_for_dbfield(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[Field]: ...
def formfield_for_choice_field(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> TypedChoiceField: ...
def get_field_queryset(
self, db: None, db_field: RelatedField, request: Optional[HttpRequest]
) -> Optional[QuerySet]: ...
def __init__(self) -> None: ...
def formfield_for_dbfield(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> Optional[Field]: ...
def formfield_for_choice_field(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> TypedChoiceField: ...
def get_field_queryset(self, db: None, db_field: RelatedField, request: WSGIRequest) -> Optional[QuerySet]: ...
def formfield_for_foreignkey(
self, db_field: ForeignKey, request: Optional[HttpRequest], **kwargs: Any
self, db_field: ForeignKey, request: WSGIRequest, **kwargs: Any
) -> Optional[ModelChoiceField]: ...
def formfield_for_manytomany(
self, db_field: ManyToManyField, request: Optional[HttpRequest], **kwargs: Any
self, db_field: ManyToManyField, request: WSGIRequest, **kwargs: Any
) -> ModelMultipleChoiceField: ...
def get_autocomplete_fields(self, request: HttpRequest) -> Tuple: ...
def get_autocomplete_fields(self, request: WSGIRequest) -> Tuple: ...
def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ...
def get_empty_value_display(self) -> SafeText: ...
def get_exclude(self, request: HttpRequest, obj: Optional[Model] = ...) -> Any: ...
def get_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Sequence[Union[Callable, str]]: ...
def get_exclude(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
def get_fields(
self, request: WSGIRequest, obj: Optional[Model] = ...
) -> Union[List[Union[Callable, str]], Tuple[str, str]]: ...
def get_fieldsets(
self, request: HttpRequest, obj: Optional[Model] = ...
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
def get_ordering(self, request: HttpRequest) -> Union[List[str], Tuple]: ...
def get_readonly_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
def get_prepopulated_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
def get_queryset(self, request: HttpRequest) -> QuerySet: ...
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
self, request: WSGIRequest, obj: Optional[Model] = ...
) -> Union[
List[Tuple[None, Dict[str, List[Union[Callable, str]]]]],
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
]: ...
def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
def get_readonly_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
def get_prepopulated_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def get_sortable_by(self, request: WSGIRequest) -> Union[List[Callable], List[str], Tuple]: ...
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ...
def has_add_permission(self, request: HttpRequest) -> bool: ...
def has_change_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_module_permission(self, request: HttpRequest) -> bool: ...
def to_field_allowed(self, request: WSGIRequest, to_field: str) -> bool: ...
def has_add_permission(self, request: WSGIRequest) -> bool: ...
def has_change_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_module_permission(self, request: WSGIRequest) -> bool: ...
class ModelAdmin(BaseModelAdmin):
list_display: Sequence[Union[str, Callable]] = ...
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
list_select_related: Union[bool, Sequence[str]] = ...
formfield_overrides: Any
list_display: Sequence[str] = ...
list_display_links: Sequence[str] = ...
list_filter: Sequence[str] = ...
list_select_related: Sequence[str] = ...
list_per_page: int = ...
list_max_show_all: int = ...
list_editable: Sequence[str] = ...
search_fields: Sequence[str] = ...
date_hierarchy: Optional[Any] = ...
search_fields: Any = ...
date_hierarchy: Any = ...
save_as: bool = ...
save_as_continue: bool = ...
save_on_top: bool = ...
paginator: Any = ...
preserve_filters: bool = ...
inlines: Sequence[Type[InlineModelAdmin]] = ...
inlines: Any = ...
add_form_template: Any = ...
change_form_template: Any = ...
change_list_template: Any = ...
@@ -120,58 +119,69 @@ class ModelAdmin(BaseModelAdmin):
actions_on_top: bool = ...
actions_on_bottom: bool = ...
actions_selection_counter: bool = ...
checks_class: Any = ...
model: Type[Model] = ...
opts: Options = ...
admin_site: AdminSite = ...
def __init__(self, model: Type[Model], admin_site: Optional[AdminSite]) -> None: ...
def get_inline_instances(self, request: HttpRequest, obj: Optional[Model] = ...) -> List[InlineModelAdmin]: ...
def get_inline_instances(self, request: WSGIRequest, obj: Optional[Model] = ...) -> List[InlineModelAdmin]: ...
def get_urls(self) -> List[URLPattern]: ...
@property
def urls(self) -> List[URLPattern]: ...
@property
def media(self) -> Media: ...
def get_model_perms(self, request: HttpRequest) -> Dict[str, bool]: ...
def get_model_perms(self, request: WSGIRequest) -> Dict[str, bool]: ...
def get_form(self, request: Any, obj: Optional[Any] = ..., change: bool = ..., **kwargs: Any): ...
def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ...
def get_changelist_instance(self, request: HttpRequest) -> ChangeList: ...
def get_object(self, request: HttpRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
def get_changelist(self, request: WSGIRequest, **kwargs: Any) -> Type[ChangeList]: ...
def get_changelist_instance(self, request: WSGIRequest) -> ChangeList: ...
def get_object(self, request: WSGIRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
def get_changelist_form(self, request: Any, **kwargs: Any): ...
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
def get_formsets_with_inlines(self, request: HttpRequest, obj: Optional[Model] = ...) -> Iterator[Any]: ...
def get_formsets_with_inlines(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
def get_paginator(
self,
request: HttpRequest,
request: WSGIRequest,
queryset: QuerySet,
per_page: int,
orphans: int = ...,
allow_empty_first_page: bool = ...,
) -> Paginator: ...
def log_addition(self, request: HttpRequest, object: Model, message: Any) -> LogEntry: ...
def log_change(self, request: HttpRequest, object: Model, message: Any) -> LogEntry: ...
def log_deletion(self, request: HttpRequest, object: Model, object_repr: str) -> LogEntry: ...
def log_addition(
self,
request: WSGIRequest,
object: Model,
message: Union[Dict[str, Dict[Any, Any]], List[Dict[str, Dict[str, str]]]],
) -> LogEntry: ...
def log_change(
self,
request: WSGIRequest,
object: Model,
message: Union[Dict[str, Dict[str, List[str]]], List[Dict[str, Dict[str, Union[List[str], str]]]]],
) -> LogEntry: ...
def log_deletion(self, request: WSGIRequest, object: Model, object_repr: str) -> LogEntry: ...
def action_checkbox(self, obj: Model) -> SafeText: ...
def get_actions(self, request: HttpRequest) -> OrderedDict: ...
def get_actions(self, request: WSGIRequest) -> OrderedDict: ...
def get_action_choices(
self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ...
self, request: WSGIRequest, default_choices: List[Tuple[str, str]] = ...
) -> List[Tuple[str, str]]: ...
def get_action(self, action: Union[Callable, str]) -> Tuple[Callable, str, str]: ...
def get_list_display(self, request: HttpRequest) -> Sequence[str]: ...
def get_list_display_links(self, request: HttpRequest, list_display: Sequence[str]) -> Optional[Sequence[str]]: ...
def get_list_filter(self, request: HttpRequest) -> Sequence[str]: ...
def get_list_select_related(self, request: HttpRequest) -> Sequence[str]: ...
def get_search_fields(self, request: HttpRequest) -> List[str]: ...
def get_list_display(self, request: WSGIRequest) -> Sequence[str]: ...
def get_list_display_links(self, request: WSGIRequest, list_display: Sequence[str]) -> Optional[Sequence[str]]: ...
def get_list_filter(self, request: WSGIRequest) -> Sequence[str]: ...
def get_list_select_related(self, request: WSGIRequest) -> Sequence[str]: ...
def get_search_fields(self, request: WSGIRequest) -> List[str]: ...
def get_search_results(
self, request: HttpRequest, queryset: QuerySet, search_term: str
self, request: WSGIRequest, queryset: QuerySet, search_term: str
) -> Tuple[QuerySet, bool]: ...
def get_preserved_filters(self, request: HttpRequest) -> str: ...
def _get_edited_object_pks(self, request: HttpRequest, prefix: str) -> List[str]: ...
def _get_list_editable_queryset(self, request: HttpRequest, prefix: str) -> QuerySet: ...
def get_preserved_filters(self, request: WSGIRequest) -> str: ...
def _get_edited_object_pks(self, request: WSGIRequest, prefix: str) -> List[str]: ...
def _get_list_editable_queryset(self, request: WSGIRequest, prefix: str) -> QuerySet: ...
def construct_change_message(
self, request: HttpRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
self, request: WSGIRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
) -> List[Dict[str, Dict[str, List[str]]]]: ...
def message_user(
self,
request: HttpRequest,
request: WSGIRequest,
message: str,
level: Union[int, str] = ...,
extra_tags: str = ...,
@@ -179,8 +189,8 @@ class ModelAdmin(BaseModelAdmin):
) -> None: ...
def save_form(self, request: Any, form: Any, change: Any): ...
def save_model(self, request: Any, obj: Any, form: Any, change: Any) -> None: ...
def delete_model(self, request: HttpRequest, obj: Model) -> None: ...
def delete_queryset(self, request: HttpRequest, queryset: QuerySet) -> None: ...
def delete_model(self, request: WSGIRequest, obj: Model) -> None: ...
def delete_queryset(self, request: WSGIRequest, queryset: QuerySet) -> None: ...
def save_formset(self, request: Any, form: Any, formset: Any, change: Any) -> None: ...
def save_related(self, request: Any, form: Any, formsets: Any, change: Any) -> None: ...
def render_change_form(
@@ -193,51 +203,52 @@ class ModelAdmin(BaseModelAdmin):
obj: Optional[Any] = ...,
): ...
def response_add(
self, request: HttpRequest, obj: Model, post_url_continue: Optional[str] = ...
self, request: WSGIRequest, obj: Model, post_url_continue: Optional[str] = ...
) -> HttpResponse: ...
def response_change(self, request: HttpRequest, obj: Model) -> HttpResponse: ...
def response_post_save_add(self, request: HttpRequest, obj: Model) -> HttpResponseRedirect: ...
def response_post_save_change(self, request: HttpRequest, obj: Model) -> HttpResponseRedirect: ...
def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
def response_change(self, request: WSGIRequest, obj: Model) -> HttpResponse: ...
def response_post_save_add(self, request: WSGIRequest, obj: Model) -> HttpResponseRedirect: ...
def response_post_save_change(self, request: WSGIRequest, obj: Model) -> HttpResponseRedirect: ...
def response_action(self, request: WSGIRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
def response_delete(self, request: WSGIRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
def render_delete_form(self, request: Any, context: Any): ...
def get_inline_formsets(
self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[Model] = ...
self, request: WSGIRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[Model] = ...
) -> List[Any]: ...
def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str]: ...
def get_changeform_initial_data(self, request: WSGIRequest) -> Dict[str, str]: ...
def changeform_view(
self,
request: HttpRequest,
request: WSGIRequest,
object_id: Optional[str] = ...,
form_url: str = ...,
extra_context: Optional[Dict[str, bool]] = ...,
) -> Any: ...
def autocomplete_view(self, request: HttpRequest) -> JsonResponse: ...
def add_view(self, request: HttpRequest, form_url: str = ..., extra_context: None = ...) -> HttpResponse: ...
def autocomplete_view(self, request: WSGIRequest) -> JsonResponse: ...
def add_view(self, request: WSGIRequest, form_url: str = ..., extra_context: None = ...) -> HttpResponse: ...
def change_view(
self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: Optional[Dict[str, bool]] = ...
self, request: WSGIRequest, object_id: str, form_url: str = ..., extra_context: Optional[Dict[str, bool]] = ...
) -> HttpResponse: ...
def changelist_view(
self, request: HttpRequest, extra_context: Optional[Dict[str, str]] = ...
) -> TemplateResponse: ...
self, request: WSGIRequest, extra_context: Optional[Dict[str, str]] = ...
) -> HttpResponseBase: ...
def get_deleted_objects(
self, objs: QuerySet, request: HttpRequest
self, objs: QuerySet, request: WSGIRequest
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
def delete_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> Any: ...
def history_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
def delete_view(self, request: WSGIRequest, object_id: str, extra_context: None = ...) -> Any: ...
def history_view(self, request: WSGIRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
class InlineModelAdmin(BaseModelAdmin):
model: Any = ...
fk_name: Any = ...
formset: Any = ...
extra: int = ...
min_num: Optional[int] = ...
max_num: Optional[int] = ...
template: str = ...
verbose_name: Optional[str] = ...
verbose_name_plural: Optional[str] = ...
min_num: Any = ...
max_num: Any = ...
template: Any = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
can_delete: bool = ...
show_change_link: bool = ...
checks_class: Any = ...
classes: Any = ...
admin_site: Any = ...
parent_model: Any = ...
@@ -246,10 +257,18 @@ class InlineModelAdmin(BaseModelAdmin):
def __init__(self, parent_model: Union[Type[Model], Model], admin_site: AdminSite) -> None: ...
@property
def media(self) -> Media: ...
def get_extra(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> int: ...
def get_min_num(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
def get_max_num(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
def get_extra(self, request: WSGIRequest, obj: Optional[Model] = ..., **kwargs: Any) -> int: ...
def get_min_num(self, request: WSGIRequest, obj: Optional[Model] = ..., **kwargs: Any) -> None: ...
def get_max_num(self, request: WSGIRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
fields: Any = ...
def get_formset(self, request: Any, obj: Optional[Any] = ..., **kwargs: Any): ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def has_change_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
class StackedInline(InlineModelAdmin): ...
class TabularInline(InlineModelAdmin): ...
class StackedInline(InlineModelAdmin):
template: str = ...
class TabularInline(InlineModelAdmin):
template: str = ...

View File

@@ -1,15 +1,13 @@
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.http.response import HttpResponse
from django.template.response import TemplateResponse
from django.urls.resolvers import URLResolver
from django.urls.resolvers import URLPattern, URLResolver
from django.utils.functional import LazyObject
from django.apps.config import AppConfig
all_sites: Any
class AlreadyRegistered(Exception): ...
@@ -30,16 +28,16 @@ class AdminSite:
name: str = ...
_registry: Dict[Type[Model], ModelAdmin]
def __init__(self, name: str = ...) -> None: ...
def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[Any]: ...
def check(self, app_configs: None) -> List[Any]: ...
def register(
self,
model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
model_or_iterable: Union[List[Type[Model]], Tuple[Type[Model]], Type[Model]],
admin_class: Optional[Type[ModelAdmin]] = ...,
**options: Any
) -> None: ...
def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
def unregister(self, model_or_iterable: Type[Model]) -> None: ...
def is_registered(self, model: Type[Model]) -> bool: ...
def add_action(self, action: Callable, name: Optional[str] = ...) -> None: ...
def add_action(self, action: Callable, name: None = ...) -> None: ...
def disable_action(self, name: str) -> None: ...
def get_action(self, name: str) -> Callable: ...
@property
@@ -54,20 +52,14 @@ class AdminSite:
@property
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
def each_context(self, request: Any): ...
def password_change(
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def password_change_done(
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def password_change(self, request: WSGIRequest, extra_context: Dict[str, str] = ...) -> TemplateResponse: ...
def password_change_done(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[Any, Any]] = ...) -> HttpResponse: ...
def logout(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def login(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def logout(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...
def login(self, request: WSGIRequest, extra_context: None = ...) -> HttpResponse: ...
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def app_index(
self, request: WSGIRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, str]] = ...) -> TemplateResponse: ...
def app_index(self, request: WSGIRequest, app_label: str, extra_context: None = ...) -> TemplateResponse: ...
class DefaultAdminSite(LazyObject): ...

View File

@@ -27,12 +27,12 @@ class ResultList(list):
def results(cl: ChangeList) -> Iterator[ResultList]: ...
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
def result_list(
cl: ChangeList,
cl: ChangeList
) -> Dict[
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
]: ...
def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Any]]: ...
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Union[Dict[str, str], List[Dict[str, str]], bool]]]: ...
def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ...
def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...

View File

@@ -1,6 +1,7 @@
from typing import Any
from typing import Any, Optional
from django.contrib.admin.helpers import InlineAdminForm
from django.contrib.admin.templatetags.base import InclusionAdminNode
from django.template.base import Parser, Token
from django.template.context import Context, RequestContext

View File

@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Optional
register: Any

View File

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

View File

@@ -1,23 +0,0 @@
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: ...

View File

@@ -1,6 +1,5 @@
import collections
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
from uuid import UUID
from django.contrib.admin.options import BaseModelAdmin
@@ -9,23 +8,30 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.deletion import Collector
from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, OneToOneRel
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.forms import BaseForm
from django.db.models.fields import Field, reverse_related
from django.utils.safestring import SafeText
class FieldIsAForeignKeyColumnName(Exception): ...
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
def prepare_lookup_value(key: str, value: Union[datetime, str]) -> Union[bool, datetime, str]: ...
def quote(s: Union[int, str, UUID]) -> str: ...
def quote(s: Union[int, str, UUID]) -> Union[int, str, UUID]: ...
def unquote(s: str) -> str: ...
def flatten(fields: Any) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
def flatten(
fields: Union[List[Union[Callable, str]], List[Union[List[str], str]], List[Union[Tuple[str, str], str]], Tuple]
) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(
fieldsets: Union[
List[Tuple[Optional[str], Dict[str, Tuple[str]]]],
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
]
) -> List[Union[Callable, str]]: ...
def get_deleted_objects(
objs: Sequence[Optional[Model]], request: WSGIRequest, admin_site: AdminSite
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
class NestedObjects(Collector):
@@ -39,30 +45,36 @@ class NestedObjects(Collector):
model_objs: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
def related_objects(self, related: ManyToOneRel, objs: Sequence[Optional[Model]]) -> QuerySet: ...
def nested(self, format_callback: Callable = ...) -> List[Any]: ...
def collect(
self,
objs: Union[List[Model], QuerySet],
source: Optional[Type[Model]] = ...,
source_attr: Optional[str] = ...,
**kwargs: Any
) -> None: ...
def related_objects(self, related: ManyToOneRel, objs: List[Model]) -> QuerySet: ...
def nested(self, format_callback: Callable = ...) -> Union[List[SafeText], List[int]]: ...
def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ...
def model_format_dict(obj: Any): ...
def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ...
def lookup_field(
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
) -> Tuple[Optional[Field], Any, Any]: ...
) -> Tuple[Optional[Field], Callable, Callable]: ...
def label_for_field(
name: Union[Callable, str],
model: Type[Model],
model_admin: Optional[BaseModelAdmin] = ...,
return_attr: bool = ...,
form: Optional[BaseForm] = ...,
name: Union[Callable, str], model: Type[Model], model_admin: Optional[BaseModelAdmin] = ..., return_attr: bool = ...
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
def help_text_for_field(name: str, model: Type[Model]) -> str: ...
def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ...
def display_for_field(
value: Any, field: Union[Field, reverse_related.OneToOneRel], empty_value_display: str
) -> str: ...
def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ...
class NotRelationField(Exception): ...
def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel]) -> Type[Model]: ...
def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ...
def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ...
def get_fields_from_path(model: Type[Model], path: str) -> List[Union[Field, FieldCacheMixin]]: ...
def construct_change_message(
form: AdminPasswordChangeForm, formsets: None, add: bool
) -> List[Dict[str, Dict[str, List[str]]]]: ...

View File

@@ -1,10 +1,18 @@
from typing import Any
from typing import Any, Optional
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: ...

View File

@@ -1,7 +1,5 @@
from typing import Callable, TypeVar, overload
from typing import Any, Callable, Optional
_C = TypeVar("_C", bound=Callable)
@overload
def staff_member_required(view_func: _C = ..., redirect_field_name: str = ..., login_url: str = ...) -> _C: ...
@overload
def staff_member_required(view_func: None = ..., redirect_field_name: str = ..., login_url: str = ...) -> Callable: ...
def staff_member_required(
view_func: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: str = ...
) -> Callable: ...

View File

@@ -2,11 +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 ( # noqa: F401
ModelAdmin,
IS_POPUP_VAR as IS_POPUP_VAR,
TO_FIELD_VAR as TO_FIELD_VAR,
)
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
@@ -81,7 +77,9 @@ class ChangeList:
paginator: Any = ...
def get_results(self, request: WSGIRequest) -> None: ...
def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[CombinedExpression, str]]: ...
def get_ordering(self, request: WSGIRequest, queryset: QuerySet) -> List[Union[OrderBy, Combinable, str]]: ...
def get_ordering(
self, request: WSGIRequest, queryset: QuerySet
) -> Union[List[Union[Combinable, str]], List[Union[OrderBy, str]]]: ...
def get_ordering_field_columns(self) -> OrderedDict: ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def apply_select_related(self, qs: QuerySet) -> QuerySet: ...

View File

@@ -1,12 +1,16 @@
from typing import Any, Dict, Optional, Tuple, Union
from collections import OrderedDict
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, 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
from django.db.models.query_utils import Q
from django.forms.fields import Field
from django.forms.widgets import ChoiceWidget, Media, Widget
from django.http.request import QueryDict
from django.utils.datastructures import MultiValueDict
class FilteredSelectMultiple(forms.SelectMultiple):
@property
@@ -14,37 +18,112 @@ 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): ...
class AdminRadioSelect(forms.RadioSelect): ...
class AdminFileWidget(forms.ClearableFileInput): ...
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,
],
]: ...
def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ...
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]: ...
class ForeignKeyRawIdWidget(forms.TextInput):
rel: ManyToOneRel = ...
attrs: Dict[Any, Any]
template_name: str = ...
rel: django.db.models.fields.reverse_related.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): ...
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
admin_site: AdminSite
attrs: Dict[Any, Any]
db: None
rel: django.db.models.fields.reverse_related.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 RelatedFieldWidgetWrapper(forms.Widget):
template_name: str = ...
needs_multipart_form: bool = ...
attrs: Dict[Any, Any] = ...
choices: ModelChoiceIterator = ...
widget: forms.Widget = ...
rel: ManyToOneRel = ...
widget: django.contrib.admin.widgets.AutocompleteSelect = ...
rel: django.db.models.fields.reverse_related.ManyToOneRel = ...
can_add_related: bool = ...
can_change_related: bool = ...
can_delete_related: bool = ...
@@ -52,7 +131,7 @@ class RelatedFieldWidgetWrapper(forms.Widget):
admin_site: AdminSite = ...
def __init__(
self,
widget: forms.Widget,
widget: ChoiceWidget,
rel: ForeignObjectRel,
admin_site: AdminSite,
can_add_related: Optional[bool] = ...,
@@ -60,22 +139,54 @@ 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): ...
class AdminTextInputWidget(forms.TextInput): ...
class AdminEmailInputWidget(forms.EmailInput): ...
class AdminURLFieldWidget(forms.URLInput): ...
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 AdminIntegerFieldWidget(forms.NumberInput):
attrs: Dict[str, str]
input_type: str
class_name: str = ...
def __init__(self, attrs: None = ...) -> None: ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
class AdminUUIDInputWidget(forms.TextInput):
def __init__(self, attrs: Optional[Dict[str, str]] = ...) -> None: ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
class_name: str = ...
SELECT2_TRANSLATIONS: Any
@@ -95,6 +206,12 @@ 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: ...

View File

@@ -1,3 +0,0 @@
from typing import Any, List
urlpatterns: List[Any] = ...

View File

@@ -3,17 +3,46 @@ from typing import Any, Optional, Union
from django.db.models.fields import Field
from django.views.generic import TemplateView
from .utils import get_view_name
MODEL_METHODS_EXCLUDE: Any
class BaseAdminDocsView(TemplateView): ...
class BookmarkletsView(BaseAdminDocsView): ...
class TemplateTagIndexView(BaseAdminDocsView): ...
class TemplateFilterIndexView(BaseAdminDocsView): ...
class ViewIndexView(BaseAdminDocsView): ...
class ViewDetailView(BaseAdminDocsView): ...
class ModelIndexView(BaseAdminDocsView): ...
class ModelDetailView(BaseAdminDocsView): ...
class TemplateDetailView(BaseAdminDocsView): ...
class BaseAdminDocsView(TemplateView):
template_name: str = ...
def dispatch(self, request: Any, *args: Any, **kwargs: Any): ...
def get_context_data(self, **kwargs: Any): ...
class BookmarkletsView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class TemplateTagIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class TemplateFilterIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ViewIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ViewDetailView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ModelIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ModelDetailView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class TemplateDetailView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
def get_return_data_type(func_name: Any): ...
def get_readable_field_data_type(field: Union[Field, str]) -> str: ...

View File

@@ -1,18 +1,54 @@
from typing import Any
from typing import Any, Dict, List, Optional, Tuple, Type
from django.contrib.auth.models import User, Group
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.fields.related import ManyToManyField
from django.forms.models import ModelMultipleChoiceField
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): ...
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 UserAdmin(admin.ModelAdmin):
admin_site: AdminSite
formfield_overrides: Dict[
Type[Union[django.db.models.fields.DateTimeCheckMixin, Field]],
Dict[str, Type[Union[django.forms.fields.SplitDateTimeField, Widget]]],
]
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: ...

View File

@@ -1,3 +1,18 @@
from typing import Any, Optional
from django.apps import AppConfig
class AuthConfig(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: ...

View File

@@ -1,34 +1,23 @@
from typing import Any, Optional, Set, Union
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser, User, Permission
from django.db.models.base import Model
_AnyUser = Union[Model, AnonymousUser]
from django.contrib.auth.models import AnonymousUser, User
UserModel: Any
class BaseBackend:
class ModelBackend:
def authenticate(
self, request: Any, username: Optional[str] = ..., password: Optional[str] = ..., **kwargs: Any
self, request: Any, username: Optional[Union[int, str]] = ..., password: Optional[str] = ..., **kwargs: Any
) -> Optional[AbstractBaseUser]: ...
def get_user(self, user_id: int) -> Optional[AbstractBaseUser]: ...
def get_user_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
def get_group_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
def get_all_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
def has_perm(self, user_obj: _AnyUser, perm: str, obj: Optional[Model] = ...) -> bool: ...
class ModelBackend(BaseBackend):
def has_module_perms(self, user_obj: _AnyUser, app_label: str) -> bool: ...
def user_can_authenticate(self, user: Optional[_AnyUser]) -> bool: ...
def with_perm(
self,
perm: Union[str, Permission],
is_active: bool = ...,
include_superusers: bool = ...,
obj: Optional[Model] = ...,
): ...
def user_can_authenticate(self, user: Optional[AbstractBaseUser]) -> bool: ...
def get_user_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ...
def get_group_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ...
def get_all_permissions(self, user_obj: AbstractBaseUser, obj: Optional[str] = ...) -> Set[str]: ...
def has_perm(
self, user_obj: Union[AbstractBaseUser, AnonymousUser], perm: str, obj: Optional[str] = ...
) -> bool: ...
def has_module_perms(self, user_obj: Union[AbstractBaseUser, AnonymousUser], app_label: str) -> bool: ...
def get_user(self, user_id: int) -> AbstractBaseUser: ...
class AllowAllUsersModelBackend(ModelBackend): ...

View File

@@ -1,23 +1,21 @@
from typing import Any, Optional, Tuple, List, overload, TypeVar
from django.db.models.base import Model
from typing import Any, Optional, Tuple, List
from django.db import models
_T = TypeVar("_T", bound=Model)
class BaseUserManager(models.Manager[_T]):
class BaseUserManager(models.Manager):
@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]) -> _T: ...
def get_by_natural_key(self, username: Optional[str]) -> AbstractBaseUser: ...
class AbstractBaseUser(models.Model):
password: models.CharField = ...
last_login: Optional[models.DateTimeField] = ...
is_active: models.BooleanField = ...
REQUIRED_FIELDS: List[str] = ...
password = models.CharField(max_length=128)
last_login = models.DateTimeField(blank=True, null=True)
def get_username(self) -> str: ...
def clean(self) -> None: ...
def save(self, *args: Any, **kwargs: Any) -> None: ...
def natural_key(self) -> Tuple[str]: ...
@property
def is_anonymous(self) -> bool: ...
@@ -31,8 +29,4 @@ class AbstractBaseUser(models.Model):
@classmethod
def get_email_field_name(cls) -> str: ...
@classmethod
@overload
def normalize_username(cls, username: str) -> str: ...
@classmethod
@overload
def normalize_username(cls, username: Any) -> Any: ...

View File

@@ -1,8 +1,8 @@
from typing import Any, List, Iterable, Optional
from typing import Any, List, Optional
from django.core.checks.messages import CheckMessage
from django.apps.config import AppConfig
from .management import _get_builtin_permissions
def check_user_model(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_models_permissions(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
def check_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...

View File

@@ -1,20 +1,22 @@
from typing import Any, Dict
from typing import Any, Dict, Optional, Union
from django.contrib.auth.models import AnonymousUser, User
from django.http.request import HttpRequest
from django.utils.functional import SimpleLazyObject
class PermLookupDict:
app_label: str
user: Any
def __init__(self, user: Any, app_label: str) -> None: ...
app_label: django.utils.safestring.SafeText
user: SimpleLazyObject
def __init__(self, user: SimpleLazyObject, app_label: str) -> None: ...
def __getitem__(self, perm_name: str) -> bool: ...
def __iter__(self) -> Any: ...
def __bool__(self) -> bool: ...
class PermWrapper:
user: Any = ...
def __init__(self, user: Any) -> None: ...
user: SimpleLazyObject = ...
def __init__(self, user: Union[AnonymousUser, User]) -> None: ...
def __getitem__(self, app_label: str) -> PermLookupDict: ...
def __iter__(self) -> Any: ...
def __contains__(self, perm_name: Any) -> bool: ...
def __contains__(self, perm_name: Union[bool, str]) -> bool: ...
def auth(request: HttpRequest) -> Dict[str, Any]: ...
def auth(request: HttpRequest) -> Dict[str, Union[PermWrapper, AnonymousUser, User]]: ...

View File

@@ -1,6 +1,4 @@
from typing import Callable, List, Optional, Set, Union
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
from typing import Any, Callable, List, Optional, Set, Union
def user_passes_test(
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...

View File

@@ -1,36 +1,84 @@
from typing import Any, Dict, Iterator, Optional
import collections
import datetime
from typing import Any, Dict, Iterator, List, Optional, Union, Type
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): ...
class UsernameField(forms.CharField):
def to_python(self, value: Optional[str]) -> str: ...
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 = ...
class Meta:
model: Any = ...
fields: Any = ...
field_classes: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> User: ...
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 = ...
class Meta:
model: Any = ...
fields: str = ...
field_classes: 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 = ...
@@ -43,12 +91,21 @@ 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, Any],
context: Dict[str, Union[AbstractBaseUser, str]],
from_email: Optional[str],
to_email: str,
html_email_template_name: Optional[str] = ...,
@@ -68,6 +125,15 @@ 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 = ...
@@ -77,10 +143,31 @@ 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 = ...
@@ -89,3 +176,5 @@ 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]: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any, Dict, Optional
UserModel: Any

View File

@@ -23,7 +23,7 @@ class BasePasswordHasher:
memory_cost: int = ...
parallelism: int = ...
digest: Any = ...
iterations: int = ...
iterations: Optional[int] = ...
def salt(self) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def encode(self, password: str, salt: str) -> Any: ...

View File

@@ -1,9 +1,4 @@
import getpass as getpass # noqa: F401
from typing import Any
from django.core.management.base import BaseCommand
class NotRunningInTTYException(Exception): ...
class Command(BaseCommand):
stdin: Any
class Command(BaseCommand): ...

View File

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

View File

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

View File

@@ -1,82 +1,75 @@
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
import datetime
from typing import Any, List, Optional, Set, Tuple, Type, Union
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.contrib.contenttypes.models import ContentType
from django.db.models.base import Model
from django.db.models.manager import EmptyManager
from django.db import models
_AnyUser = Union[Model, "AnonymousUser"]
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
class PermissionManager(models.Manager["Permission"]):
class PermissionManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
class Permission(models.Model):
content_type_id: int
objects: PermissionManager
name = models.CharField(max_length=255)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename = models.CharField(max_length=100)
id: int
name: str = ...
content_type: Any = ...
codename: str = ...
def natural_key(self) -> Tuple[str, str, str]: ...
class GroupManager(models.Manager["Group"]):
class GroupManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_by_natural_key(self, name: str) -> Group: ...
class Group(models.Model):
objects: GroupManager
name = models.CharField(max_length=150)
permissions = models.ManyToManyField(Permission)
id: None
name: str = ...
permissions: Any = ...
def natural_key(self): ...
_T = TypeVar("_T", bound=Model)
class UserManager(BaseUserManager[_T]):
class UserManager(BaseUserManager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def create_user(
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> _T: ...
) -> AbstractUser: ...
def create_superuser(
self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any
) -> _T: ...
def with_perm(
self,
perm: Union[str, Permission],
is_active: bool = ...,
include_superusers: bool = ...,
backend: Optional[Union[Type[ModelBackend], str]] = ...,
obj: Optional[Model] = ...,
): ...
) -> AbstractBaseUser: ...
class PermissionsMixin(models.Model):
is_superuser = models.BooleanField()
groups = models.ManyToManyField(Group)
user_permissions = models.ManyToManyField(Permission)
def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
is_superuser: Any = ...
groups: Any = ...
user_permissions: Any = ...
def get_group_permissions(self, obj: None = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Optional[str] = ...) -> Set[str]: ...
def has_perm(self, perm: Union[Tuple[str, Any], str], obj: Optional[str] = ...) -> bool: ...
def has_perms(self, perm_list: Union[List[str], Set[str], Tuple[str]], obj: None = ...) -> bool: ...
def has_module_perms(self, app_label: str) -> bool: ...
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
username_validator: UnicodeUsernameValidator = ...
username = models.CharField(max_length=150)
first_name = models.CharField(max_length=30, blank=True)
last_name = models.CharField(max_length=150, blank=True)
email = models.EmailField(blank=True)
is_staff = models.BooleanField()
is_active = models.BooleanField()
date_joined = models.DateTimeField()
class AbstractUser(AbstractBaseUser, PermissionsMixin):
is_superuser: bool
username_validator: Any = ...
username: str = ...
first_name: str = ...
last_name: str = ...
email: str = ...
is_staff: bool = ...
date_joined: datetime.datetime = ...
EMAIL_FIELD: str = ...
USERNAME_FIELD: str = ...
def clean(self) -> None: ...
def get_full_name(self) -> str: ...
def get_short_name(self) -> str: ...
def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ...
@@ -98,11 +91,10 @@ class AnonymousUser:
def groups(self) -> EmptyManager: ...
@property
def user_permissions(self) -> EmptyManager: ...
def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[Any]: ...
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def 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_module_perms(self, module: str) -> bool: ...
@property
def is_anonymous(self) -> bool: ...

View File

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

View File

@@ -1,3 +0,0 @@
from typing import Any, List
urlpatterns: List[Any] = ...

View File

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

View File

@@ -1,10 +1,15 @@
from typing import Any, Optional, Set
from typing import Any, Dict, Optional, Set, Type, Union
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 HttpResponseRedirect
from django.http.response import HttpResponse, 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
@@ -15,18 +20,31 @@ 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, Union[AuthenticationForm, LoginView, Site, RequestSite, str]]: ...
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(
@@ -40,33 +58,55 @@ 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 = ...
reset_url_token: str = ...
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: ...

View File

@@ -1,3 +1,16 @@
from typing import Any, Optional
from django.apps import AppConfig
class ContentTypesConfig(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: ...

View File

@@ -1,6 +1,4 @@
from typing import Any, List, Iterable, Optional
from typing import Any, List, Optional
from django.apps.config import AppConfig
def check_generic_foreign_keys(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
def check_model_name_lengths(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...

View File

@@ -3,22 +3,17 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import Error
from django.db.models.base import Model
from django.db.models.expressions import Combinable
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignObject
from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.fields import Field, PositiveIntegerField
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.query import QuerySet
from django.db.models.query_utils import FilteredRelation, PathInfo
from django.db.models.sql.where import WhereNode
from django.db.models.fields import Field, PositiveIntegerField
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 = ...
@@ -49,27 +44,41 @@ 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[Any]: ...
def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
def __get__(
self, instance: Optional[Model], cls: Type[Model] = ...
) -> Optional[Union[GenericForeignKey, Model]]: ...
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
class GenericRel(ForeignObjectRel):
field: GenericRelation
limit_choices_to: Dict[Any, 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: Optional[str] = ...,
related_name: None = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
limit_choices_to: None = ...,
) -> 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 = ...
content_type_field_name: Any = ...
for_concrete_model: Any = ...
to_fields: Any = ...
def __init__(
self,
to: Union[Type[Model], str],
@@ -77,19 +86,28 @@ class GenericRelation(ForeignObject):
content_type_field: str = ...,
for_concrete_model: bool = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
limit_choices_to: None = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
to_fields: Any = ...
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 contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
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): ...
class ReverseGenericManyToOneDescriptor(ReverseManyToOneDescriptor):
field: GenericRelation
rel: GenericRel
def related_manager_cls(self): ...
def create_generic_related_manager(superclass: Any, rel: Any): ...

View File

@@ -1,13 +1,20 @@
from typing import Any, Dict, List
from django.db.models.deletion import Collector
from typing import Any, Optional
from django.core.management import BaseCommand
from django.core.management.base import CommandParser
from django.db.models.deletion import Collector
class Command(BaseCommand): ...
from ...management import get_contenttypes_and_models
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 NoFastDeleteCollector(Collector):
data: Dict[str, Any]
data: collections.OrderedDict
dependencies: Dict[Any, Any]
fast_deletes: List[Any]
field_updates: Dict[Any, Any]

View File

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

View File

@@ -1,4 +1,4 @@
from typing import Union
from typing import Any, Optional, Union
from django.http.request import HttpRequest
from django.http.response import HttpResponseRedirect

View File

@@ -1,7 +1,22 @@
from typing import Any
from typing import Any, Dict, Optional, Union
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 = ...
class Meta:
model: Any = ...
fields: str = ...
def clean_url(self) -> str: ...
def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ...

View File

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

View File

@@ -1,3 +1,7 @@
from django.contrib.sitemaps import Sitemap
from typing import Optional
class FlatPageSitemap(Sitemap): ...
from django.contrib.sitemaps import Sitemap
from django.db.models.query import QuerySet
class FlatPageSitemap(Sitemap):
def items(self) -> QuerySet: ...

View File

@@ -1,3 +0,0 @@
from typing import Any, List
urlpatterns: List[Any] = ...

View File

@@ -1,3 +1,5 @@
from typing import Any, Optional
from django.contrib.flatpages.models import FlatPage
from django.core.handlers.wsgi import WSGIRequest
from django.http.response import HttpResponse

View File

@@ -1,13 +0,0 @@
from django.db.models import *
from .fields import (
GeometryField as GeometryField,
LineStringField as LineStringField,
MultiLineStringField as MultiLineStringField,
MultiPointField as MultiPointField,
MultiPolygonField as MultiPolygonField,
PointField as PointField,
PolygonField as PolygonField,
GeometryCollectionField as GeometryCollectionField,
RasterField as RasterField,
)

View File

@@ -1,91 +0,0 @@
from typing import Any, Iterable, NamedTuple, Optional, TypeVar, Union, Tuple
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
_Connection = Any
# __set__ value type
_ST = TypeVar("_ST")
# __get__ return type
_GT = TypeVar("_GT")
class SRIDCacheEntry(NamedTuple):
units: Any
units_name: str
geodetic: bool
spheroid: str
def get_srid_info(srid: int, connection: _Connection) -> SRIDCacheEntry: ...
class BaseSpatialField(Field[_ST, _GT]):
def __init__(
self,
verbose_name: Optional[Union[str, bytes]] = ...,
srid: int = ...,
spatial_index: bool = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
def spheroid(self, connection: _Connection) -> str: ...
def units(self, connection: _Connection) -> Any: ...
def units_name(self, connection: _Connection) -> str: ...
def geodetic(self, connection: _Connection) -> bool: ...
class GeometryField(BaseSpatialField):
def __init__(
self,
verbose_name: Optional[Union[str, bytes]] = ...,
dim: int = ...,
geography: bool = ...,
extent: Tuple[float, float, float, float] = ...,
tolerance: float = ...,
srid: int = ...,
spatial_index: bool = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class PointField(GeometryField): ...
class LineStringField(GeometryField): ...
class PolygonField(GeometryField): ...
class MultiPointField(GeometryField): ...
class MultiLineStringField(GeometryField): ...
class MultiPolygonField(GeometryField): ...
class GeometryCollectionField(GeometryField): ...
class RasterField(BaseSpatialField): ...

View File

@@ -1,4 +1,4 @@
from datetime import date, datetime as datetime
from datetime import date, datetime
from decimal import Decimal
from typing import Any, Optional, Union

View File

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

View File

@@ -1,12 +1,13 @@
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[HttpRequest],
request: Optional[WSGIRequest],
level: int,
message: str,
extra_tags: str = ...,
@@ -15,12 +16,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: 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 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 success(
request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
) -> None: ...
def warning(
request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
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: ...
def error(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...

View File

@@ -1,11 +0,0 @@
from typing import Dict
DEBUG: int = ...
INFO: int = ...
SUCCESS: int = ...
WARNING: int = ...
ERROR: int = ...
DEFAULT_TAGS: Dict[int, str] = ...
DEFAULT_LEVELS: Dict[str, int] = ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Union
from typing import Any, Dict, List, Optional, Union
from django.contrib.messages.storage.base import BaseStorage
from django.http.request import HttpRequest

View File

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

View File

@@ -1,4 +1,4 @@
from typing import Any, List, Optional
from typing import Any, List, Optional, Union
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
@@ -16,7 +16,7 @@ class Message:
def level_tag(self) -> str: ...
class BaseStorage:
request: HttpRequest = ...
request: Any = ...
used: bool = ...
added_new: bool = ...
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...

View File

@@ -1,20 +1,49 @@
import json
from typing import Any
from typing import Any, Dict, List, Optional, Union
from django.contrib.messages.storage.base import BaseStorage
from django.contrib.messages.storage.base import BaseStorage, Message
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: Any) -> Any: ...
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,
]: ...
class CookieStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
cookie_name: str = ...
max_cookie_size: int = ...
not_finished: str = ...

View File

@@ -1,8 +1,11 @@
from typing import Any
from typing import Any, Optional
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: ...

View File

@@ -1,10 +1,15 @@
from typing import Any, List, Optional, Sequence, Union
from typing import Any, List, Optional, Union
from django.contrib.messages.storage.base import BaseStorage
from django.contrib.messages.storage.base import BaseStorage, Message
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: Sequence[Any]) -> str: ...
def deserialize_messages(self, data: Optional[Union[List[Any], str]]) -> Optional[List[Any]]: ...
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]]]: ...

View File

@@ -1,3 +1,3 @@
from typing import Dict
from typing import Dict, Optional
def get_level_tags() -> Dict[int, str]: ...

View File

@@ -1,9 +1,9 @@
from typing import Dict
from typing import Any, Dict, Optional
from django.forms.forms import BaseForm
from django.http.response import HttpResponse
from django.forms.forms import Form
from django.http.response import HttpResponseRedirect
class SuccessMessageMixin:
success_message: str = ...
def form_valid(self, form: BaseForm) -> HttpResponse: ...
def form_valid(self, form: Form) -> HttpResponseRedirect: ...
def get_success_message(self, cleaned_data: Dict[str, str]) -> str: ...

View File

@@ -1,24 +0,0 @@
from .general import (
ArrayAgg as ArrayAgg,
BitAnd as BitAnd,
BitOr as BitOr,
BoolAnd as BoolAnd,
BoolOr as BoolOr,
JSONBAgg as JSONBAgg,
StringAgg as StringAgg,
)
from .statistics import (
Corr as Corr,
CovarPop as CovarPop,
RegrAvgX as RegrAvgX,
RegrAvgY as RegrAvgY,
RegrCount as RegrCount,
RegrIntercept as RegrIntercept,
RegrR2 as RegrR2,
RegrSlope as RegrSlope,
RegrSXX as RegrSXX,
RegrSXY as RegrSXY,
RegrSYY as RegrSYY,
StatAggregate as StatAggregate,
)

View File

@@ -1,11 +0,0 @@
from django.db.models.aggregates import Aggregate
from .mixins import OrderableAggMixin
class ArrayAgg(OrderableAggMixin, Aggregate): ...
class BitAnd(Aggregate): ...
class BitOr(Aggregate): ...
class BoolAnd(Aggregate): ...
class BoolOr(Aggregate): ...
class JSONBAgg(Aggregate): ...
class StringAgg(OrderableAggMixin, Aggregate): ...

View File

@@ -1 +0,0 @@
class OrderableAggMixin: ...

View File

@@ -1,14 +0,0 @@
from django.db.models.aggregates import Aggregate
class StatAggregate(Aggregate): ...
class Corr(StatAggregate): ...
class CovarPop(StatAggregate): ...
class RegrAvgX(StatAggregate): ...
class RegrAvgY(StatAggregate): ...
class RegrCount(StatAggregate): ...
class RegrIntercept(StatAggregate): ...
class RegrR2(StatAggregate): ...
class RegrSlope(StatAggregate): ...
class RegrSXX(StatAggregate): ...
class RegrSXY(StatAggregate): ...
class RegrSYY(StatAggregate): ...

View File

@@ -1,18 +0,0 @@
from typing import Optional, Sequence, Tuple, Union
from django.db.models.constraints import BaseConstraint
from django.db.models.expressions import Combinable
from django.db.models.query_utils import Q
class ExclusionConstraint(BaseConstraint):
expressions: Sequence[Tuple[Union[str, Combinable], str]]
index_type: str
condition: Optional[Q]
def __init__(
self,
*,
name: str,
expressions: Sequence[Tuple[Union[str, Combinable], str]],
condition: Optional[Q] = ...,
index_type: Optional[str] = ...,
): ...

View File

@@ -4,17 +4,7 @@ from .ranges import (
RangeField as RangeField,
IntegerRangeField as IntegerRangeField,
BigIntegerRangeField as BigIntegerRangeField,
DecimalRangeField as DecimalRangeField,
FloatRangeField as FloatRangeField,
DateRangeField as DateRangeField,
DateTimeRangeField as DateTimeRangeField,
RangeOperators as RangeOperators,
RangeBoundary as RangeBoundary,
)
from .hstore import HStoreField as HStoreField
from .citext import (
CICharField as CICharField,
CIEmailField as CIEmailField,
CIText as CIText,
CITextField as CITextField,
)

View File

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

View File

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

View File

@@ -1,11 +1,10 @@
from json import JSONEncoder
from typing import Any, Optional, Type
from typing import Any, Dict, List, Optional, Tuple, Type, Union
from django.db.models import Field
from django.db.models.lookups import Transform
from .mixins import CheckFieldDefaultMixin
class JsonAdapter:
class JsonAdapter(object):
encoder: Any = ...
def __init__(self, adapted: Any, dumps: Optional[Any] = ..., encoder: Optional[Any] = ...) -> None: ...
def dumps(self, obj: Any): ...
@@ -16,17 +15,12 @@ class JSONField(CheckFieldDefaultMixin, Field):
default_error_messages: Any = ...
encoder: Any = ...
def __init__(
self,
verbose_name: Optional[str] = ...,
name: Optional[str] = ...,
encoder: Optional[Type[JSONEncoder]] = ...,
**kwargs: Any
self, verbose_name: None = ..., name: None = ..., 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): ...
class KeyTransform(Transform):
operator: str = ...
nested_operator: str = ...
def __init__(self, key_name: str, *args: Any, **kwargs: Any) -> None: ...
class KeyTextTransform(KeyTransform): ...
def formfield(self, **kwargs: Any): ...

View File

@@ -2,47 +2,46 @@ from typing import Any
from django.db import models
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange # type: ignore
class RangeField(models.Field):
empty_strings_allowed: bool = ...
base_field: Any = ...
range_type: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@property
def model(self): ...
@model.setter
def model(self, model: Any) -> None: ...
def get_prep_value(self, value: Any): ...
def to_python(self, value: Any): ...
def set_attributes_from_name(self, name: str) -> None: ...
def value_to_string(self, obj: Any): ...
def formfield(self, **kwargs: Any): ...
class IntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
class BigIntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class DecimalRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
class FloatRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
class DateTimeRangeField(RangeField):
def __get__(self, instance, owner) -> DateTimeTZRange: ...
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
class DateRangeField(RangeField):
def __get__(self, instance, owner) -> DateRange: ...
class RangeOperators:
EQUAL: str
NOT_EQUAL: str
CONTAINS: str
CONTAINED_BY: str
OVERLAPS: str
FULLY_LT: str
FULLY_GT: str
NOT_LT: str
NOT_GT: str
ADJACENT_TO: str
class RangeBoundary(models.Expression):
lower: str
upper: str
def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...): ...
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...

View File

@@ -1,4 +0,0 @@
from django.db.models import Func
class RandomUUID(Func): ...
class TransactionNow(Func): ...

View File

@@ -1,82 +0,0 @@
from typing import Optional, Sequence
from django.db.models.query_utils import Q
from django.db.models import Index
class PostgresIndex(Index): ...
class BrinIndex(PostgresIndex):
def __init__(
self,
*,
autosummarize: Optional[bool] = ...,
pages_per_range: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class BTreeIndex(PostgresIndex):
def __init__(
self,
*,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class GinIndex(PostgresIndex):
def __init__(
self,
*,
fastupdate: Optional[bool] = ...,
gin_pending_list_limit: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class GistIndex(PostgresIndex):
def __init__(
self,
*,
buffering: Optional[bool] = ...,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class HashIndex(PostgresIndex):
def __init__(
self,
*,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class SpGistIndex(PostgresIndex):
def __init__(
self,
*,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...

View File

@@ -1,18 +0,0 @@
from django.db.models.lookups import Exact
from django.db.models import Lookup, Transform
from .search import SearchVectorExact
class PostgresSimpleLookup(Lookup):
operator: str
class DataContains(PostgresSimpleLookup): ...
class ContainedBy(PostgresSimpleLookup): ...
class Overlap(PostgresSimpleLookup): ...
class HasKey(PostgresSimpleLookup): ...
class HasKeys(PostgresSimpleLookup): ...
class HasAnyKeys(HasKeys): ...
class Unaccent(Transform): ...
class SearchLookup(SearchVectorExact): ...
class TrigramSimilar(PostgresSimpleLookup): ...
class JSONExact(Exact): ...

View File

@@ -1,63 +0,0 @@
from typing import Any, Dict, Optional, TypeVar, Union
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value, _OutputField
from django.db.models.lookups import Lookup
from django.db.models import Field
_Expression = Union[str, Combinable, "SearchQueryCombinable"]
class SearchVectorExact(Lookup): ...
class SearchVectorField(Field): ...
class SearchQueryField(Field): ...
class SearchVectorCombinable:
ADD: str = ...
class SearchVector(SearchVectorCombinable, Func):
config: Optional[Any] = ...
def __init__(self, *expressions: _Expression, **extra: Any): ...
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
def __init__(
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
): ...
_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): # type: ignore
SEARCH_TYPES: Dict[str, str] = ...
def __init__(
self,
value: str,
output_field: Optional[_OutputField] = ...,
*,
config: Optional[_Expression] = ...,
invert: bool = ...,
search_type: str = ...
): ...
def __invert__(self: _T) -> _T: ...
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: ignore
def __init__(
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
) -> None: ...
class SearchRank(Func):
def __init__(
self, vector: Union[SearchVector, _Expression], query: Union[SearchQuery, _Expression], **extra: Any
) -> None: ...
class TrigramBase(Func):
def __init__(self, expression: _Expression, string, **extra: Any) -> None: ...
class TrigramSimilarity(TrigramBase): ...
class TrigramDistance(TrigramBase): ...

View File

@@ -1,5 +0,0 @@
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: ...

View File

@@ -1,17 +0,0 @@
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): ...

View File

@@ -1,10 +1,10 @@
from typing import Any
from django.http.request import HttpRequest
from django.core.handlers.wsgi import WSGIRequest
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class RedirectFallbackMiddleware(MiddlewareMixin):
response_gone_class: Any = ...
response_redirect_class: Any = ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...
def process_response(self, request: WSGIRequest, response: HttpResponse) -> HttpResponse: ...

View File

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

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