mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-08 13:04:47 +08:00
Merge branch 'master' into django-db-models-missing-imports
This commit is contained in:
@@ -10,7 +10,7 @@ jobs:
|
||||
- name: "Typecheck Django test suite"
|
||||
python: 3.7
|
||||
script: |
|
||||
xonsh ./scripts/typecheck_django_tests.xsh
|
||||
python ./scripts/typecheck_tests.py
|
||||
|
||||
- name: "Run plugin test suite with python 3.7"
|
||||
python: 3.7
|
||||
@@ -25,7 +25,8 @@ jobs:
|
||||
|
||||
before_install: |
|
||||
# Upgrade pip, setuptools, and wheel
|
||||
pip install -U pip setuptools wheel xonsh
|
||||
pip install -U pip setuptools wheel
|
||||
|
||||
install: |
|
||||
pip install -r ./dev-requirements.txt
|
||||
pip install -r ./scripts/typecheck-tests-requirements.txt
|
||||
|
||||
@@ -23,4 +23,10 @@ plugins =
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Any
|
||||
from django.utils.version import get_version as get_version
|
||||
from .utils.version import get_version as get_version
|
||||
|
||||
VERSION: Any
|
||||
__version__: str
|
||||
|
||||
def setup(set_prefix: bool = ...) -> None: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Iterator, Type
|
||||
from typing import Any, Iterator, Type, Optional
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
@@ -6,14 +6,14 @@ MODELS_MODULE_NAME: str
|
||||
|
||||
class AppConfig:
|
||||
name: str = ...
|
||||
module: Any = ...
|
||||
module: Optional[Any] = ...
|
||||
apps: None = ...
|
||||
label: str = ...
|
||||
verbose_name: str = ...
|
||||
path: str = ...
|
||||
models_module: None = ...
|
||||
models: None = ...
|
||||
def __init__(self, app_name: str, app_module: None) -> None: ...
|
||||
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
|
||||
@classmethod
|
||||
def create(cls, entry: str) -> AppConfig: ...
|
||||
def get_model(self, model_name: str, require_ready: bool = ...) -> Type[Model]: ...
|
||||
|
||||
@@ -2,6 +2,8 @@ from typing import Any
|
||||
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
ENVIRONMENT_VARIABLE: str = ...
|
||||
|
||||
# required for plugin to be able to distinguish this specific instance of LazySettings from others
|
||||
class _DjangoConfLazyObject(LazyObject): ...
|
||||
|
||||
@@ -11,5 +13,8 @@ class LazySettings(_DjangoConfLazyObject):
|
||||
|
||||
settings: LazySettings = ...
|
||||
|
||||
class Settings: ...
|
||||
class Settings:
|
||||
def __init__(self, settings_module: str): ...
|
||||
def is_overridden(self, setting: str) -> bool: ...
|
||||
|
||||
class UserSettingsHolder: ...
|
||||
|
||||
630
django-stubs/conf/global_settings.pyi
Normal file
630
django-stubs/conf/global_settings.pyi
Normal file
@@ -0,0 +1,630 @@
|
||||
"""
|
||||
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.
|
||||
def gettext_noop(s):
|
||||
return s
|
||||
|
||||
####################
|
||||
# CORE #
|
||||
####################
|
||||
|
||||
DEBUG = False
|
||||
|
||||
# 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 = False
|
||||
|
||||
# People who get code error notifications.
|
||||
# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
|
||||
ADMINS = []
|
||||
|
||||
# List of IP addresses, as strings, that:
|
||||
# * See debug comments, when DEBUG is true
|
||||
# * Receive x-headers
|
||||
INTERNAL_IPS = []
|
||||
|
||||
# Hosts/domain names that are valid for this site.
|
||||
# "*" matches anything, ".example.com" matches example.com and all subdomains
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
# 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 = "America/Chicago"
|
||||
|
||||
# If you set this to True, Django will use timezone-aware datetimes.
|
||||
USE_TZ = False
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
# Languages we provide translations for, out of the box.
|
||||
LANGUAGES = [
|
||||
("af", gettext_noop("Afrikaans")),
|
||||
("ar", gettext_noop("Arabic")),
|
||||
("ast", gettext_noop("Asturian")),
|
||||
("az", gettext_noop("Azerbaijani")),
|
||||
("bg", gettext_noop("Bulgarian")),
|
||||
("be", gettext_noop("Belarusian")),
|
||||
("bn", gettext_noop("Bengali")),
|
||||
("br", gettext_noop("Breton")),
|
||||
("bs", gettext_noop("Bosnian")),
|
||||
("ca", gettext_noop("Catalan")),
|
||||
("cs", gettext_noop("Czech")),
|
||||
("cy", gettext_noop("Welsh")),
|
||||
("da", gettext_noop("Danish")),
|
||||
("de", gettext_noop("German")),
|
||||
("dsb", gettext_noop("Lower Sorbian")),
|
||||
("el", gettext_noop("Greek")),
|
||||
("en", gettext_noop("English")),
|
||||
("en-au", gettext_noop("Australian English")),
|
||||
("en-gb", gettext_noop("British English")),
|
||||
("eo", gettext_noop("Esperanto")),
|
||||
("es", gettext_noop("Spanish")),
|
||||
("es-ar", gettext_noop("Argentinian Spanish")),
|
||||
("es-co", gettext_noop("Colombian Spanish")),
|
||||
("es-mx", gettext_noop("Mexican Spanish")),
|
||||
("es-ni", gettext_noop("Nicaraguan Spanish")),
|
||||
("es-ve", gettext_noop("Venezuelan Spanish")),
|
||||
("et", gettext_noop("Estonian")),
|
||||
("eu", gettext_noop("Basque")),
|
||||
("fa", gettext_noop("Persian")),
|
||||
("fi", gettext_noop("Finnish")),
|
||||
("fr", gettext_noop("French")),
|
||||
("fy", gettext_noop("Frisian")),
|
||||
("ga", gettext_noop("Irish")),
|
||||
("gd", gettext_noop("Scottish Gaelic")),
|
||||
("gl", gettext_noop("Galician")),
|
||||
("he", gettext_noop("Hebrew")),
|
||||
("hi", gettext_noop("Hindi")),
|
||||
("hr", gettext_noop("Croatian")),
|
||||
("hsb", gettext_noop("Upper Sorbian")),
|
||||
("hu", gettext_noop("Hungarian")),
|
||||
("ia", gettext_noop("Interlingua")),
|
||||
("id", gettext_noop("Indonesian")),
|
||||
("io", gettext_noop("Ido")),
|
||||
("is", gettext_noop("Icelandic")),
|
||||
("it", gettext_noop("Italian")),
|
||||
("ja", gettext_noop("Japanese")),
|
||||
("ka", gettext_noop("Georgian")),
|
||||
("kab", gettext_noop("Kabyle")),
|
||||
("kk", gettext_noop("Kazakh")),
|
||||
("km", gettext_noop("Khmer")),
|
||||
("kn", gettext_noop("Kannada")),
|
||||
("ko", gettext_noop("Korean")),
|
||||
("lb", gettext_noop("Luxembourgish")),
|
||||
("lt", gettext_noop("Lithuanian")),
|
||||
("lv", gettext_noop("Latvian")),
|
||||
("mk", gettext_noop("Macedonian")),
|
||||
("ml", gettext_noop("Malayalam")),
|
||||
("mn", gettext_noop("Mongolian")),
|
||||
("mr", gettext_noop("Marathi")),
|
||||
("my", gettext_noop("Burmese")),
|
||||
("nb", gettext_noop("Norwegian Bokmål")),
|
||||
("ne", gettext_noop("Nepali")),
|
||||
("nl", gettext_noop("Dutch")),
|
||||
("nn", gettext_noop("Norwegian Nynorsk")),
|
||||
("os", gettext_noop("Ossetic")),
|
||||
("pa", gettext_noop("Punjabi")),
|
||||
("pl", gettext_noop("Polish")),
|
||||
("pt", gettext_noop("Portuguese")),
|
||||
("pt-br", gettext_noop("Brazilian Portuguese")),
|
||||
("ro", gettext_noop("Romanian")),
|
||||
("ru", gettext_noop("Russian")),
|
||||
("sk", gettext_noop("Slovak")),
|
||||
("sl", gettext_noop("Slovenian")),
|
||||
("sq", gettext_noop("Albanian")),
|
||||
("sr", gettext_noop("Serbian")),
|
||||
("sr-latn", gettext_noop("Serbian Latin")),
|
||||
("sv", gettext_noop("Swedish")),
|
||||
("sw", gettext_noop("Swahili")),
|
||||
("ta", gettext_noop("Tamil")),
|
||||
("te", gettext_noop("Telugu")),
|
||||
("th", gettext_noop("Thai")),
|
||||
("tr", gettext_noop("Turkish")),
|
||||
("tt", gettext_noop("Tatar")),
|
||||
("udm", gettext_noop("Udmurt")),
|
||||
("uk", gettext_noop("Ukrainian")),
|
||||
("ur", gettext_noop("Urdu")),
|
||||
("vi", gettext_noop("Vietnamese")),
|
||||
("zh-hans", gettext_noop("Simplified Chinese")),
|
||||
("zh-hant", gettext_noop("Traditional Chinese")),
|
||||
]
|
||||
|
||||
# Languages using BiDi (right-to-left) layout
|
||||
LANGUAGES_BIDI = ["he", "ar", "fa", "ur"]
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
LOCALE_PATHS = []
|
||||
|
||||
# Settings for language cookie
|
||||
LANGUAGE_COOKIE_NAME = "django_language"
|
||||
LANGUAGE_COOKIE_AGE = None
|
||||
LANGUAGE_COOKIE_DOMAIN = None
|
||||
LANGUAGE_COOKIE_PATH = "/"
|
||||
|
||||
# If you set this to True, Django will format dates, numbers and calendars
|
||||
# according to user current locale.
|
||||
USE_L10N = False
|
||||
|
||||
# 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 = "text/html"
|
||||
DEFAULT_CHARSET = "utf-8"
|
||||
|
||||
# Encoding of files read from disk (template and initial SQL files).
|
||||
FILE_CHARSET = "utf-8"
|
||||
|
||||
# Email address that error messages come from.
|
||||
SERVER_EMAIL = "root@localhost"
|
||||
|
||||
# Database connection info. If left empty, will default to the dummy backend.
|
||||
DATABASES = {}
|
||||
|
||||
# Classes used to implement DB routing behavior.
|
||||
DATABASE_ROUTERS = []
|
||||
|
||||
# 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 = "django.core.mail.backends.smtp.EmailBackend"
|
||||
|
||||
# Host for sending email.
|
||||
EMAIL_HOST = "localhost"
|
||||
|
||||
# Port for sending email.
|
||||
EMAIL_PORT = 25
|
||||
|
||||
# Whether to send SMTP 'Date' header in the local time zone or in UTC.
|
||||
EMAIL_USE_LOCALTIME = False
|
||||
|
||||
# Optional SMTP authentication information for EMAIL_HOST.
|
||||
EMAIL_HOST_USER = ""
|
||||
EMAIL_HOST_PASSWORD = ""
|
||||
EMAIL_USE_TLS = False
|
||||
EMAIL_USE_SSL = False
|
||||
EMAIL_SSL_CERTFILE = None
|
||||
EMAIL_SSL_KEYFILE = None
|
||||
EMAIL_TIMEOUT = None
|
||||
|
||||
# List of strings representing installed apps.
|
||||
INSTALLED_APPS = []
|
||||
|
||||
TEMPLATES = []
|
||||
|
||||
# Default form rendering class.
|
||||
FORM_RENDERER = "django.forms.renderers.DjangoTemplates"
|
||||
|
||||
# Default email address to use for various automated correspondence from
|
||||
# the site managers.
|
||||
DEFAULT_FROM_EMAIL = "webmaster@localhost"
|
||||
|
||||
# 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 = "[Django] "
|
||||
|
||||
# Whether to append trailing slashes to URLs.
|
||||
APPEND_SLASH = True
|
||||
|
||||
# Whether to prepend the "www." subdomain to URLs that don't have it.
|
||||
PREPEND_WWW = False
|
||||
|
||||
# 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 = []
|
||||
|
||||
ABSOLUTE_URL_OVERRIDES = {}
|
||||
|
||||
# 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 = []
|
||||
|
||||
# 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 = ""
|
||||
|
||||
# Default file storage mechanism that holds media.
|
||||
DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/var/www/example.com/media/"
|
||||
MEDIA_ROOT = ""
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT.
|
||||
# Examples: "http://example.com/media/", "http://media.example.com/"
|
||||
MEDIA_URL = ""
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Example: "/var/www/example.com/static/"
|
||||
STATIC_ROOT = None
|
||||
|
||||
# URL that handles the static files served from STATIC_ROOT.
|
||||
# Example: "http://example.com/static/", "http://static.example.com/"
|
||||
STATIC_URL = None
|
||||
|
||||
# List of upload handler classes to be applied in order.
|
||||
FILE_UPLOAD_HANDLERS = [
|
||||
"django.core.files.uploadhandler.MemoryFileUploadHandler",
|
||||
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
|
||||
]
|
||||
|
||||
# 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 = 2621440 # 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 = 2621440 # 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 = 1000
|
||||
|
||||
# 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 = None
|
||||
|
||||
# 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 = None
|
||||
|
||||
# Default formatting for date objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
DATE_FORMAT = "N j, Y"
|
||||
|
||||
# Default formatting for datetime objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
DATETIME_FORMAT = "N j, Y, P"
|
||||
|
||||
# Default formatting for time objects. See all available format strings here:
|
||||
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
|
||||
TIME_FORMAT = "P"
|
||||
|
||||
# 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 = "F Y"
|
||||
|
||||
# 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 = "F j"
|
||||
|
||||
# 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 = "m/d/Y"
|
||||
|
||||
# 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 = "m/d/Y P"
|
||||
|
||||
# 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 = [
|
||||
"%Y-%m-%d",
|
||||
"%m/%d/%Y",
|
||||
"%m/%d/%y", # '2006-10-25', '10/25/2006', '10/25/06'
|
||||
"%b %d %Y",
|
||||
"%b %d, %Y", # 'Oct 25 2006', 'Oct 25, 2006'
|
||||
"%d %b %Y",
|
||||
"%d %b, %Y", # '25 Oct 2006', '25 Oct, 2006'
|
||||
"%B %d %Y",
|
||||
"%B %d, %Y", # 'October 25 2006', 'October 25, 2006'
|
||||
"%d %B %Y",
|
||||
"%d %B, %Y", # '25 October 2006', '25 October, 2006'
|
||||
]
|
||||
|
||||
# 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 = ["%H:%M:%S", "%H:%M:%S.%f", "%H:%M"] # '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 = [
|
||||
"%Y-%m-%d %H:%M:%S", # '2006-10-25 14:30:59'
|
||||
"%Y-%m-%d %H:%M:%S.%f", # '2006-10-25 14:30:59.000200'
|
||||
"%Y-%m-%d %H:%M", # '2006-10-25 14:30'
|
||||
"%Y-%m-%d", # '2006-10-25'
|
||||
"%m/%d/%Y %H:%M:%S", # '10/25/2006 14:30:59'
|
||||
"%m/%d/%Y %H:%M:%S.%f", # '10/25/2006 14:30:59.000200'
|
||||
"%m/%d/%Y %H:%M", # '10/25/2006 14:30'
|
||||
"%m/%d/%Y", # '10/25/2006'
|
||||
"%m/%d/%y %H:%M:%S", # '10/25/06 14:30:59'
|
||||
"%m/%d/%y %H:%M:%S.%f", # '10/25/06 14:30:59.000200'
|
||||
"%m/%d/%y %H:%M", # '10/25/06 14:30'
|
||||
"%m/%d/%y", # '10/25/06'
|
||||
]
|
||||
|
||||
# First day of week, to be used on calendars
|
||||
# 0 means Sunday, 1 means Monday...
|
||||
FIRST_DAY_OF_WEEK = 0
|
||||
|
||||
# Decimal separator symbol
|
||||
DECIMAL_SEPARATOR = "."
|
||||
|
||||
# Boolean that sets whether to add thousand separator when formatting numbers
|
||||
USE_THOUSAND_SEPARATOR = False
|
||||
|
||||
# Number of digits that will be together, when splitting them by
|
||||
# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
|
||||
NUMBER_GROUPING = 0
|
||||
|
||||
# Thousand separator symbol
|
||||
THOUSAND_SEPARATOR = ","
|
||||
|
||||
# The tablespaces to use for each model when not specified otherwise.
|
||||
DEFAULT_TABLESPACE = ""
|
||||
DEFAULT_INDEX_TABLESPACE = ""
|
||||
|
||||
# Default X-Frame-Options header value
|
||||
X_FRAME_OPTIONS = "SAMEORIGIN"
|
||||
|
||||
USE_X_FORWARDED_HOST = False
|
||||
USE_X_FORWARDED_PORT = False
|
||||
|
||||
# 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 = None
|
||||
|
||||
# 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 = None
|
||||
|
||||
##############
|
||||
# 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 = []
|
||||
|
||||
############
|
||||
# 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 = None
|
||||
# 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 = "Lax"
|
||||
# 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 = None
|
||||
# class to serialize session data
|
||||
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
|
||||
|
||||
#########
|
||||
# CACHE #
|
||||
#########
|
||||
|
||||
# The cache backends to use.
|
||||
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}
|
||||
CACHE_MIDDLEWARE_KEY_PREFIX = ""
|
||||
CACHE_MIDDLEWARE_SECONDS = 600
|
||||
CACHE_MIDDLEWARE_ALIAS = "default"
|
||||
|
||||
##################
|
||||
# AUTHENTICATION #
|
||||
##################
|
||||
|
||||
AUTH_USER_MODEL = "auth.User"
|
||||
|
||||
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]
|
||||
|
||||
LOGIN_URL = "/accounts/login/"
|
||||
|
||||
LOGIN_REDIRECT_URL = "/accounts/profile/"
|
||||
|
||||
LOGOUT_REDIRECT_URL = None
|
||||
|
||||
# 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 = [
|
||||
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
|
||||
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
|
||||
"django.contrib.auth.hashers.Argon2PasswordHasher",
|
||||
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
|
||||
]
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = []
|
||||
|
||||
###########
|
||||
# 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 = "Lax"
|
||||
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
|
||||
CSRF_TRUSTED_ORIGINS = []
|
||||
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 = {}
|
||||
|
||||
# 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 = []
|
||||
|
||||
############
|
||||
# FIXTURES #
|
||||
############
|
||||
|
||||
# The list of directories to search for fixtures
|
||||
FIXTURE_DIRS = []
|
||||
|
||||
###############
|
||||
# STATICFILES #
|
||||
###############
|
||||
|
||||
# A list of locations of additional static files
|
||||
STATICFILES_DIRS = []
|
||||
|
||||
# The default file storage backend used during the build process
|
||||
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = [
|
||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
]
|
||||
|
||||
##############
|
||||
# MIGRATIONS #
|
||||
##############
|
||||
|
||||
# Migration module overrides for apps, by app label.
|
||||
MIGRATION_MODULES = {}
|
||||
|
||||
#################
|
||||
# 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 = []
|
||||
|
||||
#######################
|
||||
# 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 = []
|
||||
SECURE_SSL_HOST = None
|
||||
SECURE_SSL_REDIRECT = False
|
||||
@@ -1,19 +1,21 @@
|
||||
from typing import Any, List
|
||||
from typing import Any, List, Union
|
||||
|
||||
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
def check_admin_app(app_configs: None, **kwargs: Any) -> List[str]: ...
|
||||
def check_dependencies(**kwargs: Any) -> List[Error]: ...
|
||||
_CheckError = Union[str, Error]
|
||||
|
||||
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[Error]: ...
|
||||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
|
||||
|
||||
class ModelAdminChecks(BaseModelAdminChecks):
|
||||
def check(self, admin_obj: ModelAdmin, **kwargs: Any) -> List[Error]: ...
|
||||
def check(self, admin_obj: ModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
|
||||
|
||||
class InlineModelAdminChecks(BaseModelAdminChecks):
|
||||
def check(self, inline_obj: InlineModelAdmin, **kwargs: Any) -> List[Any]: ...
|
||||
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): ...
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||
|
||||
from django.contrib.admin.filters import SimpleListFilter
|
||||
from django.contrib.admin.models import LogEntry
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
from django.contrib.admin.views.main import ChangeList
|
||||
@@ -11,18 +10,17 @@ 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.forms.fields import TypedChoiceField
|
||||
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
|
||||
from django.db.models.options import Options
|
||||
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.response import HttpResponse, HttpResponseBase, HttpResponseRedirect, JsonResponse
|
||||
from django.urls.resolvers import URLPattern
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
from django.db.models.options import Options
|
||||
from django.db.models.fields import Field
|
||||
|
||||
IS_POPUP_VAR: str
|
||||
TO_FIELD_VAR: str
|
||||
@@ -55,7 +53,7 @@ class BaseModelAdmin:
|
||||
view_on_site: bool = ...
|
||||
show_full_result_count: bool = ...
|
||||
checks_class: Any = ...
|
||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
||||
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
|
||||
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: ...
|
||||
@@ -94,13 +92,13 @@ class BaseModelAdmin:
|
||||
|
||||
class ModelAdmin(BaseModelAdmin):
|
||||
formfield_overrides: Any
|
||||
list_display: Any = ...
|
||||
list_display_links: Any = ...
|
||||
list_filter: Any = ...
|
||||
list_select_related: bool = ...
|
||||
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: Any = ...
|
||||
list_editable: Sequence[str] = ...
|
||||
search_fields: Any = ...
|
||||
date_hierarchy: Any = ...
|
||||
save_as: bool = ...
|
||||
@@ -167,17 +165,17 @@ class ModelAdmin(BaseModelAdmin):
|
||||
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: WSGIRequest) -> Union[List[Callable], List[str], Tuple[str]]: ...
|
||||
def get_list_display_links(
|
||||
self, request: WSGIRequest, list_display: Union[List[Callable], List[str], Tuple[str]]
|
||||
) -> Optional[Union[List[Callable], List[str], Tuple[str]]]: ...
|
||||
def get_list_filter(self, request: WSGIRequest) -> Union[List[Type[SimpleListFilter]], List[str], Tuple]: ...
|
||||
def get_list_select_related(self, request: WSGIRequest) -> Union[Tuple, bool]: ...
|
||||
def get_search_fields(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
|
||||
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: WSGIRequest, queryset: QuerySet, search_term: str
|
||||
) -> Tuple[QuerySet, bool]: ...
|
||||
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: WSGIRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
|
||||
) -> List[Dict[str, Dict[str, List[str]]]]: ...
|
||||
@@ -204,7 +202,9 @@ class ModelAdmin(BaseModelAdmin):
|
||||
form_url: str = ...,
|
||||
obj: Optional[Any] = ...,
|
||||
): ...
|
||||
def response_add(self, request: WSGIRequest, obj: Model, post_url_continue: None = ...) -> HttpResponse: ...
|
||||
def response_add(
|
||||
self, request: WSGIRequest, obj: Model, post_url_continue: Optional[str] = ...
|
||||
) -> 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: ...
|
||||
|
||||
@@ -26,8 +26,9 @@ class AdminSite:
|
||||
password_change_template: Any = ...
|
||||
password_change_done_template: Any = ...
|
||||
name: str = ...
|
||||
_registry: Dict[Type[Model], ModelAdmin]
|
||||
def __init__(self, name: str = ...) -> None: ...
|
||||
def check(self, app_configs: None) -> List[str]: ...
|
||||
def check(self, app_configs: None) -> List[Any]: ...
|
||||
def register(
|
||||
self,
|
||||
model_or_iterable: Union[List[Type[Model]], Tuple[Type[Model]], Type[Model]],
|
||||
@@ -47,9 +48,9 @@ class AdminSite:
|
||||
def empty_value_display(self, empty_value_display: Any) -> None: ...
|
||||
def has_permission(self, request: WSGIRequest) -> bool: ...
|
||||
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
|
||||
def get_urls(self) -> List[Union[URLPattern, URLResolver]]: ...
|
||||
def get_urls(self) -> List[URLResolver]: ...
|
||||
@property
|
||||
def urls(self) -> Tuple[List[Union[URLPattern, URLResolver]], str, str]: ...
|
||||
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
|
||||
def each_context(self, request: Any): ...
|
||||
def password_change(self, request: WSGIRequest, extra_context: Dict[str, str] = ...) -> TemplateResponse: ...
|
||||
def password_change_done(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Iterator, List, Optional, Union
|
||||
from typing import Any, Dict, Iterator, List, Optional, Union, Iterable
|
||||
|
||||
from django.contrib.admin.filters import FieldListFilter
|
||||
from django.contrib.admin.templatetags.base import InclusionAdminNode
|
||||
@@ -15,7 +15,7 @@ register: Any
|
||||
DOT: str
|
||||
|
||||
def paginator_number(cl: ChangeList, i: int) -> SafeText: ...
|
||||
def pagination(cl: ChangeList) -> Dict[str, Union[List[Union[int, str]], ChangeList, int, range, str]]: ...
|
||||
def pagination(cl: ChangeList) -> Dict[str, Iterable[Any]]: ...
|
||||
def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
|
||||
def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ...
|
||||
def items_for_result(cl: ChangeList, result: Model, form: None) -> Iterator[SafeText]: ...
|
||||
|
||||
@@ -9,6 +9,7 @@ from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from django.db.models.options import Options
|
||||
from django.forms.formsets import BaseFormSet
|
||||
|
||||
ALL_VAR: str
|
||||
ORDER_VAR: str
|
||||
@@ -44,6 +45,7 @@ class ChangeList:
|
||||
queryset: Any = ...
|
||||
title: Any = ...
|
||||
pk_attname: Any = ...
|
||||
formset: Optional[BaseFormSet]
|
||||
def __init__(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
|
||||
@@ -11,10 +11,8 @@ class BaseUserManager(models.Manager):
|
||||
class AbstractBaseUser(models.Model):
|
||||
password: models.CharField = ...
|
||||
last_login: Optional[models.DateTimeField] = ...
|
||||
is_active: bool = ...
|
||||
is_active: models.BooleanField = ...
|
||||
REQUIRED_FIELDS: List[str] = ...
|
||||
class Meta:
|
||||
abstract: bool = ...
|
||||
def get_username(self) -> str: ...
|
||||
def clean(self) -> None: ...
|
||||
def save(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
UNUSABLE_PASSWORD_PREFIX: str
|
||||
@@ -17,92 +16,30 @@ def identify_hasher(encoded: str) -> BasePasswordHasher: ...
|
||||
def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ...
|
||||
|
||||
class BasePasswordHasher:
|
||||
algorithm: Any = ...
|
||||
library: Any = ...
|
||||
algorithm: str = ...
|
||||
library: str = ...
|
||||
rounds: int = ...
|
||||
time_cost: int = ...
|
||||
memory_cost: int = ...
|
||||
parallelism: int = ...
|
||||
digest: Any = ...
|
||||
iterations: Optional[int] = ...
|
||||
def salt(self) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> Any: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def encode(self, password: str, salt: str) -> Any: ...
|
||||
def safe_summary(self, encoded: str) -> Any: ...
|
||||
def must_update(self, encoded: str) -> bool: ...
|
||||
def harden_runtime(self, password: str, encoded: str) -> None: ...
|
||||
|
||||
class PBKDF2PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
iterations: int = ...
|
||||
digest: Any = ...
|
||||
def encode(self, password: str, salt: str, iterations: Optional[int] = ...) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def safe_summary(self, encoded: str) -> OrderedDict: ...
|
||||
def must_update(self, encoded: str) -> bool: ...
|
||||
def harden_runtime(self, password: str, encoded: str) -> None: ...
|
||||
|
||||
class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher):
|
||||
algorithm: str = ...
|
||||
digest: Any = ...
|
||||
|
||||
class Argon2PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
library: str = ...
|
||||
time_cost: int = ...
|
||||
memory_cost: int = ...
|
||||
parallelism: int = ...
|
||||
def encode(self, password: Any, salt: Any): ...
|
||||
def verify(self, password: Any, encoded: Any): ...
|
||||
def safe_summary(self, encoded: Any): ...
|
||||
def must_update(self, encoded: Any): ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
|
||||
class BCryptSHA256PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
digest: Any = ...
|
||||
library: Any = ...
|
||||
rounds: int = ...
|
||||
def salt(self): ...
|
||||
def encode(self, password: Any, salt: Any): ...
|
||||
def verify(self, password: Any, encoded: Any): ...
|
||||
def safe_summary(self, encoded: Any): ...
|
||||
def must_update(self, encoded: Any): ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
|
||||
class BCryptPasswordHasher(BCryptSHA256PasswordHasher):
|
||||
algorithm: str = ...
|
||||
digest: Any = ...
|
||||
|
||||
class SHA1PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def safe_summary(self, encoded: Any): ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
|
||||
class MD5PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def safe_summary(self, encoded: str) -> OrderedDict: ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
|
||||
class UnsaltedSHA1PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
def salt(self) -> str: ...
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def safe_summary(self, encoded: Any): ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
|
||||
class UnsaltedMD5PasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
def salt(self) -> str: ...
|
||||
def encode(self, password: str, salt: str) -> str: ...
|
||||
def verify(self, password: str, encoded: str) -> bool: ...
|
||||
def safe_summary(self, encoded: Any): ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
|
||||
class CryptPasswordHasher(BasePasswordHasher):
|
||||
algorithm: str = ...
|
||||
library: str = ...
|
||||
def salt(self): ...
|
||||
def encode(self, password: Any, salt: Any): ...
|
||||
def verify(self, password: Any, encoded: Any): ...
|
||||
def safe_summary(self, encoded: Any): ...
|
||||
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
|
||||
class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher): ...
|
||||
class Argon2PasswordHasher(BasePasswordHasher): ...
|
||||
class BCryptSHA256PasswordHasher(BasePasswordHasher): ...
|
||||
class BCryptPasswordHasher(BCryptSHA256PasswordHasher): ...
|
||||
class SHA1PasswordHasher(BasePasswordHasher): ...
|
||||
class MD5PasswordHasher(BasePasswordHasher): ...
|
||||
class UnsaltedSHA1PasswordHasher(BasePasswordHasher): ...
|
||||
class UnsaltedMD5PasswordHasher(BasePasswordHasher): ...
|
||||
class CryptPasswordHasher(BasePasswordHasher): ...
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
from django.db.models.base import Model
|
||||
from typing import Any, List, Type
|
||||
|
||||
from django.contrib.admin.options import InlineModelAdmin
|
||||
from django.db.models.base import Model
|
||||
|
||||
class GenericInlineModelAdminChecks:
|
||||
def _check_exclude_of_parent_model(self, obj: GenericTabularInline, parent_model: Type[Model]) -> List[Any]: ...
|
||||
def _check_relation(self, obj: GenericTabularInline, parent_model: Type[Model]) -> List[Any]: ...
|
||||
def _check_exclude_of_parent_model(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ...
|
||||
def _check_relation(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ...
|
||||
|
||||
class GenericInlineModelAdmin(InlineModelAdmin):
|
||||
template: str = ...
|
||||
|
||||
class GenericStackedInline(GenericInlineModelAdmin): ...
|
||||
class GenericTabularInline(GenericInlineModelAdmin): ...
|
||||
|
||||
@@ -79,6 +79,7 @@ class GenericRelation(ForeignObject):
|
||||
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],
|
||||
@@ -90,13 +91,11 @@ class GenericRelation(ForeignObject):
|
||||
**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: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from datetime import date, datetime
|
||||
from datetime import date, datetime as datetime
|
||||
from decimal import Decimal
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .api import get_level as get_level, set_level as set_level
|
||||
|
||||
@@ -13,22 +13,14 @@ class ArrayField(CheckFieldDefaultMixin, Field, Generic[_T]):
|
||||
default_validators: Any = ...
|
||||
from_db_value: Any = ...
|
||||
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]: ...
|
||||
|
||||
@@ -5,43 +5,13 @@ from django.db import models
|
||||
class RangeField(models.Field):
|
||||
empty_strings_allowed: bool = ...
|
||||
base_field: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
@property
|
||||
def model(self): ...
|
||||
@model.setter
|
||||
def model(self, model: Any) -> None: ...
|
||||
range_type: Any = ...
|
||||
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):
|
||||
base_field: Any = ...
|
||||
range_type: Any = ...
|
||||
form_field: Any = ...
|
||||
def db_type(self, connection: Any): ...
|
||||
|
||||
class BigIntegerRangeField(RangeField):
|
||||
base_field: Any = ...
|
||||
range_type: Any = ...
|
||||
form_field: Any = ...
|
||||
def db_type(self, connection: Any): ...
|
||||
|
||||
class FloatRangeField(RangeField):
|
||||
base_field: Any = ...
|
||||
range_type: Any = ...
|
||||
form_field: Any = ...
|
||||
def db_type(self, connection: Any): ...
|
||||
|
||||
class DateTimeRangeField(RangeField):
|
||||
base_field: Any = ...
|
||||
range_type: Any = ...
|
||||
form_field: Any = ...
|
||||
def db_type(self, connection: Any): ...
|
||||
|
||||
class DateRangeField(RangeField):
|
||||
base_field: Any = ...
|
||||
range_type: Any = ...
|
||||
form_field: Any = ...
|
||||
def db_type(self, connection: Any): ...
|
||||
class IntegerRangeField(RangeField): ...
|
||||
class BigIntegerRangeField(RangeField): ...
|
||||
class FloatRangeField(RangeField): ...
|
||||
class DateTimeRangeField(RangeField): ...
|
||||
class DateRangeField(RangeField): ...
|
||||
|
||||
@@ -41,10 +41,10 @@ class SessionBase:
|
||||
def get_expire_at_browser_close(self) -> bool: ...
|
||||
def flush(self) -> None: ...
|
||||
def cycle_key(self) -> None: ...
|
||||
def exists(self, session_key: Any) -> None: ...
|
||||
def exists(self, session_key: str) -> None: ...
|
||||
def create(self) -> None: ...
|
||||
def save(self, must_create: bool = ...) -> None: ...
|
||||
def delete(self, session_key: Optional[Any] = ...) -> None: ...
|
||||
def load(self) -> None: ...
|
||||
def load(self) -> Dict[str, Any]: ...
|
||||
@classmethod
|
||||
def clear_expired(cls) -> None: ...
|
||||
|
||||
@@ -2,11 +2,10 @@ from typing import Type
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.request import HttpRequest
|
||||
from django.http.response import HttpResponse
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
class SessionMiddleware(MiddlewareMixin):
|
||||
SessionStore: Type[SessionBase] = ...
|
||||
def process_request(self, request: HttpRequest) -> None: ...
|
||||
def process_request(self, request: WSGIRequest) -> None: ...
|
||||
def process_response(self, request: WSGIRequest, response: HttpResponse) -> HttpResponse: ...
|
||||
|
||||
2
django-stubs/core/cache/backends/base.pyi
vendored
2
django-stubs/core/cache/backends/base.pyi
vendored
@@ -21,7 +21,7 @@ class BaseCache:
|
||||
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
|
||||
def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> str: ...
|
||||
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
|
||||
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
|
||||
def delete(self, key: Any, version: Optional[Any] = ...) -> None: ...
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
from .messages import Warning as Warning, Info as Info, Debug as Debug, Error as Error, Critical as Critical
|
||||
|
||||
from .registry import run_checks as run_checks, Tags as Tags, register as register
|
||||
|
||||
@@ -6,6 +6,10 @@ from django.http.response import HttpResponse, HttpResponseBase
|
||||
logger: Any
|
||||
|
||||
class BaseHandler:
|
||||
_view_middleware: None = ...
|
||||
_template_response_middleware: None = ...
|
||||
_exception_middleware: None = ...
|
||||
_middleware_chain: None = ...
|
||||
def load_middleware(self) -> None: ...
|
||||
def make_view_atomic(self, view: Callable) -> Callable: ...
|
||||
def get_exception_response(self, request: Any, resolver: Any, status_code: Any, exception: Any): ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Dict, List, Optional, Union, Iterable, Sequence
|
||||
from typing import Dict, List, Optional, Union, Iterable, Sequence, Protocol, Any
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
@@ -8,13 +8,23 @@ class InvalidPage(Exception): ...
|
||||
class PageNotAnInteger(InvalidPage): ...
|
||||
class EmptyPage(InvalidPage): ...
|
||||
|
||||
class SupportsLen(Protocol):
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
class SupportsCount(Protocol):
|
||||
def count(self) -> int: ...
|
||||
|
||||
class Paginator:
|
||||
object_list: QuerySet = ...
|
||||
per_page: int = ...
|
||||
orphans: int = ...
|
||||
allow_empty_first_page: bool = ...
|
||||
def __init__(
|
||||
self, object_list: Iterable, per_page: Union[int, str], orphans: int = ..., allow_empty_first_page: bool = ...
|
||||
self,
|
||||
object_list: Union[SupportsLen, SupportsCount],
|
||||
per_page: Union[int, str],
|
||||
orphans: int = ...,
|
||||
allow_empty_first_page: bool = ...,
|
||||
) -> None: ...
|
||||
def validate_number(self, number: Optional[Union[float, str]]) -> int: ...
|
||||
def get_page(self, number: Optional[int]) -> Page: ...
|
||||
|
||||
@@ -2,10 +2,18 @@ from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.core.serializers.base import Serializer, Deserializer
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from .base import (
|
||||
Serializer as Serializer,
|
||||
Deserializer as Deserializer,
|
||||
SerializerDoesNotExist as SerializerDoesNotExist,
|
||||
SerializationError as SerializationError,
|
||||
DeserializationError as DeserializationError,
|
||||
M2MDeserializationError as M2MDeserializationError,
|
||||
)
|
||||
|
||||
BUILTIN_SERIALIZERS: Any
|
||||
|
||||
class BadSerializer:
|
||||
|
||||
@@ -18,10 +18,11 @@ from . import migrations
|
||||
|
||||
connections: Any
|
||||
router: Any
|
||||
connection: Any
|
||||
|
||||
class DefaultConnectionProxy:
|
||||
def __getattr__(self, item: str) -> Any: ...
|
||||
def __setattr__(self, name: str, value: Any) -> None: ...
|
||||
def __delattr__(self, name: str) -> None: ...
|
||||
|
||||
connection: Any
|
||||
def close_old_connections(**kwargs): ...
|
||||
|
||||
@@ -37,6 +37,7 @@ from .fields import (
|
||||
FilePathField as FilePathField,
|
||||
BinaryField as BinaryField,
|
||||
DurationField as DurationField,
|
||||
BigAutoField as BigAutoField,
|
||||
)
|
||||
|
||||
from .fields.related import (
|
||||
@@ -78,8 +79,21 @@ from .expressions import (
|
||||
RawSQL as RawSQL,
|
||||
Value as Value,
|
||||
Func as Func,
|
||||
ExpressionWrapper as ExpressionWrapper,
|
||||
)
|
||||
|
||||
from .manager import BaseManager as BaseManager, Manager as Manager
|
||||
|
||||
from . import lookups as lookups
|
||||
|
||||
from .aggregates import (
|
||||
Avg as Avg,
|
||||
Min as Min,
|
||||
Max as Max,
|
||||
Variance as Variance,
|
||||
StdDev as StdDev,
|
||||
Sum as Sum,
|
||||
Aggregate as Aggregate,
|
||||
)
|
||||
|
||||
from .indexes import Index as Index
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
from typing import Any, List, Optional, Set, Tuple, Dict
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, TypeVar, Union
|
||||
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
class ModelBase(type): ...
|
||||
|
||||
_Self = TypeVar("_Self", bound="Model")
|
||||
|
||||
class Model(metaclass=ModelBase):
|
||||
class DoesNotExist(Exception):
|
||||
pass
|
||||
_meta: Any
|
||||
pk: Any = ...
|
||||
objects: Manager[Model]
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def delete(self, using: Any = ..., keep_parents: bool = ...) -> Tuple[int, Dict[str, int]]: ...
|
||||
def full_clean(self, exclude: Optional[List[str]] = ..., validate_unique: bool = ...) -> None: ...
|
||||
def clean_fields(self, exclude: List[str] = ...) -> None: ...
|
||||
@@ -19,7 +22,14 @@ class Model(metaclass=ModelBase):
|
||||
force_insert: bool = ...,
|
||||
force_update: bool = ...,
|
||||
using: Optional[str] = ...,
|
||||
update_fields: Optional[List[str]] = ...,
|
||||
update_fields: Optional[Union[List[str], str]] = ...,
|
||||
) -> None: ...
|
||||
def refresh_from_db(self, using: None = ..., fields: Optional[List[str]] = ...) -> None: ...
|
||||
def refresh_from_db(self: _Self, using: Optional[str] = ..., fields: Optional[List[str]] = ...) -> _Self: ...
|
||||
def get_deferred_fields(self) -> Set[str]: ...
|
||||
|
||||
class ModelStateFieldsCacheDescriptor: ...
|
||||
|
||||
class ModelState:
|
||||
db: None = ...
|
||||
adding: bool = ...
|
||||
fields_cache: ModelStateFieldsCacheDescriptor = ...
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
from django.db import IntegrityError
|
||||
|
||||
def CASCADE(collector, field, sub_objs, using): ...
|
||||
def SET_NULL(collector, field, sub_objs, using): ...
|
||||
def SET_DEFAULT(collector, field, sub_objs, using): ...
|
||||
def DO_NOTHING(collector, field, sub_objs, using): ...
|
||||
def PROTECT(collector, field, sub_objs, using): ...
|
||||
|
||||
class ProtectedError(IntegrityError): ...
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||
|
||||
from django.db.models import QuerySet
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.lookups import Lookup
|
||||
from django.db.models.sql import Query
|
||||
from django.db.models.sql.compiler import SQLCompiler
|
||||
|
||||
from django.db.models import Q, QuerySet
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.sql import Query
|
||||
|
||||
_OutputField = Union[Field, str]
|
||||
|
||||
class SQLiteNumericMixin:
|
||||
def as_sqlite(self, compiler: SQLCompiler, connection: Any, **extra_context: Any) -> Tuple[str, List[float]]: ...
|
||||
|
||||
@@ -26,9 +29,10 @@ class Combinable:
|
||||
def __add__(self, other: Optional[Union[timedelta, Combinable, float, str]]) -> CombinedExpression: ...
|
||||
def __sub__(self, other: Union[timedelta, Combinable, float]) -> CombinedExpression: ...
|
||||
def __mul__(self, other: Union[timedelta, Combinable, float]) -> CombinedExpression: ...
|
||||
def __truediv__(self, other: float) -> CombinedExpression: ...
|
||||
def __mod__(self, other: int) -> CombinedExpression: ...
|
||||
def __pow__(self, other: float) -> CombinedExpression: ...
|
||||
def __truediv__(self, other: Union[Combinable, float]) -> Combinable: ...
|
||||
def __itruediv__(self, other: Union[Combinable, float]) -> Combinable: ...
|
||||
def __mod__(self, other: int) -> Combinable: ...
|
||||
def __pow__(self, other: float) -> Combinable: ...
|
||||
def __and__(self, other: Combinable) -> Any: ...
|
||||
def bitand(self, other: int) -> CombinedExpression: ...
|
||||
def bitleftshift(self, other: int) -> CombinedExpression: ...
|
||||
@@ -48,11 +52,10 @@ class BaseExpression:
|
||||
is_summary: bool = ...
|
||||
filterable: bool = ...
|
||||
window_compatible: bool = ...
|
||||
def __init__(self, output_field: Optional[Union[Field, str]] = ...) -> None: ...
|
||||
def __init__(self, output_field: Optional[_OutputField] = ...) -> None: ...
|
||||
def get_db_converters(self, connection: Any) -> List[Callable]: ...
|
||||
def get_source_expressions(self) -> List[Any]: ...
|
||||
def set_source_expressions(self, exprs: List[Any]) -> None: ...
|
||||
def as_sql(self, compiler: Any, connection: Any) -> None: ...
|
||||
def contains_aggregate(self) -> bool: ...
|
||||
def contains_over_clause(self) -> bool: ...
|
||||
def contains_column_references(self) -> bool: ...
|
||||
@@ -80,6 +83,12 @@ class BaseExpression:
|
||||
def reverse_ordering(self): ...
|
||||
def flatten(self) -> Iterator[Expression]: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def as_sqlite(self, compiler: SQLCompiler, connection: Any) -> Any: ...
|
||||
def as_sql(self, compiler: SQLCompiler, connection: Any, **extra_context: Any) -> Any: ...
|
||||
def as_mysql(self, compiler: Any, connection: Any) -> Any: ...
|
||||
def as_postgresql(self, compiler: Any, connection: Any) -> Any: ...
|
||||
def as_oracle(self, compiler: Any, connection: Any): ...
|
||||
|
||||
class Expression(BaseExpression, Combinable): ...
|
||||
|
||||
@@ -87,10 +96,11 @@ class CombinedExpression(SQLiteNumericMixin, Expression):
|
||||
connector: Any = ...
|
||||
lhs: Any = ...
|
||||
rhs: Any = ...
|
||||
def __init__(self, lhs: Combinable, connector: str, rhs: Combinable, output_field: None = ...) -> None: ...
|
||||
def __init__(
|
||||
self, lhs: Combinable, connector: str, rhs: Combinable, output_field: Optional[_OutputField] = ...
|
||||
) -> None: ...
|
||||
def get_source_expressions(self) -> Union[List[Combinable], List[SQLiteNumericMixin]]: ...
|
||||
def set_source_expressions(self, exprs: List[Combinable]) -> None: ...
|
||||
def as_sql(self, compiler: SQLCompiler, connection: Any) -> Any: ...
|
||||
def resolve_expression(
|
||||
self,
|
||||
query: Any = ...,
|
||||
@@ -111,6 +121,9 @@ class F(Combinable):
|
||||
summarize: bool = ...,
|
||||
for_save: bool = ...,
|
||||
) -> Expression: ...
|
||||
def asc(self, **kwargs) -> OrderBy: ...
|
||||
def desc(self, **kwargs) -> OrderBy: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
|
||||
class OuterRef(F): ...
|
||||
|
||||
@@ -118,7 +131,7 @@ class Subquery(Expression):
|
||||
template: str = ...
|
||||
queryset: QuerySet = ...
|
||||
extra: Dict[Any, Any] = ...
|
||||
def __init__(self, queryset: QuerySet, output_field: Optional[Field] = ..., **extra: Any) -> None: ...
|
||||
def __init__(self, queryset: QuerySet, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ...
|
||||
|
||||
class Exists(Subquery):
|
||||
extra: Dict[Any, Any]
|
||||
@@ -139,13 +152,13 @@ class OrderBy(BaseExpression):
|
||||
|
||||
class Value(Expression):
|
||||
value: Any = ...
|
||||
def __init__(self, value: Any, output_field: Optional[Field] = ...) -> None: ...
|
||||
def __init__(self, value: Any, output_field: Optional[_OutputField] = ...) -> None: ...
|
||||
|
||||
class RawSQL(Expression):
|
||||
output_field: Field
|
||||
params: List[Any]
|
||||
sql: str
|
||||
def __init__(self, sql: str, params: Union[List[int], List[str], Tuple], output_field: None = ...) -> None: ...
|
||||
def __init__(self, sql: str, params: Sequence[Any], output_field: Optional[_OutputField] = ...) -> None: ...
|
||||
|
||||
class Func(SQLiteNumericMixin, Expression):
|
||||
function: Any = ...
|
||||
@@ -154,7 +167,7 @@ class Func(SQLiteNumericMixin, Expression):
|
||||
arity: Any = ...
|
||||
source_expressions: List[Expression] = ...
|
||||
extra: Any = ...
|
||||
def __init__(self, *expressions: Any, output_field: Optional[Any] = ..., **extra: Any) -> None: ...
|
||||
def __init__(self, *expressions: Any, output_field: Optional[_OutputField] = ..., **extra: Any) -> None: ...
|
||||
def get_source_expressions(self) -> List[Combinable]: ...
|
||||
def set_source_expressions(self, exprs: List[Expression]) -> None: ...
|
||||
def resolve_expression(
|
||||
@@ -180,5 +193,10 @@ class Case(Expression):
|
||||
default: Any = ...
|
||||
extra: Any = ...
|
||||
def __init__(
|
||||
self, *cases: Any, default: Optional[Any] = ..., output_field: Optional[Any] = ..., **extra: Any
|
||||
self, *cases: Any, default: Optional[Any] = ..., output_field: Optional[_OutputField] = ..., **extra: Any
|
||||
) -> None: ...
|
||||
|
||||
class ExpressionWrapper(Expression):
|
||||
def __init__(self, expression: Union[Expression, Q], output_field: _OutputField): ...
|
||||
def set_source_expressions(self, exprs: Sequence[Expression]) -> None: ...
|
||||
def get_source_expressions(self) -> List[Expression]: ...
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union
|
||||
from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type
|
||||
|
||||
from django.db.models import Model
|
||||
from django.db.models.query_utils import RegisterLookupMixin
|
||||
from django.forms import Widget, Field as FormField
|
||||
|
||||
_Choice = Tuple[Any, str]
|
||||
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
||||
@@ -10,11 +12,18 @@ _ValidatorCallable = Callable[..., None]
|
||||
_ErrorMessagesToOverride = Dict[str, Any]
|
||||
|
||||
class Field(RegisterLookupMixin):
|
||||
widget: Widget
|
||||
help_text: str
|
||||
db_table: str
|
||||
remote_field: Field
|
||||
model: Type[Model]
|
||||
name: str
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
primary_key: bool = ...,
|
||||
max_length: Optional[int] = ...,
|
||||
unique: bool = ...,
|
||||
blank: bool = ...,
|
||||
null: bool = ...,
|
||||
@@ -23,6 +32,9 @@ class Field(RegisterLookupMixin):
|
||||
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] = ...,
|
||||
@@ -31,6 +43,13 @@ class Field(RegisterLookupMixin):
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
def __get__(self, instance, owner) -> Any: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def set_attributes_from_name(self, name: str) -> None: ...
|
||||
def db_type(self, connection: Any) -> str: ...
|
||||
def db_parameters(self, connection: Any) -> Dict[str, str]: ...
|
||||
def get_prep_value(self, value: Any) -> Any: ...
|
||||
def formfield(self, **kwargs) -> FormField: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, private_only: bool = ...) -> None: ...
|
||||
|
||||
class IntegerField(Field):
|
||||
def __get__(self, instance, owner) -> int: ...
|
||||
@@ -86,6 +105,9 @@ class CharField(Field):
|
||||
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] = ...,
|
||||
@@ -112,6 +134,9 @@ class SlugField(CharField):
|
||||
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] = ...,
|
||||
@@ -168,6 +193,31 @@ class GenericIPAddressField(Field):
|
||||
class DateTimeCheckMixin: ...
|
||||
|
||||
class DateField(DateTimeCheckMixin, Field):
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
auto_now: bool = ...,
|
||||
auto_now_add: bool = ...,
|
||||
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 = ...,
|
||||
choices: Optional[_FieldChoices] = ...,
|
||||
help_text: str = ...,
|
||||
db_column: Optional[str] = ...,
|
||||
db_tablespace: Optional[str] = ...,
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
|
||||
class TimeField(DateTimeCheckMixin, Field):
|
||||
def __init__(
|
||||
self,
|
||||
verbose_name: Optional[str] = ...,
|
||||
@@ -191,7 +241,6 @@ class DateField(DateTimeCheckMixin, Field):
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
|
||||
class TimeField(DateTimeCheckMixin, Field): ...
|
||||
class DateTimeField(DateField): ...
|
||||
class UUIDField(Field): ...
|
||||
|
||||
@@ -206,6 +255,7 @@ class FilePathField(Field):
|
||||
allow_files: bool = ...,
|
||||
allow_folders: bool = ...,
|
||||
primary_key: bool = ...,
|
||||
max_length: int = ...,
|
||||
unique: bool = ...,
|
||||
blank: bool = ...,
|
||||
null: bool = ...,
|
||||
@@ -224,3 +274,4 @@ class FilePathField(Field):
|
||||
|
||||
class BinaryField(Field): ...
|
||||
class DurationField(Field): ...
|
||||
class BigAutoField(AutoField): ...
|
||||
|
||||
@@ -51,7 +51,6 @@ class FileField(Field):
|
||||
def get_internal_type(self) -> str: ...
|
||||
def get_prep_value(self, value: Union[FieldFile, str]) -> str: ...
|
||||
def pre_save(self, model_instance: Model, add: bool) -> FieldFile: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
||||
def generate_filename(self, instance: Optional[Model], filename: str) -> str: ...
|
||||
def save_form_data(self, instance: Model, data: Optional[Union[bool, File, str]]) -> None: ...
|
||||
def formfield(self, **kwargs: Any) -> form_fields.FileField: ...
|
||||
@@ -75,6 +74,5 @@ class ImageField(FileField):
|
||||
) -> None: ...
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
def deconstruct(self) -> Any: ...
|
||||
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
||||
def update_dimension_fields(self, instance: Model, force: bool = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
def formfield(self, **kwargs: Any) -> form_fields.ImageField: ...
|
||||
|
||||
@@ -1,9 +1,35 @@
|
||||
from typing import Type, Union, TypeVar, Any, Generic, List, Optional, Dict, Callable, Tuple, Sequence, TYPE_CHECKING
|
||||
from typing import (
|
||||
Type,
|
||||
Union,
|
||||
TypeVar,
|
||||
Any,
|
||||
Generic,
|
||||
List,
|
||||
Optional,
|
||||
Dict,
|
||||
Callable,
|
||||
Tuple,
|
||||
Sequence,
|
||||
TYPE_CHECKING,
|
||||
Iterable,
|
||||
)
|
||||
from uuid import UUID
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Field, Model, QuerySet
|
||||
from django.db.models.fields.mixins import FieldCacheMixin
|
||||
from django.db.models.fields.related_descriptors import (
|
||||
ReverseManyToOneDescriptor as ReverseManyToOneDescriptor,
|
||||
ReverseOneToOneDescriptor as ReverseOneToOneDescriptor,
|
||||
ForwardManyToOneDescriptor as ForwardManyToOneDescriptor,
|
||||
ForwardOneToOneDescriptor as ForwardOneToOneDescriptor,
|
||||
ManyToManyDescriptor as ManyToManyDescriptor,
|
||||
)
|
||||
from django.db.models.fields.reverse_related import (
|
||||
ForeignObjectRel as ForeignObjectRel,
|
||||
ManyToManyRel as ManyToManyRel,
|
||||
ManyToOneRel as ManyToOneRel,
|
||||
)
|
||||
from django.db.models.query_utils import PathInfo, Q
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -11,6 +37,15 @@ if TYPE_CHECKING:
|
||||
|
||||
_T = TypeVar("_T", bound=models.Model)
|
||||
|
||||
_Choice = Tuple[Any, str]
|
||||
_ChoiceNamedGroup = Tuple[str, Iterable[_Choice]]
|
||||
_FieldChoices = Iterable[Union[_Choice, _ChoiceNamedGroup]]
|
||||
|
||||
_ValidatorCallable = Callable[..., None]
|
||||
_ErrorMessagesToOverride = Dict[str, Any]
|
||||
|
||||
RECURSIVE_RELATIONSHIP_CONSTANT: str = ...
|
||||
|
||||
class RelatedField(FieldCacheMixin, Field):
|
||||
one_to_many: bool = ...
|
||||
one_to_one: bool = ...
|
||||
@@ -29,12 +64,41 @@ class RelatedField(FieldCacheMixin, Field):
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def do_related_class(self, other: Type[Model], cls: Type[Model]) -> None: ...
|
||||
def get_limit_choices_to(self) -> Dict[str, int]: ...
|
||||
def formfield(self, **kwargs: Any) -> Field: ...
|
||||
def related_query_name(self) -> str: ...
|
||||
@property
|
||||
def target_field(self) -> Field: ...
|
||||
|
||||
class ForeignObject(RelatedField): ...
|
||||
class ForeignObject(RelatedField):
|
||||
def __init__(
|
||||
self,
|
||||
to: Union[Type[Model], str],
|
||||
on_delete: Callable[..., None],
|
||||
from_fields: Sequence[str],
|
||||
to_fields: Sequence[str],
|
||||
rel: None = ...,
|
||||
related_name: Optional[str] = ...,
|
||||
related_query_name: None = ...,
|
||||
limit_choices_to: None = ...,
|
||||
parent_link: bool = ...,
|
||||
swappable: bool = ...,
|
||||
verbose_name: Optional[str] = ...,
|
||||
name: Optional[str] = ...,
|
||||
primary_key: bool = ...,
|
||||
unique: bool = ...,
|
||||
blank: bool = ...,
|
||||
null: bool = ...,
|
||||
db_index: bool = ...,
|
||||
default: Any = ...,
|
||||
editable: bool = ...,
|
||||
auto_created: bool = ...,
|
||||
serialize: bool = ...,
|
||||
choices: Optional[_FieldChoices] = ...,
|
||||
help_text: str = ...,
|
||||
db_column: Optional[str] = ...,
|
||||
db_tablespace: Optional[str] = ...,
|
||||
validators: Iterable[_ValidatorCallable] = ...,
|
||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||
): ...
|
||||
|
||||
class ForeignKey(RelatedField, Generic[_T]):
|
||||
def __init__(self, to: Union[Type[_T], str], on_delete: Any, related_name: str = ..., **kwargs): ...
|
||||
@@ -52,7 +116,6 @@ class ManyToManyField(RelatedField, Generic[_T]):
|
||||
rel_class: Any = ...
|
||||
description: Any = ...
|
||||
has_null_arg: Any = ...
|
||||
db_table: Any = ...
|
||||
swappable: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
@@ -64,7 +127,7 @@ class ManyToManyField(RelatedField, Generic[_T]):
|
||||
through: Optional[Union[str, Type[Model]]] = ...,
|
||||
through_fields: Optional[Tuple[str, str]] = ...,
|
||||
db_constraint: bool = ...,
|
||||
db_table: None = ...,
|
||||
db_table: Optional[str] = ...,
|
||||
swappable: bool = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
@@ -85,3 +148,5 @@ class ManyToManyField(RelatedField, Generic[_T]):
|
||||
def set_attributes_from_rel(self) -> None: ...
|
||||
def value_from_object(self, obj: Model) -> List[Model]: ...
|
||||
def save_form_data(self, instance: Model, data: QuerySet) -> None: ...
|
||||
|
||||
def create_many_to_many_intermediary_model(field: Type[Field], klass: Type[Model]) -> Type[Model]: ...
|
||||
|
||||
@@ -1 +1,61 @@
|
||||
from .text import Lower as Lower
|
||||
from .text import (
|
||||
Lower as Lower,
|
||||
Upper as Upper,
|
||||
Length as Length,
|
||||
Chr as Chr,
|
||||
Concat as Concat,
|
||||
ConcatPair as ConcatPair,
|
||||
Left as Left,
|
||||
Right as Right,
|
||||
LPad as LPad,
|
||||
RPad as RPad,
|
||||
LTrim as LTrim,
|
||||
RTrim as RTrim,
|
||||
Trim as Trim,
|
||||
Ord as Ord,
|
||||
Repeat as Repeat,
|
||||
StrIndex as StrIndex,
|
||||
Replace as Replace,
|
||||
Substr as Substr,
|
||||
)
|
||||
|
||||
from .window import (
|
||||
CumeDist as CumeDist,
|
||||
DenseRank as DenseRank,
|
||||
FirstValue as FirstValue,
|
||||
Lag as Lag,
|
||||
LastValue as LastValue,
|
||||
Lead as Lead,
|
||||
NthValue as NthValue,
|
||||
Ntile as Ntile,
|
||||
PercentRank as PercentRank,
|
||||
Rank as Rank,
|
||||
RowNumber as RowNumber,
|
||||
)
|
||||
|
||||
from .datetime import (
|
||||
Extract as Extract,
|
||||
ExtractDay as ExtractDay,
|
||||
ExtractHour as ExtractHour,
|
||||
ExtractMinute as ExtractMinute,
|
||||
ExtractSecond as ExtractSecond,
|
||||
ExtractMonth as ExtractMonth,
|
||||
ExtractQuarter as ExtractQuarter,
|
||||
ExtractWeek as ExtractWeek,
|
||||
ExtractWeekDay as ExtractWeekDay,
|
||||
ExtractYear as ExtractYear,
|
||||
Trunc as Trunc,
|
||||
TruncDate as TruncDate,
|
||||
TruncDay as TruncDay,
|
||||
TruncHour as TruncHour,
|
||||
TruncMinute as TruncMinute,
|
||||
TruncQuarter as TruncQuarter,
|
||||
TruncMonth as TruncMonth,
|
||||
TruncSecond as TruncSecond,
|
||||
TruncTime as TruncTime,
|
||||
TruncWeek as TruncWeek,
|
||||
TruncYear as TruncYear,
|
||||
Now as Now,
|
||||
)
|
||||
|
||||
from .comparison import Coalesce as Coalesce, Greatest as Greatest, Least as Least, Cast as Cast
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from datetime import date, datetime
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from typing import Any, List, Optional, Tuple, Union
|
||||
from typing import Any, Callable, Dict, List, Union
|
||||
|
||||
from django.db.models.expressions import Combinable, Expression
|
||||
|
||||
from django.db.backends.sqlite3.base import DatabaseWrapper
|
||||
from django.db.models import Func
|
||||
from django.db.models.expressions import Value
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.sql.compiler import SQLCompiler
|
||||
|
||||
class Cast(Func):
|
||||
contains_aggregate: bool
|
||||
@@ -14,15 +13,10 @@ class Cast(Func):
|
||||
extra: Dict[Any, Any]
|
||||
is_summary: bool
|
||||
output_field: Field
|
||||
source_expressions: List[django.db.models.expressions.Combinable]
|
||||
source_expressions: List[Combinable]
|
||||
function: str = ...
|
||||
template: str = ...
|
||||
def __init__(self, expression: Union[date, Decimal, Value, str], output_field: Field) -> None: ...
|
||||
def as_sql(
|
||||
self, compiler: SQLCompiler, connection: DatabaseWrapper, **extra_context: Any
|
||||
) -> Tuple[str, Union[List[date], List[Decimal]]]: ...
|
||||
def as_mysql(self, compiler: Any, connection: Any): ...
|
||||
def as_postgresql(self, compiler: Any, connection: Any): ...
|
||||
def __init__(self, expression: Union[date, Decimal, Expression, str], output_field: Union[str, Field]) -> None: ...
|
||||
|
||||
class Coalesce(Func):
|
||||
contains_aggregate: bool
|
||||
@@ -30,10 +24,9 @@ class Coalesce(Func):
|
||||
extra: Dict[Any, Any]
|
||||
is_summary: bool
|
||||
output_field: Field
|
||||
source_expressions: List[django.db.models.expressions.Combinable]
|
||||
source_expressions: List[Combinable]
|
||||
function: str = ...
|
||||
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
|
||||
def as_oracle(self, compiler: Any, connection: Any): ...
|
||||
|
||||
class Greatest(Func):
|
||||
contains_aggregate: bool
|
||||
@@ -42,10 +35,9 @@ class Greatest(Func):
|
||||
extra: Dict[Any, Any]
|
||||
is_summary: bool
|
||||
output_field: Field
|
||||
source_expressions: List[django.db.models.expressions.Combinable]
|
||||
source_expressions: List[Combinable]
|
||||
function: str = ...
|
||||
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
|
||||
def as_sqlite(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[datetime]]: ...
|
||||
|
||||
class Least(Func):
|
||||
contains_aggregate: bool
|
||||
@@ -54,7 +46,6 @@ class Least(Func):
|
||||
extra: Dict[Any, Any]
|
||||
is_summary: bool
|
||||
output_field: Field
|
||||
source_expressions: List[django.db.models.expressions.Combinable]
|
||||
source_expressions: List[Combinable]
|
||||
function: str = ...
|
||||
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
|
||||
def as_sqlite(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[datetime]]: ...
|
||||
|
||||
@@ -17,6 +17,8 @@ class BaseManager(QuerySet[_T]):
|
||||
def check(self, **kwargs: Any) -> List[Any]: ...
|
||||
@classmethod
|
||||
def from_queryset(cls, queryset_class: Any, class_name: Optional[Any] = ...): ...
|
||||
@classmethod
|
||||
def _get_queryset_methods(cls, queryset_class: type) -> Dict[str, Any]: ...
|
||||
def contribute_to_class(self, model: Type[Model], name: str) -> None: ...
|
||||
def db_manager(self, using: Optional[str] = ..., hints: Optional[Dict[str, Model]] = ...) -> Manager: ...
|
||||
def get_queryset(self) -> QuerySet[_T]: ...
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
from typing import TypeVar, Optional, Any, Type, Dict, Union, overload, List, Iterator, Tuple, Iterable, Sized, Sequence
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
MutableMapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Sized,
|
||||
Tuple,
|
||||
Type,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import Combinable
|
||||
from django.db.models.sql.query import Query, RawQuery
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Manager
|
||||
from django.db.models.sql.query import Query, RawQuery
|
||||
|
||||
_T = TypeVar("_T", bound=models.Model, covariant=True)
|
||||
|
||||
class QuerySet(Iterable[_T], Sized):
|
||||
query: Query
|
||||
def __init__(
|
||||
self,
|
||||
model: Optional[Type[models.Model]] = ...,
|
||||
@@ -23,6 +40,7 @@ class QuerySet(Iterable[_T], Sized):
|
||||
def __bool__(self) -> bool: ...
|
||||
def __class_getitem__(cls, item: Type[_T]):
|
||||
pass
|
||||
def __getstate__(self) -> Dict[str, Any]: ...
|
||||
@overload
|
||||
def __getitem__(self, k: int) -> _T: ...
|
||||
@overload
|
||||
@@ -35,25 +53,26 @@ class QuerySet(Iterable[_T], Sized):
|
||||
def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
|
||||
def get(self, *args: Any, **kwargs: Any) -> _T: ...
|
||||
def create(self, **kwargs: Any) -> _T: ...
|
||||
def bulk_create(self, objs: Sequence[Model], batch_size: Optional[int] = ...) -> List[_T]: ...
|
||||
def get_or_create(self, defaults: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ...
|
||||
def update_or_create(self, defaults: Optional[Dict[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ...
|
||||
def bulk_create(self, objs: Iterable[Model], batch_size: Optional[int] = ...) -> List[_T]: ...
|
||||
def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ...
|
||||
def update_or_create(
|
||||
self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any
|
||||
) -> Tuple[_T, bool]: ...
|
||||
def earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
|
||||
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
|
||||
def first(self) -> Optional[_T]: ...
|
||||
def last(self) -> Optional[_T]: ...
|
||||
def in_bulk(
|
||||
self, id_list: Any = ..., *, field_name: str = ...
|
||||
) -> Union[Dict[int, models.Model], Dict[str, models.Model]]: ...
|
||||
def in_bulk(self, id_list: Any = ..., *, field_name: str = ...) -> Dict[Union[int, str], models.Model]: ...
|
||||
def delete(self) -> Tuple[int, Dict[str, int]]: ...
|
||||
def update(self, **kwargs: Any) -> int: ...
|
||||
def _update(self, values: Any) -> Optional[Any]: ...
|
||||
def exists(self) -> bool: ...
|
||||
def explain(self, *, format: Optional[Any] = ..., **options: Any) -> str: ...
|
||||
def raw(
|
||||
self, raw_query: str, params: Any = ..., translations: Optional[Dict[str, str]] = ..., using: None = ...
|
||||
) -> RawQuerySet: ...
|
||||
def values(self, *fields: Any, **expressions: Any) -> QuerySet: ...
|
||||
def values_list(self, *fields: Any, flat: bool = ..., named: bool = ...) -> List[Any]: ...
|
||||
def values(self, *fields: Union[str, Combinable], **expressions: Any) -> QuerySet: ...
|
||||
def values_list(self, *fields: Union[str, Combinable], flat: bool = ..., named: bool = ...) -> QuerySet: ...
|
||||
def dates(self, field_name: str, kind: str, order: str = ...) -> QuerySet: ...
|
||||
def datetimes(self, field_name: str, kind: str, order: str = ..., tzinfo: None = ...) -> QuerySet: ...
|
||||
def none(self) -> QuerySet[_T]: ...
|
||||
@@ -93,9 +112,10 @@ class QuerySet(Iterable[_T], Sized):
|
||||
def __getattr__(self, item: str) -> Any: ...
|
||||
|
||||
class RawQuerySet(Iterable[_T], Sized):
|
||||
query: RawQuery
|
||||
def __init__(
|
||||
self,
|
||||
raw_query: RawQuery,
|
||||
raw_query: Union[RawQuery, str],
|
||||
model: Optional[Type[models.Model]] = ...,
|
||||
query: Optional[Query] = ...,
|
||||
params: Tuple[Any] = ...,
|
||||
@@ -144,3 +164,6 @@ class Prefetch(object):
|
||||
def get_current_queryset(self, level) -> Optional[QuerySet]: ...
|
||||
|
||||
def prefetch_related_objects(model_instances: Iterable[_T], *related_lookups: str) -> None: ...
|
||||
|
||||
class InstanceCheckMeta(type): ...
|
||||
class EmptyQuerySet(metaclass=InstanceCheckMeta): ...
|
||||
|
||||
@@ -50,6 +50,7 @@ class DeferredAttribute:
|
||||
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Any: ...
|
||||
|
||||
class RegisterLookupMixin:
|
||||
lookup_name: str
|
||||
@classmethod
|
||||
def get_lookups(cls) -> Dict[str, Any]: ...
|
||||
def get_lookup(self, lookup_name: str) -> Optional[Any]: ...
|
||||
@@ -58,6 +59,8 @@ class RegisterLookupMixin:
|
||||
def merge_dicts(dicts: List[Dict[str, Any]]) -> Dict[str, Any]: ...
|
||||
@classmethod
|
||||
def register_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...) -> Type[Any]: ...
|
||||
@classmethod
|
||||
def _unregister_lookup(cls, lookup: Any, lookup_name: Optional[str] = ...): ...
|
||||
|
||||
def select_related_descend(
|
||||
field: Field,
|
||||
|
||||
@@ -1 +1,8 @@
|
||||
from ..query import Query as Query, RawQuery as RawQuery
|
||||
from .query import Query as Query, RawQuery as RawQuery
|
||||
|
||||
from .subqueries import (
|
||||
InsertQuery as InsertQuery,
|
||||
AggregateQuery as AggregateQuery,
|
||||
DeleteQuery as DeleteQuery,
|
||||
UpdateQuery as UpdateQuery,
|
||||
)
|
||||
|
||||
@@ -6,7 +6,8 @@ from uuid import UUID
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import BaseExpression, Expression
|
||||
from django.db.models.sql import Query, RawQuery
|
||||
|
||||
from django.db.models.sql.query import Query, RawQuery
|
||||
|
||||
FORCE: Any
|
||||
|
||||
|
||||
14
django-stubs/db/models/sql/constants.pyi
Normal file
14
django-stubs/db/models/sql/constants.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import Dict, Pattern, Tuple
|
||||
|
||||
GET_ITERATOR_CHUNK_SIZE: int = ...
|
||||
|
||||
MULTI: str = ...
|
||||
SINGLE: str = ...
|
||||
CURSOR: str = ...
|
||||
NO_RESULTS: str = ...
|
||||
|
||||
ORDER_PATTERN: Pattern = ...
|
||||
ORDER_DIR: Dict[str, Tuple[str, str]] = ...
|
||||
|
||||
INNER: str = ...
|
||||
LOUTER: str = ...
|
||||
@@ -5,6 +5,8 @@ from decimal import Decimal
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
|
||||
from uuid import UUID
|
||||
|
||||
from django.db.models.sql.datastructures import BaseTable
|
||||
|
||||
from django.db.models import Model, Field, Q, FilteredRelation, Expression, QuerySet
|
||||
from django.db.models.query_utils import PathInfo
|
||||
from django.db.models.sql.compiler import SQLCompiler
|
||||
@@ -13,13 +15,14 @@ from django.db.models.sql.where import WhereNode
|
||||
JoinInfo = namedtuple("JoinInfo", ["final_field", "targets", "opts", "joins", "path", "transform_function"])
|
||||
|
||||
class RawQuery:
|
||||
high_mark: None
|
||||
low_mark: int
|
||||
high_mark: Optional[int]
|
||||
low_mark: Optional[int]
|
||||
params: Union[Any] = ...
|
||||
sql: str = ...
|
||||
using: str = ...
|
||||
extra_select: Dict[Any, Any] = ...
|
||||
annotation_select: Dict[Any, Any] = ...
|
||||
cursor: object = ...
|
||||
def __init__(self, sql: str, using: str, params: Any = ...) -> None: ...
|
||||
def chain(self, using: str) -> RawQuery: ...
|
||||
def clone(self, using: str) -> RawQuery: ...
|
||||
@@ -28,7 +31,7 @@ class RawQuery:
|
||||
|
||||
class Query:
|
||||
base_table: str
|
||||
related_ids: None
|
||||
related_ids: Optional[List[int]]
|
||||
related_updates: Dict[Type[Model], List[Tuple[Field, None, Union[int, str]]]]
|
||||
values: List[Any]
|
||||
alias_prefix: str = ...
|
||||
@@ -36,7 +39,7 @@ class Query:
|
||||
compiler: str = ...
|
||||
model: Optional[Type[Model]] = ...
|
||||
alias_refcount: Dict[str, int] = ...
|
||||
alias_map: OrderedDict = ...
|
||||
alias_map: Dict[str, BaseTable] = ...
|
||||
external_aliases: Set[str] = ...
|
||||
table_map: Dict[str, List[str]] = ...
|
||||
default_cols: bool = ...
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Type, Union
|
||||
import collections
|
||||
import uuid
|
||||
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Type, Union
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import Case
|
||||
from django.db.models.fields import DateTimeCheckMixin, Field
|
||||
from django.db.models.query import QuerySet
|
||||
from django.db.models.sql.datastructures import BaseTable
|
||||
from django.db.models.sql.query import Query
|
||||
from django.db.models.sql.where import WhereNode
|
||||
from django.utils.datastructures import ImmutableList
|
||||
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class DeleteQuery(Query):
|
||||
alias_refcount: Dict[str, int]
|
||||
@@ -46,16 +49,14 @@ class DeleteQuery(Query):
|
||||
table_map: Dict[str, List[str]]
|
||||
used_aliases: Set[str]
|
||||
values_select: Tuple
|
||||
where_class: Type[django.db.models.sql.where.WhereNode]
|
||||
where_class: Type[WhereNode]
|
||||
compiler: str = ...
|
||||
alias_map: Union[Dict[str, django.db.models.sql.datastructures.BaseTable], collections.OrderedDict] = ...
|
||||
where: django.db.models.sql.where.WhereNode = ...
|
||||
where: WhereNode = ...
|
||||
def do_query(self, table: str, where: WhereNode, using: str) -> int: ...
|
||||
def delete_batch(self, pk_list: Union[List[int], List[str]], using: str) -> int: ...
|
||||
def delete_qs(self, query: QuerySet, using: str) -> int: ...
|
||||
|
||||
class UpdateQuery(Query):
|
||||
alias_map: collections.OrderedDict
|
||||
alias_refcount: Dict[str, int]
|
||||
annotation_select_mask: Optional[Set[Any]]
|
||||
base_table: str
|
||||
@@ -81,8 +82,6 @@ class UpdateQuery(Query):
|
||||
max_depth: int
|
||||
model: Type[Model]
|
||||
order_by: Tuple
|
||||
related_ids: Optional[List[int]]
|
||||
related_updates: Dict[Type[Model], List[Tuple[Field, None, Union[int, str]]]]
|
||||
select: Tuple
|
||||
select_for_update: bool
|
||||
select_for_update_nowait: bool
|
||||
@@ -94,13 +93,13 @@ class UpdateQuery(Query):
|
||||
subquery: bool
|
||||
table_map: Dict[str, List[str]]
|
||||
used_aliases: Set[str]
|
||||
values: List[Tuple[Field, Optional[Type[Model]], Union[django.db.models.expressions.Case, uuid.UUID]]]
|
||||
values: List[Tuple[Field, Optional[Type[Model]], Union[Case, uuid.UUID]]]
|
||||
values_select: Tuple
|
||||
where_class: Type[django.db.models.sql.where.WhereNode]
|
||||
where_class: Type[WhereNode]
|
||||
compiler: str = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def clone(self) -> UpdateQuery: ...
|
||||
where: django.db.models.sql.where.WhereNode = ...
|
||||
where: WhereNode = ...
|
||||
def update_batch(self, pk_list: List[int], values: Dict[str, Optional[int]], using: str) -> None: ...
|
||||
def add_update_values(self, values: Dict[str, Any]) -> None: ...
|
||||
def add_update_fields(self, values_seq: List[Tuple[Field, Optional[Type[Model]], Case]]) -> None: ...
|
||||
@@ -108,7 +107,6 @@ class UpdateQuery(Query):
|
||||
def get_related_updates(self) -> List[UpdateQuery]: ...
|
||||
|
||||
class InsertQuery(Query):
|
||||
alias_map: collections.OrderedDict
|
||||
alias_refcount: Dict[str, int]
|
||||
annotation_select_mask: None
|
||||
combinator: None
|
||||
@@ -144,21 +142,16 @@ class InsertQuery(Query):
|
||||
table_map: Dict[str, List[str]]
|
||||
used_aliases: Set[Any]
|
||||
values_select: Tuple
|
||||
where: django.db.models.sql.where.WhereNode
|
||||
where_class: Type[django.db.models.sql.where.WhereNode]
|
||||
where: WhereNode
|
||||
where_class: Type[WhereNode]
|
||||
compiler: str = ...
|
||||
fields: Union[
|
||||
List[django.db.models.fields.DateTimeCheckMixin], List[Field], django.utils.datastructures.ImmutableList
|
||||
] = ...
|
||||
fields: Iterable[Field] = ...
|
||||
objs: List[Model] = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
raw: bool = ...
|
||||
def insert_values(
|
||||
self, fields: Union[List[DateTimeCheckMixin], List[Field], ImmutableList], objs: List[Model], raw: bool = ...
|
||||
) -> None: ...
|
||||
def insert_values(self, fields: Iterable[Field], objs: List[Model], raw: bool = ...) -> None: ...
|
||||
|
||||
class AggregateQuery(Query):
|
||||
alias_map: collections.OrderedDict
|
||||
alias_refcount: Dict[Any, Any]
|
||||
annotation_select_mask: None
|
||||
combinator: None
|
||||
@@ -191,11 +184,10 @@ class AggregateQuery(Query):
|
||||
select_related: bool
|
||||
standard_ordering: bool
|
||||
sub_params: Tuple
|
||||
subquery: Union[bool, str]
|
||||
table_map: Dict[Any, Any]
|
||||
used_aliases: Set[Any]
|
||||
values_select: Tuple
|
||||
where: django.db.models.sql.where.WhereNode
|
||||
where_class: Type[django.db.models.sql.where.WhereNode]
|
||||
where: WhereNode
|
||||
where_class: Type[WhereNode]
|
||||
compiler: str = ...
|
||||
def add_subquery(self, query: Query, using: str) -> None: ...
|
||||
|
||||
@@ -2,8 +2,66 @@ from django.core.exceptions import ValidationError as ValidationError
|
||||
|
||||
from .forms import Form as Form, BaseForm as BaseForm
|
||||
|
||||
from .models import ModelForm as ModelForm
|
||||
from .models import (
|
||||
ModelForm as ModelForm,
|
||||
ModelChoiceField as ModelChoiceField,
|
||||
ModelMultipleChoiceField as ModelMultipleChoiceField,
|
||||
)
|
||||
|
||||
from .widgets import Widget as Widget, ChoiceWidget as ChoiceWidget
|
||||
from .widgets import (
|
||||
Widget as Widget,
|
||||
ChoiceWidget as ChoiceWidget,
|
||||
NumberInput as NumberInput,
|
||||
Select as Select,
|
||||
CheckboxInput as CheckboxInput,
|
||||
CheckboxSelectMultiple as CheckboxSelectMultiple,
|
||||
Media as Media,
|
||||
MultiWidget as MultiWidget,
|
||||
TextInput as TextInput,
|
||||
Textarea as Textarea,
|
||||
Input as Input,
|
||||
ClearableFileInput as ClearableFileInput,
|
||||
DateInput as DateInput,
|
||||
DateTimeBaseInput as DateTimeBaseInput,
|
||||
DateTimeInput as DateTimeInput,
|
||||
EmailInput as EmailInput,
|
||||
FileInput as FileInput,
|
||||
HiddenInput as HiddenInput,
|
||||
MultipleHiddenInput as MultipleHiddenInput,
|
||||
NullBooleanSelect as NullBooleanSelect,
|
||||
PasswordInput as PasswordInput,
|
||||
RadioSelect as RadioSelect,
|
||||
SelectMultiple as SelectMultiple,
|
||||
TimeInput as TimeInput,
|
||||
URLInput as URLInput,
|
||||
)
|
||||
|
||||
from .fields import Field as Field, CharField as CharField
|
||||
from .fields import (
|
||||
Field as Field,
|
||||
CharField as CharField,
|
||||
ChoiceField as ChoiceField,
|
||||
DurationField as DurationField,
|
||||
FileField as FileField,
|
||||
ImageField as ImageField,
|
||||
DateTimeField as DateTimeField,
|
||||
DateField as DateField,
|
||||
BooleanField as BooleanField,
|
||||
EmailField as EmailField,
|
||||
FloatField as FloatField,
|
||||
MultiValueField as MultiValueField,
|
||||
MultipleChoiceField as MultipleChoiceField,
|
||||
NullBooleanField as NullBooleanField,
|
||||
SplitDateTimeField as SplitDateTimeField,
|
||||
TimeField as TimeField,
|
||||
IntegerField as IntegerField,
|
||||
FilePathField as FilePathField,
|
||||
DecimalField as DecimalField,
|
||||
UUIDField as UUIDField,
|
||||
URLField as URLField,
|
||||
ComboField as ComboField,
|
||||
GenericIPAddressField as GenericIPAddressField,
|
||||
RegexField as RegexField,
|
||||
SlugField as SlugField,
|
||||
TypedChoiceField as TypedChoiceField,
|
||||
TypedMultipleChoiceField as TypedMultipleChoiceField,
|
||||
)
|
||||
|
||||
@@ -6,6 +6,16 @@ from django.forms.utils import ErrorList
|
||||
|
||||
from django.forms import Form
|
||||
|
||||
TOTAL_FORM_COUNT: str = ...
|
||||
INITIAL_FORM_COUNT: str = ...
|
||||
MIN_NUM_FORM_COUNT: str = ...
|
||||
MAX_NUM_FORM_COUNT: str = ...
|
||||
ORDERING_FIELD_NAME: str = ...
|
||||
DELETION_FIELD_NAME: str = ...
|
||||
|
||||
DEFAULT_MIN_NUM: int = ...
|
||||
DEFAULT_MAX_NUM: int = ...
|
||||
|
||||
class ManagementForm(Form):
|
||||
auto_id: Union[bool, str]
|
||||
cleaned_data: Dict[str, Optional[int]]
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date, datetime
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union, Sequence
|
||||
from unittest.mock import MagicMock
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db.models import ForeignKey
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.manager import Manager
|
||||
from django.db.models.query import QuerySet
|
||||
@@ -136,23 +137,23 @@ class BaseModelFormSet(BaseFormSet):
|
||||
def modelformset_factory(
|
||||
model: Type[Model],
|
||||
form: Type[ModelForm] = ...,
|
||||
formfield_callback: None = ...,
|
||||
formfield_callback: Optional[Callable] = ...,
|
||||
formset: Type[BaseModelFormSet] = ...,
|
||||
extra: int = ...,
|
||||
can_delete: bool = ...,
|
||||
can_order: bool = ...,
|
||||
max_num: None = ...,
|
||||
fields: None = ...,
|
||||
exclude: None = ...,
|
||||
widgets: None = ...,
|
||||
min_num: Optional[int] = ...,
|
||||
max_num: Optional[int] = ...,
|
||||
fields: Optional[Union[str, Sequence[str]]] = ...,
|
||||
exclude: Optional[Sequence[str]] = ...,
|
||||
widgets: Optional[Dict[str, Any]] = ...,
|
||||
validate_max: bool = ...,
|
||||
localized_fields: None = ...,
|
||||
labels: None = ...,
|
||||
help_texts: None = ...,
|
||||
error_messages: None = ...,
|
||||
min_num: None = ...,
|
||||
labels: Optional[Dict[str, str]] = ...,
|
||||
help_texts: Optional[Dict[str, str]] = ...,
|
||||
error_messages: Optional[Dict[str, Dict[str, str]]] = ...,
|
||||
validate_min: bool = ...,
|
||||
field_classes: None = ...,
|
||||
field_classes: Optional[Dict[str, Any]] = ...,
|
||||
) -> Any: ...
|
||||
|
||||
class BaseInlineFormSet(BaseModelFormSet):
|
||||
@@ -182,22 +183,22 @@ def inlineformset_factory(
|
||||
form: Type[ModelForm] = ...,
|
||||
formset: Type[BaseInlineFormSet] = ...,
|
||||
fk_name: Optional[str] = ...,
|
||||
fields: Optional[str] = ...,
|
||||
exclude: None = ...,
|
||||
fields: Optional[Union[str, Sequence[str]]] = ...,
|
||||
exclude: Optional[Sequence[str]] = ...,
|
||||
extra: int = ...,
|
||||
can_order: bool = ...,
|
||||
can_delete: bool = ...,
|
||||
max_num: None = ...,
|
||||
formfield_callback: None = ...,
|
||||
widgets: None = ...,
|
||||
max_num: Optional[int] = ...,
|
||||
formfield_callback: Optional[Callable] = ...,
|
||||
widgets: Optional[Dict[str, Any]] = ...,
|
||||
validate_max: bool = ...,
|
||||
localized_fields: None = ...,
|
||||
labels: None = ...,
|
||||
help_texts: None = ...,
|
||||
error_messages: None = ...,
|
||||
min_num: None = ...,
|
||||
labels: Optional[Dict[str, str]] = ...,
|
||||
help_texts: Optional[Dict[str, str]] = ...,
|
||||
error_messages: Optional[Dict[str, Dict[str, str]]] = ...,
|
||||
min_num: Optional[int] = ...,
|
||||
validate_min: bool = ...,
|
||||
field_classes: None = ...,
|
||||
field_classes: Optional[Dict[str, Any]] = ...,
|
||||
) -> Any: ...
|
||||
|
||||
class InlineForeignKeyField(Field):
|
||||
@@ -266,3 +267,7 @@ class ModelMultipleChoiceField(ModelChoiceField):
|
||||
hidden_widget: Any = ...
|
||||
default_error_messages: Any = ...
|
||||
def __init__(self, queryset: QuerySet, **kwargs: Any) -> None: ...
|
||||
|
||||
def _get_foreign_key(
|
||||
parent_model: Type[Model], model: Type[Model], fk_name: Optional[str] = ..., can_fail: bool = ...
|
||||
) -> ForeignKey: ...
|
||||
|
||||
@@ -15,6 +15,7 @@ from django.utils.safestring import SafeText
|
||||
class MediaOrderConflictWarning(RuntimeWarning): ...
|
||||
|
||||
class Media:
|
||||
_js: str
|
||||
def __init__(
|
||||
self,
|
||||
media: Optional[type] = ...,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, BinaryIO, Dict, Iterable, Iterator, List, Optional, overload, Pattern, Tuple, Union
|
||||
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.core.files import uploadhandler, uploadedfile
|
||||
from django.utils.datastructures import MultiValueDict, ImmutableList
|
||||
from django.urls import ResolverMatch
|
||||
@@ -17,17 +18,18 @@ class RawPostDataException(Exception): ...
|
||||
UploadHandlerList = Union[List[uploadhandler.FileUploadHandler], ImmutableList[uploadhandler.FileUploadHandler]]
|
||||
|
||||
class HttpRequest(BytesIO):
|
||||
GET = ... # type: QueryDict
|
||||
POST = ... # type: QueryDict
|
||||
COOKIES = ... # type: Dict[str, str]
|
||||
META = ... # type: Dict[str, str]
|
||||
FILES = ... # type: MultiValueDict[str, uploadedfile.UploadedFile]
|
||||
path = ... # type: str
|
||||
path_info = ... # type: str
|
||||
method = ... # type: Optional[str]
|
||||
resolver_match = ... # type: ResolverMatch
|
||||
content_type = ... # type: Optional[str]
|
||||
content_params = ... # type: Optional[Dict[str, str]]
|
||||
GET: QueryDict = ...
|
||||
POST: QueryDict = ...
|
||||
COOKIES: Dict[str, str] = ...
|
||||
META: Dict[str, str] = ...
|
||||
FILES: MultiValueDict[str, uploadedfile.UploadedFile] = ...
|
||||
path: str = ...
|
||||
path_info: str = ...
|
||||
method: Optional[str] = ...
|
||||
resolver_match: ResolverMatch = ...
|
||||
content_type: Optional[str] = ...
|
||||
content_params: Optional[Dict[str, str]] = ...
|
||||
session: SessionBase
|
||||
def __init__(self) -> None: ...
|
||||
def get_host(self) -> str: ...
|
||||
def get_port(self) -> str: ...
|
||||
@@ -58,6 +60,7 @@ class HttpRequest(BytesIO):
|
||||
|
||||
class QueryDict(MultiValueDict[str, str]):
|
||||
encoding = str # type: Any
|
||||
_mutable: bool = ...
|
||||
def __init__(
|
||||
self, query_string: Union[str, bytes, None] = None, mutable: bool = False, encoding: Optional[str] = None
|
||||
) -> None: ...
|
||||
@@ -68,7 +71,6 @@ class QueryDict(MultiValueDict[str, str]):
|
||||
def setlist(self, key: str, list_: List[str]) -> None: ...
|
||||
def setlistdefault(self, key: str, default_list: List[str] = None) -> List[str]: ...
|
||||
def appendlist(self, key: str, value: str) -> None: ...
|
||||
def pop(self, key: str, default: List[str] = None) -> List[str]: ... # type: ignore
|
||||
def popitem(self) -> Tuple[str, str]: ...
|
||||
def clear(self) -> None: ...
|
||||
def setdefault(self, key: str, default: Optional[str] = None) -> str: ...
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
# Stubs for django.http.response (Python 3.5)
|
||||
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
from json import JSONEncoder
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, overload, Tuple, Type, Union
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type, Union, overload
|
||||
|
||||
import six
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
@@ -16,21 +14,23 @@ from django.urls import ResolverMatch
|
||||
class BadHeaderError(ValueError): ...
|
||||
|
||||
class HttpResponseBase(six.Iterator):
|
||||
status_code = ... # type: int
|
||||
cookies = ... # type: SimpleCookie
|
||||
closed = ... # type: bool
|
||||
reason_phrase = ... # type: str
|
||||
charset = ... # type: str
|
||||
status_code: int = ...
|
||||
cookies: SimpleCookie = ...
|
||||
closed: bool = ...
|
||||
reason_phrase: str = ...
|
||||
charset: str = ...
|
||||
def __init__(
|
||||
self, content_type: str = None, status: int = None, reason: str = None, charset: str = None
|
||||
self,
|
||||
content_type: Optional[str] = ...,
|
||||
status: Optional[int] = ...,
|
||||
reason: Optional[str] = ...,
|
||||
charset: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def serialize_headers(self) -> bytes: ...
|
||||
def __bytes__(self) -> bytes: ...
|
||||
def __setitem__(self, header: str, value: Union[str, bytes]) -> None: ...
|
||||
def __delitem__(self, header: str) -> None: ...
|
||||
def __getitem__(self, header: str) -> str: ...
|
||||
def has_header(self, header: str) -> bool: ...
|
||||
def __contains__(self, item: object) -> bool: ...
|
||||
def items(self) -> Iterable[Tuple[str, str]]: ...
|
||||
@overload
|
||||
def get(self, header: str, alternate: str) -> str: ...
|
||||
@@ -39,13 +39,14 @@ class HttpResponseBase(six.Iterator):
|
||||
def set_cookie(
|
||||
self,
|
||||
key: str,
|
||||
value: str = "",
|
||||
max_age: int = None,
|
||||
expires: Union[str, datetime.datetime] = None,
|
||||
path: str = "",
|
||||
domain: str = None,
|
||||
secure: bool = False,
|
||||
httponly: bool = False,
|
||||
value: str = ...,
|
||||
max_age: Optional[int] = ...,
|
||||
expires: Optional[Union[str, datetime.datetime]] = ...,
|
||||
path: str = ...,
|
||||
domain: Optional[str] = ...,
|
||||
secure: bool = ...,
|
||||
httponly: bool = ...,
|
||||
samesite: str = ...,
|
||||
) -> None: ...
|
||||
def setdefault(self, key: str, value: str) -> None: ...
|
||||
def set_signed_cookie(self, key: str, value: str, salt: str = "", **kwargs: Any) -> None: ...
|
||||
@@ -145,9 +146,9 @@ class Http404(Exception): ...
|
||||
class JsonResponse(HttpResponse):
|
||||
def __init__(
|
||||
self,
|
||||
data: object,
|
||||
data: Any,
|
||||
encoder: Type[JSONEncoder] = ...,
|
||||
safe: bool = True,
|
||||
json_dumps_params: Dict[str, Any] = None,
|
||||
safe: bool = ...,
|
||||
json_dumps_params: Optional[Dict[str, Any]] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
@@ -25,3 +25,5 @@ class CsrfViewMiddleware(MiddlewareMixin):
|
||||
self, request: HttpRequest, callback: Callable, callback_args: Tuple, callback_kwargs: Dict[str, Any]
|
||||
) -> Optional[HttpResponseForbidden]: ...
|
||||
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
|
||||
|
||||
def _compare_salted_tokens(request_csrf_token: str, csrf_token: str) -> bool: ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from typing import Any, Callable, Dict, List, Optional, Type, Union
|
||||
|
||||
from django.db.models import Manager, QuerySet
|
||||
from django.db.models.base import Model
|
||||
from django.http.response import HttpResponse, HttpResponseRedirect
|
||||
|
||||
@@ -21,6 +22,6 @@ def render(
|
||||
using: Optional[str] = ...,
|
||||
) -> HttpResponse: ...
|
||||
def redirect(to: Union[Callable, str], *args: Any, permanent: bool = ..., **kwargs: Any) -> HttpResponseRedirect: ...
|
||||
def get_object_or_404(klass: Union[Type[Model], str], *args: Any, **kwargs: Any) -> Model: ...
|
||||
def get_list_or_404(klass: List[Type[Model]], *args: Any, **kwargs: Any) -> List[Model]: ...
|
||||
def get_object_or_404(klass: Union[Type[Model], Manager, QuerySet], *args: Any, **kwargs: Any) -> Model: ...
|
||||
def get_list_or_404(klass: Union[Type[Model], Manager, QuerySet], *args: Any, **kwargs: Any) -> List[Model]: ...
|
||||
def resolve_url(to: Union[Callable, Model, str], *args: Any, **kwargs: Any) -> str: ...
|
||||
|
||||
@@ -3,8 +3,18 @@ from .testcases import (
|
||||
TransactionTestCase as TransactionTestCase,
|
||||
SimpleTestCase as SimpleTestCase,
|
||||
LiveServerTestCase as LiveServerTestCase,
|
||||
skipIfDBFeature as skipIfDBFeature,
|
||||
skipUnlessDBFeature as skipUnlessDBFeature,
|
||||
skipUnlessAnyDBFeature as skipUnlessAnyDBFeature,
|
||||
)
|
||||
|
||||
from .utils import override_settings as override_settings, modify_settings as modify_settings
|
||||
from .utils import (
|
||||
override_settings as override_settings,
|
||||
modify_settings as modify_settings,
|
||||
override_script_prefix as override_script_prefix,
|
||||
override_system_checks as override_system_checks,
|
||||
ignore_warnings as ignore_warnings,
|
||||
tag as tag,
|
||||
)
|
||||
|
||||
from .client import Client as Client
|
||||
from .client import Client as Client, RequestFactory as RequestFactory
|
||||
|
||||
@@ -36,12 +36,12 @@ class RequestFactory:
|
||||
errors: BytesIO = ...
|
||||
def __init__(self, *, json_encoder: Any = ..., **defaults: Any) -> None: ...
|
||||
def request(self, **request: Any) -> WSGIRequest: ...
|
||||
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponseBase: ...
|
||||
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> WSGIRequest: ...
|
||||
def post(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponseBase: ...
|
||||
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponseBase: ...
|
||||
def trace(self, path: str, secure: bool = ..., **extra: Any) -> HttpResponseBase: ...
|
||||
) -> WSGIRequest: ...
|
||||
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> WSGIRequest: ...
|
||||
def trace(self, path: str, secure: bool = ..., **extra: Any) -> WSGIRequest: ...
|
||||
def options(
|
||||
self,
|
||||
path: str,
|
||||
@@ -49,16 +49,16 @@ class RequestFactory:
|
||||
content_type: str = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
) -> HttpResponseBase: ...
|
||||
) -> WSGIRequest: ...
|
||||
def put(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponseBase: ...
|
||||
) -> WSGIRequest: ...
|
||||
def patch(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponseBase: ...
|
||||
) -> WSGIRequest: ...
|
||||
def delete(
|
||||
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
|
||||
) -> HttpResponseBase: ...
|
||||
) -> WSGIRequest: ...
|
||||
def generic(
|
||||
self,
|
||||
method: str,
|
||||
@@ -67,7 +67,7 @@ class RequestFactory:
|
||||
content_type: Optional[str] = ...,
|
||||
secure: bool = ...,
|
||||
**extra: Any
|
||||
) -> HttpResponseBase: ...
|
||||
) -> WSGIRequest: ...
|
||||
|
||||
class Client(RequestFactory):
|
||||
defaults: Dict[str, str]
|
||||
|
||||
@@ -176,6 +176,7 @@ class CheckCondition:
|
||||
|
||||
def skipIfDBFeature(*features: Any) -> Callable: ...
|
||||
def skipUnlessDBFeature(*features: Any) -> Callable: ...
|
||||
def skipUnlessAnyDBFeature(*features: Any) -> Callable: ...
|
||||
|
||||
class QuietWSGIRequestHandler(WSGIRequestHandler):
|
||||
def log_message(*args: Any) -> None: ...
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import decimal
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
from decimal import Decimal
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Set, Tuple, Type, Union, IO
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.core.checks.registry import CheckRegistry
|
||||
@@ -38,7 +39,7 @@ class TestContextDecorator:
|
||||
def __exit__(self, exc_type: None, exc_value: None, traceback: None) -> None: ...
|
||||
def decorate_class(self, cls: _TestClass) -> _TestClass: ...
|
||||
def decorate_callable(self, func: Callable) -> Callable: ...
|
||||
def __call__(self, decorated: _DecoratedTest) -> _DecoratedTest: ...
|
||||
def __call__(self, decorated: _DecoratedTest) -> Any: ...
|
||||
|
||||
class override_settings(TestContextDecorator):
|
||||
options: Dict[str, Any] = ...
|
||||
@@ -102,3 +103,17 @@ class isolate_apps(TestContextDecorator):
|
||||
installed_apps: Tuple[str] = ...
|
||||
def __init__(self, *installed_apps: Any, **kwargs: Any) -> None: ...
|
||||
old_apps: Apps = ...
|
||||
|
||||
@contextmanager
|
||||
def extend_sys_path(*paths: str) -> Iterator[None]: ...
|
||||
@contextmanager
|
||||
def captured_output(stream_name) -> Iterator[IO[str]]: ...
|
||||
@contextmanager
|
||||
def captured_stdin() -> Iterator[IO[str]]: ...
|
||||
@contextmanager
|
||||
def captured_stdout() -> Iterator[IO[str]]: ...
|
||||
@contextmanager
|
||||
def captured_stderr() -> Iterator[IO[str]]: ...
|
||||
@contextmanager
|
||||
def freeze_time(t: float) -> Iterator[None]: ...
|
||||
def tag(*tags: str): ...
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
from typing import Any, Dict, Iterable, Optional, Tuple, Union
|
||||
|
||||
from django.db.models.sql.where import NothingNode
|
||||
|
||||
class Node:
|
||||
default: str = ...
|
||||
connector: str = ...
|
||||
negated: bool = ...
|
||||
def __init__(self, children: Optional[Node] = ..., connector: Optional[str] = ..., negated: bool = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
children: Optional[Iterable[Union[Node, NothingNode]]] = ...,
|
||||
connector: Optional[str] = ...,
|
||||
negated: bool = ...,
|
||||
) -> None: ...
|
||||
def __deepcopy__(self, memodict: Dict[Any, Any]) -> Node: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
|
||||
@@ -21,6 +21,9 @@ def determine_model_cls_from_string_for_migrations(ctx: MethodContext) -> Type:
|
||||
if app_label is None:
|
||||
return ctx.default_return_type
|
||||
|
||||
if 'model_name' not in ctx.callee_arg_names:
|
||||
return ctx.default_return_type
|
||||
|
||||
model_name_expr = ctx.args[ctx.callee_arg_names.index('model_name')][0]
|
||||
model_name = get_string_value_from_expr(model_name_expr)
|
||||
if model_name is None:
|
||||
|
||||
1
scripts/typecheck-tests-requirements.txt
Normal file
1
scripts/typecheck-tests-requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
gitpython
|
||||
@@ -1,56 +0,0 @@
|
||||
import os
|
||||
if not os.path.exists('./django-sources'):
|
||||
git clone -b stable/2.1.x https://github.com/django/django.git django-sources
|
||||
|
||||
IGNORED_ERROR_PATTERNS = [
|
||||
'Need type annotation for',
|
||||
'already defined on',
|
||||
'Cannot assign to a',
|
||||
'cannot perform relative import',
|
||||
'broken_app',
|
||||
'LazySettings',
|
||||
'Cannot infer type of lambda',
|
||||
'Incompatible types in assignment (expression has type "Callable[',
|
||||
'"Callable[[Any], Any]" has no attribute',
|
||||
'Invalid value for a to= parameter'
|
||||
]
|
||||
TESTS_DIRS = [
|
||||
'absolute_url_overrides',
|
||||
'admin_*',
|
||||
'aggregation*',
|
||||
'annotations'
|
||||
]
|
||||
|
||||
def check_file_in_the_current_directory(directory, fname):
|
||||
cd @(directory)
|
||||
with ${...}.swap(FNAME=fname):
|
||||
for line in $(mypy --config-file ../../../scripts/mypy.ini $FNAME).split('\n'):
|
||||
for pattern in IGNORED_ERROR_PATTERNS:
|
||||
if pattern in line:
|
||||
break
|
||||
else:
|
||||
if line:
|
||||
print(line)
|
||||
cd -
|
||||
|
||||
def parse_ls_output_into_fnames(output):
|
||||
fnames = []
|
||||
for line in output.splitlines()[1:]:
|
||||
fnames.append(line.split()[-1])
|
||||
return fnames
|
||||
|
||||
all_tests_dirs = []
|
||||
for test_dir in TESTS_DIRS:
|
||||
with ${...}.swap(TEST_DIR=test_dir):
|
||||
dirs = g`django-sources/tests/$TEST_DIR`
|
||||
all_tests_dirs.extend(dirs)
|
||||
|
||||
for tests_dir in all_tests_dirs:
|
||||
print('Checking ' + tests_dir)
|
||||
abs_dir = os.path.join(os.getcwd(), tests_dir)
|
||||
|
||||
with ${...}.swap(ABS_DIR=abs_dir):
|
||||
ls_output = $(ls -lhv --color=auto -F --group-directories-first $ABS_DIR)
|
||||
for fname in parse_ls_output_into_fnames(ls_output):
|
||||
path_to_check = os.path.join(abs_dir, fname)
|
||||
check_file_in_the_current_directory(abs_dir, fname)
|
||||
345
scripts/typecheck_tests.py
Normal file
345
scripts/typecheck_tests.py
Normal file
@@ -0,0 +1,345 @@
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Pattern
|
||||
|
||||
from git import Repo
|
||||
from mypy import build
|
||||
from mypy.main import process_options
|
||||
|
||||
# Django branch to typecheck against
|
||||
DJANGO_BRANCH = 'stable/2.1.x'
|
||||
|
||||
# Specific commit in the Django repository to check against
|
||||
DJANGO_COMMIT_SHA = '03219b5f709dcd5b0bfacd963508625557ec1ef0'
|
||||
|
||||
# Some errors occur for the test suite itself, and cannot be addressed via django-stubs. They should be ignored
|
||||
# using this constant.
|
||||
IGNORED_ERROR_PATTERNS = [
|
||||
'Need type annotation for',
|
||||
'already defined on',
|
||||
'Cannot assign to a',
|
||||
'cannot perform relative import',
|
||||
'broken_app',
|
||||
'cache_clear',
|
||||
'call_count',
|
||||
'call_args_list',
|
||||
'call_args',
|
||||
'"password_changed" does not return a value',
|
||||
'"validate_password" does not return a value',
|
||||
'LazySettings',
|
||||
'Cannot infer type of lambda',
|
||||
'"refresh_from_db" of "Model"',
|
||||
'"as_sql" undefined in superclass',
|
||||
'Incompatible types in assignment (expression has type "str", target has type "type")',
|
||||
'Incompatible types in assignment (expression has type "Callable[',
|
||||
'Invalid value for a to= parameter',
|
||||
'Incompatible types in assignment (expression has type "FilteredChildAdmin", variable has type "ChildAdmin")',
|
||||
'Incompatible types in assignment (expression has type "RelatedFieldWidgetWrapper", variable has type "AdminRadioSelect")',
|
||||
'has incompatible type "MockRequest"; expected "WSGIRequest"',
|
||||
'"NullTranslations" has no attribute "_catalog"',
|
||||
'Definition of "as_sql" in base class',
|
||||
'expression has type "property"',
|
||||
'"object" has no attribute "__iter__"',
|
||||
'Too few arguments for "dates" of "QuerySet"',
|
||||
'has no attribute "vendor"',
|
||||
'Argument 1 to "get_list_or_404" has incompatible type "List',
|
||||
'error: "AdminRadioSelect" has no attribute "can_add_related"',
|
||||
'MockCompiler',
|
||||
'SessionTestsMixin',
|
||||
'Argument 1 to "Paginator" has incompatible type "ObjectList"',
|
||||
'"Type[Morsel[Any]]" has no attribute "_reserved"',
|
||||
'Argument 1 to "append" of "list"',
|
||||
'Argument 1 to "bytes"',
|
||||
'"full_clean" of "Model" does not return a value',
|
||||
'"object" not callable',
|
||||
re.compile('Cannot determine type of \'(objects|stuff|specimens|normal_manager)\''),
|
||||
re.compile(r'"Callable\[\[(Any(, )?)+\], Any\]" has no attribute'),
|
||||
re.compile(r'"HttpResponseBase" has no attribute "[A-Za-z_]+"'),
|
||||
re.compile(r'Incompatible types in assignment \(expression has type "Tuple\[\]", '
|
||||
r'variable has type "Tuple\[[A-Za-z, ]+\]"'),
|
||||
re.compile(r'"validate" of "[A-Za-z]+" does not return a value'),
|
||||
re.compile(r'Module has no attribute "[A-Za-z_]+"'),
|
||||
re.compile(r'"[A-Za-z\[\]]+" has no attribute "getvalue"'),
|
||||
# TODO: remove when reassignment will be possible (in 0.670? )
|
||||
re.compile(r'Incompatible types in assignment \(expression has type "(QuerySet|List)\[[A-Za-z, ]+\]", '
|
||||
r'variable has type "(QuerySet|List)\[[A-Za-z, ]+\]"\)'),
|
||||
re.compile(r'"(MockRequest|DummyRequest|DummyUser)" has no attribute "[a-zA-Z_]+"'),
|
||||
# TODO: remove when form <-> model plugin support is added
|
||||
re.compile(r'"Model" has no attribute "[A-Za-z_]+"'),
|
||||
re.compile(r'Argument 1 to "get_object_or_404" has incompatible type "(str|Type\[CustomClass\])"'),
|
||||
re.compile(r'"None" has no attribute "[a-zA-Z_0-9]+"'),
|
||||
]
|
||||
|
||||
# Test folders to typecheck
|
||||
TESTS_DIRS = [
|
||||
'absolute_url_overrides',
|
||||
'admin_autodiscover',
|
||||
'admin_changelist',
|
||||
'admin_checks',
|
||||
'admin_custom_urls',
|
||||
'admin_default_site',
|
||||
'admin_docs',
|
||||
# TODO: 'admin_filters',
|
||||
'admin_inlines',
|
||||
'admin_ordering',
|
||||
'admin_registration',
|
||||
'admin_scripts',
|
||||
# TODO: 'admin_utils',
|
||||
# TODO: 'admin_views',
|
||||
'admin_widgets',
|
||||
'aggregation',
|
||||
'aggregation_regress',
|
||||
'annotations',
|
||||
'app_loading',
|
||||
# TODO: 'apps',
|
||||
# TODO: 'auth_tests'
|
||||
'base',
|
||||
'bash_completion',
|
||||
'basic',
|
||||
'builtin_server',
|
||||
'bulk_create',
|
||||
# TODO: 'cache',
|
||||
# TODO: 'check_framework',
|
||||
'choices',
|
||||
'conditional_processing',
|
||||
# TODO: 'contenttypes_tests',
|
||||
'context_processors',
|
||||
'csrf_tests',
|
||||
'custom_columns',
|
||||
# TODO: 'custom_lookups',
|
||||
# TODO: 'custom_managers',
|
||||
'custom_methods',
|
||||
'custom_migration_operations',
|
||||
'custom_pk',
|
||||
'datatypes',
|
||||
'dates',
|
||||
'datetimes',
|
||||
'db_functions',
|
||||
'db_typecasts',
|
||||
'db_utils',
|
||||
'dbshell',
|
||||
# TODO: 'decorators',
|
||||
'defer',
|
||||
# TODO: 'defer_regress',
|
||||
'delete',
|
||||
'delete_regress',
|
||||
# TODO: 'deprecation',
|
||||
# TODO: 'dispatch',
|
||||
'distinct_on_fields',
|
||||
'empty',
|
||||
# TODO: 'expressions',
|
||||
'expressions_case',
|
||||
# TODO: 'expressions_window',
|
||||
# TODO: 'extra_regress',
|
||||
# TODO: 'field_deconstruction',
|
||||
'field_defaults',
|
||||
'field_subclassing',
|
||||
# TODO: 'file_storage',
|
||||
# TODO: 'file_uploads',
|
||||
# TODO: 'files',
|
||||
'filtered_relation',
|
||||
# TODO: 'fixtures',
|
||||
'fixtures_model_package',
|
||||
# TODO: 'fixtures_regress',
|
||||
# TODO: 'flatpages_tests',
|
||||
'force_insert_update',
|
||||
'foreign_object',
|
||||
# TODO: 'forms_tests',
|
||||
'from_db_value',
|
||||
# TODO: 'generic_inline_admin',
|
||||
# TODO: 'generic_relations',
|
||||
'generic_relations_regress',
|
||||
# TODO: 'generic_views',
|
||||
'get_earliest_or_latest',
|
||||
'get_object_or_404',
|
||||
# TODO: 'get_or_create',
|
||||
# TODO: 'gis_tests',
|
||||
'handlers',
|
||||
# TODO: 'httpwrappers',
|
||||
'humanize_tests',
|
||||
# TODO: 'i18n',
|
||||
'import_error_package',
|
||||
'indexes',
|
||||
'inline_formsets',
|
||||
'inspectdb',
|
||||
'introspection',
|
||||
# TODO: 'invalid_models_tests',
|
||||
'known_related_objects',
|
||||
# TODO: 'logging_tests',
|
||||
# TODO: 'lookup',
|
||||
'm2m_and_m2o',
|
||||
'm2m_intermediary',
|
||||
'm2m_multiple',
|
||||
'm2m_recursive',
|
||||
'm2m_regress',
|
||||
'm2m_signals',
|
||||
'm2m_through',
|
||||
'm2m_through_regress',
|
||||
'm2o_recursive',
|
||||
# TODO: 'mail',
|
||||
'managers_regress',
|
||||
'many_to_many',
|
||||
'many_to_one',
|
||||
'many_to_one_null',
|
||||
'max_lengths',
|
||||
# TODO: 'messages_tests',
|
||||
# TODO: 'middleware',
|
||||
# TODO: 'middleware_exceptions',
|
||||
# SKIPPED (all errors are false positives) 'migrate_signals',
|
||||
'migration_test_data_persistence',
|
||||
# TODO: 'migrations',
|
||||
'migrations2',
|
||||
# TODO: 'model_fields',
|
||||
# TODO: 'model_forms',
|
||||
'model_formsets',
|
||||
'model_formsets_regress',
|
||||
'model_indexes',
|
||||
# TODO: 'model_inheritance',
|
||||
'model_inheritance_regress',
|
||||
# SKIPPED (all errors are false positives) 'model_meta',
|
||||
'model_options',
|
||||
'model_package',
|
||||
'model_regress',
|
||||
# TODO: 'modeladmin',
|
||||
# TODO: 'multiple_database',
|
||||
'mutually_referential',
|
||||
'nested_foreign_keys',
|
||||
'no_models',
|
||||
'null_fk',
|
||||
'null_fk_ordering',
|
||||
'null_queries',
|
||||
'one_to_one',
|
||||
'or_lookups',
|
||||
'order_with_respect_to',
|
||||
'ordering',
|
||||
'pagination',
|
||||
# TODO: 'postgres_tests',
|
||||
# TODO: 'prefetch_related',
|
||||
'project_template',
|
||||
'properties',
|
||||
'proxy_model_inheritance',
|
||||
# TODO: 'proxy_models',
|
||||
# TODO: 'queries',
|
||||
'queryset_pickle',
|
||||
'raw_query',
|
||||
'redirects_tests',
|
||||
# TODO: 'requests',
|
||||
'reserved_names',
|
||||
'resolve_url',
|
||||
# TODO: 'responses',
|
||||
'reverse_lookup',
|
||||
'save_delete_hooks',
|
||||
'schema',
|
||||
# TODO: 'select_for_update',
|
||||
'select_related',
|
||||
'select_related_onetoone',
|
||||
'select_related_regress',
|
||||
# TODO: 'serializers',
|
||||
# TODO: 'servers',
|
||||
'sessions_tests',
|
||||
'settings_tests',
|
||||
'shell',
|
||||
# TODO: 'shortcuts',
|
||||
# TODO: 'signals',
|
||||
'signed_cookies_tests',
|
||||
# TODO: 'signing',
|
||||
# TODO: 'sitemaps_tests',
|
||||
'sites_framework',
|
||||
# TODO: 'sites_tests',
|
||||
# TODO: 'staticfiles_tests',
|
||||
'str',
|
||||
'string_lookup',
|
||||
'swappable_models',
|
||||
# TODO: 'syndication_tests',
|
||||
# TODO: 'template_backends',
|
||||
'template_loader',
|
||||
# TODO: 'template_tests',
|
||||
# TODO: 'test_client',
|
||||
# TODO: 'test_client_regress',
|
||||
'test_exceptions',
|
||||
# TODO: 'test_runner',
|
||||
'test_runner_apps',
|
||||
# TODO: 'test_utils',
|
||||
# TODO: 'timezones',
|
||||
'transaction_hooks',
|
||||
# TODO: 'transactions',
|
||||
'unmanaged_models',
|
||||
# TODO: 'update',
|
||||
'update_only_fields',
|
||||
'urlpatterns',
|
||||
# TODO: 'urlpatterns_reverse',
|
||||
'user_commands',
|
||||
# TODO: 'utils_tests',
|
||||
# TODO: 'validation',
|
||||
'validators',
|
||||
'version',
|
||||
# TODO: 'view_tests',
|
||||
# TODO: 'wsgi',
|
||||
]
|
||||
|
||||
|
||||
@contextmanager
|
||||
def cd(path):
|
||||
"""Context manager to temporarily change working directories"""
|
||||
if not path:
|
||||
return
|
||||
prev_cwd = Path.cwd().as_posix()
|
||||
if isinstance(path, Path):
|
||||
path = path.as_posix()
|
||||
os.chdir(str(path))
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
os.chdir(prev_cwd)
|
||||
|
||||
|
||||
def is_ignored(line: str) -> bool:
|
||||
for pattern in IGNORED_ERROR_PATTERNS:
|
||||
if isinstance(pattern, Pattern):
|
||||
if pattern.search(line):
|
||||
return True
|
||||
else:
|
||||
if pattern in line:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def check_with_mypy(abs_path: Path, config_file_path: Path) -> int:
|
||||
error_happened = False
|
||||
with cd(abs_path):
|
||||
sources, options = process_options(['--config-file', str(config_file_path), str(abs_path)])
|
||||
res = build.build(sources, options)
|
||||
for error_line in res.errors:
|
||||
if not is_ignored(error_line):
|
||||
error_happened = True
|
||||
print(error_line)
|
||||
return int(error_happened)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
project_directory = Path(__file__).parent.parent
|
||||
mypy_config_file = (project_directory / 'scripts' / 'mypy.ini').absolute()
|
||||
repo_directory = project_directory / 'django-sources'
|
||||
tests_root = repo_directory / 'tests'
|
||||
global_rc = 0
|
||||
|
||||
# clone Django repository, if it does not exist
|
||||
if not repo_directory.exists():
|
||||
repo = Repo.clone_from('https://github.com/django/django.git', repo_directory)
|
||||
else:
|
||||
repo = Repo(repo_directory)
|
||||
repo.remotes['origin'].pull(DJANGO_BRANCH)
|
||||
|
||||
repo.git.checkout(DJANGO_COMMIT_SHA)
|
||||
for dirname in TESTS_DIRS:
|
||||
abs_path = (project_directory / tests_root / dirname).absolute()
|
||||
print(f'Checking {abs_path.as_uri()}')
|
||||
|
||||
rc = check_with_mypy(abs_path, mypy_config_file)
|
||||
if rc != 0:
|
||||
global_rc = 1
|
||||
|
||||
sys.exit(rc)
|
||||
Reference in New Issue
Block a user