mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 14:01:56 +08:00
move django.core stubs
This commit is contained in:
21
django-stubs/core/cache/__init__.pyi
vendored
Normal file
21
django-stubs/core/cache/__init__.pyi
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, Union
|
||||
|
||||
from django.core.cache.backends.base import BaseCache as BaseCache
|
||||
|
||||
DEFAULT_CACHE_ALIAS: str
|
||||
|
||||
class CacheHandler:
|
||||
def __init__(self) -> None: ...
|
||||
def __getitem__(self, alias: str) -> BaseCache: ...
|
||||
def all(self): ...
|
||||
|
||||
class DefaultCacheProxy:
|
||||
def __getattr__(self, name: str) -> Union[Callable, Dict[str, float], OrderedDict, int]: ...
|
||||
def __setattr__(self, name: str, value: Callable) -> None: ...
|
||||
def __delattr__(self, name: Any): ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def __eq__(self, other: Any): ...
|
||||
|
||||
cache: Any
|
||||
caches: CacheHandler
|
||||
0
django-stubs/core/cache/backends/__init__.pyi
vendored
Normal file
0
django-stubs/core/cache/backends/__init__.pyi
vendored
Normal file
47
django-stubs/core/cache/backends/base.pyi
vendored
Normal file
47
django-stubs/core/cache/backends/base.pyi
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional, Union
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
class InvalidCacheBackendError(ImproperlyConfigured): ...
|
||||
class CacheKeyWarning(RuntimeWarning): ...
|
||||
|
||||
DEFAULT_TIMEOUT: Any
|
||||
MEMCACHE_MAX_KEY_LENGTH: int
|
||||
|
||||
def default_key_func(key: Union[int, str], key_prefix: str, version: Union[int, str]) -> str: ...
|
||||
def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ...
|
||||
|
||||
class BaseCache:
|
||||
default_timeout: int = ...
|
||||
key_prefix: str = ...
|
||||
version: int = ...
|
||||
key_func: Callable = ...
|
||||
def __init__(self, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
|
||||
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
|
||||
def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> str: ...
|
||||
def 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 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: ...
|
||||
def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ...
|
||||
def get_or_set(
|
||||
self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> Optional[Union[int, str]]: ...
|
||||
def has_key(self, key: Any, version: Optional[Any] = ...): ...
|
||||
def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def __contains__(self, key: str) -> bool: ...
|
||||
def set_many(
|
||||
self,
|
||||
data: Union[Dict[str, bytes], Dict[str, int], Dict[str, str], OrderedDict],
|
||||
timeout: Any = ...,
|
||||
version: Optional[Union[int, str]] = ...,
|
||||
) -> List[Any]: ...
|
||||
def delete_many(self, keys: Union[Dict[str, str], List[str]], version: None = ...) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def validate_key(self, key: str) -> None: ...
|
||||
def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def decr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def close(self, **kwargs: Any) -> None: ...
|
||||
39
django-stubs/core/cache/backends/db.pyi
vendored
Normal file
39
django-stubs/core/cache/backends/db.pyi
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class Options:
|
||||
db_table: str = ...
|
||||
app_label: str = ...
|
||||
model_name: str = ...
|
||||
verbose_name: str = ...
|
||||
verbose_name_plural: str = ...
|
||||
object_name: str = ...
|
||||
abstract: bool = ...
|
||||
managed: bool = ...
|
||||
proxy: bool = ...
|
||||
swapped: bool = ...
|
||||
def __init__(self, table: str) -> None: ...
|
||||
|
||||
class BaseDatabaseCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
cache_model_class: Any = ...
|
||||
def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
|
||||
|
||||
class DatabaseCache(BaseDatabaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def get(self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...) -> Any: ...
|
||||
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def add(
|
||||
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> bool: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
|
||||
def clear(self) -> None: ...
|
||||
19
django-stubs/core/cache/backends/dummy.pyi
vendored
Normal file
19
django-stubs/core/cache/backends/dummy.pyi
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import Any, Dict, Optional, Union
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class DummyCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def __init__(self, host: str, *args: Any, **kwargs: Any) -> None: ...
|
||||
def add(self, key: str, value: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def get(self, key: str, default: Optional[str] = ..., version: Optional[int] = ...) -> Optional[str]: ...
|
||||
def set(
|
||||
self, key: str, value: Union[Dict[str, Any], int, str], timeout: Any = ..., version: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: None = ...) -> None: ...
|
||||
def has_key(self, key: str, version: None = ...) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
22
django-stubs/core/cache/backends/filebased.pyi
vendored
Normal file
22
django-stubs/core/cache/backends/filebased.pyi
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class FileBasedCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
cache_suffix: str = ...
|
||||
def __init__(self, dir: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
|
||||
def add(
|
||||
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
|
||||
) -> bool: ...
|
||||
def get(
|
||||
self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...
|
||||
) -> Optional[str]: ...
|
||||
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
26
django-stubs/core/cache/backends/locmem.pyi
vendored
Normal file
26
django-stubs/core/cache/backends/locmem.pyi
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
|
||||
class LocMemCache(BaseCache):
|
||||
default_timeout: int
|
||||
key_func: Callable
|
||||
key_prefix: str
|
||||
version: int
|
||||
def __init__(self, name: str, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
|
||||
def add(
|
||||
self,
|
||||
key: str,
|
||||
value: Union[Dict[str, int], Dict[str, str], bytes, int, str],
|
||||
timeout: Any = ...,
|
||||
version: Optional[int] = ...,
|
||||
) -> Any: ...
|
||||
def get(
|
||||
self, key: Union[int, str], default: Optional[Union[int, str]] = ..., version: Optional[int] = ...
|
||||
) -> Any: ...
|
||||
def set(self, key: Union[int, str], value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
|
||||
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> Any: ...
|
||||
def incr(self, key: Union[int, str], delta: int = ..., version: Optional[int] = ...) -> int: ...
|
||||
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
|
||||
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
5
django-stubs/core/cache/utils.pyi
vendored
Normal file
5
django-stubs/core/cache/utils.pyi
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
from typing import Any, List, Optional, Union
|
||||
|
||||
TEMPLATE_FRAGMENT_KEY_TEMPLATE: str
|
||||
|
||||
def make_template_fragment_key(fragment_name: str, vary_on: Optional[Union[List[int], List[str]]] = ...) -> str: ...
|
||||
0
django-stubs/core/checks/__init__.pyi
Normal file
0
django-stubs/core/checks/__init__.pyi
Normal file
7
django-stubs/core/checks/caches.pyi
Normal file
7
django-stubs/core/checks/caches.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
E001: Any
|
||||
|
||||
def check_default_cache_is_configured(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
3
django-stubs/core/checks/database.pyi
Normal file
3
django-stubs/core/checks/database.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ...
|
||||
45
django-stubs/core/checks/messages.pyi
Normal file
45
django-stubs/core/checks/messages.pyi
Normal file
@@ -0,0 +1,45 @@
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
DEBUG: int
|
||||
INFO: int
|
||||
WARNING: int
|
||||
ERROR: int
|
||||
CRITICAL: int
|
||||
|
||||
class CheckMessage:
|
||||
level: Any = ...
|
||||
msg: Any = ...
|
||||
hint: Any = ...
|
||||
obj: Any = ...
|
||||
id: Any = ...
|
||||
def __init__(
|
||||
self, level: int, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def __eq__(self, other: Union[CheckMessage, str]) -> bool: ...
|
||||
def is_serious(self, level: int = ...) -> bool: ...
|
||||
def is_silenced(self) -> bool: ...
|
||||
|
||||
class Debug(CheckMessage):
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Info(CheckMessage):
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Warning(CheckMessage):
|
||||
hint: str
|
||||
id: str
|
||||
level: int
|
||||
msg: str
|
||||
obj: Any
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Error(CheckMessage):
|
||||
hint: None
|
||||
id: str
|
||||
level: int
|
||||
msg: str
|
||||
obj: Any
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
|
||||
class Critical(CheckMessage):
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
6
django-stubs/core/checks/model_checks.pyi
Normal file
6
django-stubs/core/checks/model_checks.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
def check_all_models(app_configs: None = ..., **kwargs: Any) -> List[Warning]: ...
|
||||
def check_lazy_references(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
35
django-stubs/core/checks/registry.pyi
Normal file
35
django-stubs/core/checks/registry.pyi
Normal file
@@ -0,0 +1,35 @@
|
||||
from typing import Any, Callable, List, Optional, Set, Union
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.core.checks.messages import CheckMessage
|
||||
|
||||
class Tags:
|
||||
admin: str = ...
|
||||
caches: str = ...
|
||||
compatibility: str = ...
|
||||
database: str = ...
|
||||
models: str = ...
|
||||
security: str = ...
|
||||
signals: str = ...
|
||||
templates: str = ...
|
||||
urls: str = ...
|
||||
|
||||
class CheckRegistry:
|
||||
registered_checks: Set[Callable] = ...
|
||||
deployment_checks: Set[Callable] = ...
|
||||
def __init__(self) -> None: ...
|
||||
def register(self, check: Optional[Union[Callable, str]] = ..., *tags: Any, **kwargs: Any) -> Callable: ...
|
||||
def run_checks(
|
||||
self,
|
||||
app_configs: Optional[List[AppConfig]] = ...,
|
||||
tags: Optional[List[str]] = ...,
|
||||
include_deployment_checks: bool = ...,
|
||||
) -> Union[List[CheckMessage], List[int], List[str]]: ...
|
||||
def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ...
|
||||
def tags_available(self, deployment_checks: bool = ...) -> Set[str]: ...
|
||||
def get_checks(self, include_deployment_checks: bool = ...) -> List[Callable]: ...
|
||||
|
||||
registry: Any
|
||||
register: Any
|
||||
run_checks: Any
|
||||
tag_exists: Any
|
||||
0
django-stubs/core/checks/security/__init__.pyi
Normal file
0
django-stubs/core/checks/security/__init__.pyi
Normal file
31
django-stubs/core/checks/security/base.pyi
Normal file
31
django-stubs/core/checks/security/base.pyi
Normal file
@@ -0,0 +1,31 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
SECRET_KEY_MIN_LENGTH: int
|
||||
SECRET_KEY_MIN_UNIQUE_CHARACTERS: int
|
||||
W001: Any
|
||||
W002: Any
|
||||
W004: Any
|
||||
W005: Any
|
||||
W006: Any
|
||||
W007: Any
|
||||
W008: Any
|
||||
W009: Any
|
||||
W018: Any
|
||||
W019: Any
|
||||
W020: Any
|
||||
W021: Any
|
||||
|
||||
def check_security_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xframe_options_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts_include_subdomains(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_sts_preload(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_content_type_nosniff(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xss_filter(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_ssl_redirect(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_secret_key(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_debug(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_xframe_deny(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_allowed_hosts(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
9
django-stubs/core/checks/security/csrf.pyi
Normal file
9
django-stubs/core/checks/security/csrf.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
W003: Any
|
||||
W016: Any
|
||||
|
||||
def check_csrf_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_csrf_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
18
django-stubs/core/checks/security/sessions.pyi
Normal file
18
django-stubs/core/checks/security/sessions.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Warning
|
||||
|
||||
def add_session_cookie_message(message: Any): ...
|
||||
|
||||
W010: Any
|
||||
W011: Any
|
||||
W012: Any
|
||||
|
||||
def add_httponly_message(message: Any): ...
|
||||
|
||||
W013: Any
|
||||
W014: Any
|
||||
W015: Any
|
||||
|
||||
def check_session_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def check_session_cookie_httponly(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
9
django-stubs/core/checks/templates.pyi
Normal file
9
django-stubs/core/checks/templates.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
E001: Any
|
||||
E002: Any
|
||||
|
||||
def check_setting_app_dirs_loaders(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
def check_string_if_invalid_is_string(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
11
django-stubs/core/checks/urls.pyi
Normal file
11
django-stubs/core/checks/urls.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import Any, Callable, List, Optional, Tuple, Union
|
||||
|
||||
from django.core.checks.messages import CheckMessage, Error, Warning
|
||||
from django.urls.resolvers import URLPattern, URLResolver
|
||||
|
||||
def check_url_config(app_configs: None, **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_resolver(resolver: Union[Tuple[str, Callable], URLPattern, URLResolver]) -> List[CheckMessage]: ...
|
||||
def check_url_namespaces_unique(app_configs: None, **kwargs: Any) -> List[Warning]: ...
|
||||
def get_warning_for_invalid_pattern(pattern: Any) -> List[Error]: ...
|
||||
def check_url_settings(app_configs: None, **kwargs: Any) -> List[Error]: ...
|
||||
def E006(name: str) -> Error: ...
|
||||
58
django-stubs/core/exceptions.pyi
Normal file
58
django-stubs/core/exceptions.pyi
Normal file
@@ -0,0 +1,58 @@
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.forms.utils import ErrorDict, ErrorList
|
||||
|
||||
class FieldDoesNotExist(Exception): ...
|
||||
class AppRegistryNotReady(Exception): ...
|
||||
|
||||
class ObjectDoesNotExist(Exception):
|
||||
silent_variable_failure: bool = ...
|
||||
|
||||
class MultipleObjectsReturned(Exception): ...
|
||||
class SuspiciousOperation(Exception): ...
|
||||
class SuspiciousMultipartForm(SuspiciousOperation): ...
|
||||
class SuspiciousFileOperation(SuspiciousOperation): ...
|
||||
class DisallowedHost(SuspiciousOperation): ...
|
||||
class DisallowedRedirect(SuspiciousOperation): ...
|
||||
class TooManyFieldsSent(SuspiciousOperation): ...
|
||||
class RequestDataTooBig(SuspiciousOperation): ...
|
||||
class PermissionDenied(Exception): ...
|
||||
class ViewDoesNotExist(Exception): ...
|
||||
class MiddlewareNotUsed(Exception): ...
|
||||
class ImproperlyConfigured(Exception): ...
|
||||
class FieldError(Exception): ...
|
||||
|
||||
NON_FIELD_ERRORS: str
|
||||
|
||||
class ValidationError(Exception):
|
||||
error_dict: Any = ...
|
||||
error_list: Any = ...
|
||||
message: Any = ...
|
||||
code: Any = ...
|
||||
params: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
message: Union[
|
||||
Dict[str, List[ValidationError]],
|
||||
Dict[str, ErrorList],
|
||||
List[Union[ValidationError, str]],
|
||||
ValidationError,
|
||||
ErrorList,
|
||||
str,
|
||||
],
|
||||
code: Optional[str] = ...,
|
||||
params: Optional[
|
||||
Union[Dict[str, Union[Tuple[str], Type[Model], Model, str]], Dict[str, Union[int, str]]]
|
||||
] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def message_dict(self) -> Dict[str, List[str]]: ...
|
||||
@property
|
||||
def messages(self) -> List[str]: ...
|
||||
def update_error_dict(
|
||||
self, error_dict: Union[Dict[str, List[ValidationError]], ErrorDict]
|
||||
) -> Union[Dict[str, List[ValidationError]], ErrorDict]: ...
|
||||
def __iter__(self) -> Iterator[Union[Tuple[str, List[str]], str]]: ...
|
||||
|
||||
class EmptyResultSet(Exception): ...
|
||||
@@ -1,3 +1,3 @@
|
||||
from django.core.files.base import File
|
||||
from django.core.files.base import File as File
|
||||
|
||||
__all__ = ["File"]
|
||||
|
||||
15
django-stubs/core/files/images.pyi
Normal file
15
django-stubs/core/files/images.pyi
Normal file
@@ -0,0 +1,15 @@
|
||||
from io import BufferedReader, BytesIO
|
||||
from typing import Any, Union
|
||||
|
||||
from django.core.files import File
|
||||
|
||||
class ImageFile(File):
|
||||
file: BufferedReader
|
||||
mode: str
|
||||
name: str
|
||||
@property
|
||||
def width(self) -> int: ...
|
||||
@property
|
||||
def height(self) -> int: ...
|
||||
|
||||
def get_image_dimensions(file_or_path: Union[BufferedReader, BytesIO, ImageFile, str], close: bool = ...) -> Any: ...
|
||||
17
django-stubs/core/files/locks.pyi
Normal file
17
django-stubs/core/files/locks.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
from ctypes import Structure, c_int64, c_ulong, c_void_p
|
||||
from io import BufferedRandom, TextIOWrapper
|
||||
from typing import Union
|
||||
|
||||
LOCK_SH: int
|
||||
LOCK_NB: int
|
||||
LOCK_EX: int
|
||||
ULONG_PTR = c_int64
|
||||
ULONG_PTR = c_ulong
|
||||
PVOID = c_void_p
|
||||
|
||||
class _OFFSET(Structure): ...
|
||||
class _OFFSET_UNION(Union): ...
|
||||
class OVERLAPPED(Structure): ...
|
||||
|
||||
def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ...
|
||||
def unlock(f: Union[BufferedRandom, int]) -> bool: ...
|
||||
3
django-stubs/core/files/move.pyi
Normal file
3
django-stubs/core/files/move.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
def file_move_safe(
|
||||
old_file_name: str, new_file_name: str, chunk_size: int = ..., allow_overwrite: bool = ...
|
||||
) -> None: ...
|
||||
51
django-stubs/core/files/storage.pyi
Normal file
51
django-stubs/core/files/storage.pyi
Normal file
@@ -0,0 +1,51 @@
|
||||
from datetime import datetime
|
||||
from io import StringIO, TextIOWrapper
|
||||
from typing import Any, List, Optional, Tuple, Union
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
class Storage:
|
||||
def open(self, name: str, mode: str = ...) -> File: ...
|
||||
def save(
|
||||
self, name: Optional[str], content: Union[StringIO, TextIOWrapper, File], max_length: Optional[int] = ...
|
||||
) -> str: ...
|
||||
def get_valid_name(self, name: str) -> str: ...
|
||||
def get_available_name(self, name: str, max_length: Optional[int] = ...) -> str: ...
|
||||
def generate_filename(self, filename: str) -> str: ...
|
||||
def path(self, name: str) -> Any: ...
|
||||
def delete(self, name: Any) -> None: ...
|
||||
def exists(self, name: Any) -> None: ...
|
||||
def listdir(self, path: Any) -> None: ...
|
||||
def size(self, name: Any) -> None: ...
|
||||
def url(self, name: Any) -> None: ...
|
||||
def get_accessed_time(self, name: Any) -> None: ...
|
||||
def get_created_time(self, name: Any) -> None: ...
|
||||
def get_modified_time(self, name: Any) -> None: ...
|
||||
|
||||
class FileSystemStorage(Storage):
|
||||
def __init__(
|
||||
self,
|
||||
location: Optional[str] = ...,
|
||||
base_url: Optional[str] = ...,
|
||||
file_permissions_mode: Optional[int] = ...,
|
||||
directory_permissions_mode: Optional[int] = ...,
|
||||
) -> None: ...
|
||||
def base_location(self) -> str: ...
|
||||
def location(self) -> str: ...
|
||||
def base_url(self) -> str: ...
|
||||
def file_permissions_mode(self) -> Optional[int]: ...
|
||||
def directory_permissions_mode(self) -> Optional[int]: ...
|
||||
def delete(self, name: str) -> None: ...
|
||||
def exists(self, name: str) -> bool: ...
|
||||
def listdir(self, path: str) -> Tuple[List[str], List[str]]: ...
|
||||
def path(self, name: str) -> str: ...
|
||||
def size(self, name: str) -> int: ...
|
||||
def url(self, name: Optional[str]) -> str: ...
|
||||
def get_accessed_time(self, name: str) -> datetime: ...
|
||||
def get_created_time(self, name: str) -> datetime: ...
|
||||
def get_modified_time(self, name: str) -> datetime: ...
|
||||
|
||||
class DefaultStorage(LazyObject): ...
|
||||
|
||||
default_storage: Any
|
||||
0
django-stubs/core/handlers/__init__.pyi
Normal file
0
django-stubs/core/handlers/__init__.pyi
Normal file
13
django-stubs/core/handlers/base.pyi
Normal file
13
django-stubs/core/handlers/base.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import Any, Callable
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.response import HttpResponse, HttpResponseBase
|
||||
|
||||
logger: Any
|
||||
|
||||
class BaseHandler:
|
||||
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): ...
|
||||
def get_response(self, request: WSGIRequest) -> HttpResponseBase: ...
|
||||
def process_exception_by_middleware(self, exception: Exception, request: WSGIRequest) -> HttpResponse: ...
|
||||
12
django-stubs/core/handlers/exception.pyi
Normal file
12
django-stubs/core/handlers/exception.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
from typing import Any, Callable
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.response import HttpResponse
|
||||
from django.urls.resolvers import URLResolver
|
||||
|
||||
def convert_exception_to_response(get_response: Callable) -> Callable: ...
|
||||
def response_for_exception(request: WSGIRequest, exc: Exception) -> HttpResponse: ...
|
||||
def get_exception_response(
|
||||
request: WSGIRequest, resolver: URLResolver, status_code: int, exception: Exception, sender: None = ...
|
||||
) -> HttpResponse: ...
|
||||
def handle_uncaught_exception(request: Any, resolver: Any, exc_info: Any): ...
|
||||
52
django-stubs/core/handlers/wsgi.pyi
Normal file
52
django-stubs/core/handlers/wsgi.pyi
Normal file
@@ -0,0 +1,52 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, Callable, Dict, Optional, Union
|
||||
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.contrib.sessions.backends.base import SessionBase
|
||||
from django.http.request import QueryDict
|
||||
from django.http.response import HttpResponse
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
|
||||
from django.core.handlers import base
|
||||
from django.http import HttpRequest
|
||||
|
||||
_Stream = Union[BytesIO, str]
|
||||
|
||||
class LimitedStream:
|
||||
stream: _Stream = ...
|
||||
remaining: int = ...
|
||||
buffer: bytes = ...
|
||||
buf_size: int = ...
|
||||
def __init__(self, stream: _Stream, limit: int, buf_size: int = ...) -> None: ...
|
||||
def read(self, size: Optional[int] = ...) -> bytes: ...
|
||||
def readline(self, size: Optional[int] = ...) -> bytes: ...
|
||||
|
||||
class WSGIRequest(HttpRequest):
|
||||
content_params: Dict[str, str]
|
||||
content_type: str
|
||||
environ: Dict[str, Any] = ...
|
||||
path_info: str = ...
|
||||
path: str = ...
|
||||
user: AbstractUser
|
||||
session: SessionBase
|
||||
|
||||
META: Dict[str, Any] = ...
|
||||
method: str = ...
|
||||
encoding: Any = ...
|
||||
resolver_match: None = ...
|
||||
def __init__(self, environ: Dict[str, Any]) -> None: ...
|
||||
def GET(self) -> QueryDict: ...
|
||||
def COOKIES(self) -> Dict[str, str]: ...
|
||||
@property
|
||||
def FILES(self) -> MultiValueDict: ...
|
||||
POST: Any = ...
|
||||
|
||||
class WSGIHandler(base.BaseHandler):
|
||||
request_class: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def __call__(self, environ: Dict[str, Any], start_response: Callable) -> HttpResponse: ...
|
||||
|
||||
def get_path_info(environ: Dict[str, Any]) -> str: ...
|
||||
def get_script_name(environ: Dict[str, Any]) -> str: ...
|
||||
def get_bytes_from_wsgi(environ: Dict[str, Any], key: str, default: str) -> bytes: ...
|
||||
def get_str_from_wsgi(environ: Dict[str, Any], key: str, default: str) -> str: ...
|
||||
47
django-stubs/core/mail/__init__.pyi
Normal file
47
django-stubs/core/mail/__init__.pyi
Normal file
@@ -0,0 +1,47 @@
|
||||
from typing import Any, List, Optional, Tuple
|
||||
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
from django.core.mail.message import DEFAULT_ATTACHMENT_MIME_TYPE as DEFAULT_ATTACHMENT_MIME_TYPE
|
||||
from django.core.mail.message import BadHeaderError as BadHeaderError
|
||||
from django.core.mail.message import EmailMessage as EmailMessage
|
||||
from django.core.mail.message import EmailMultiAlternatives as EmailMultiAlternatives
|
||||
from django.core.mail.message import SafeMIMEMultipart as SafeMIMEMultipart
|
||||
from django.core.mail.message import SafeMIMEText as SafeMIMEText
|
||||
from django.core.mail.message import forbid_multi_line_headers as forbid_multi_line_headers
|
||||
from django.core.mail.message import make_msgid as make_msgid
|
||||
from django.core.mail.utils import DNS_NAME as DNS_NAME
|
||||
from django.core.mail.utils import CachedDnsName as CachedDnsName
|
||||
|
||||
def get_connection(backend: Optional[str] = ..., fail_silently: bool = ..., **kwds: Any) -> BaseEmailBackend: ...
|
||||
def send_mail(
|
||||
subject: str,
|
||||
message: str,
|
||||
from_email: Optional[str],
|
||||
recipient_list: List[str],
|
||||
fail_silently: bool = ...,
|
||||
auth_user: None = ...,
|
||||
auth_password: None = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> int: ...
|
||||
def send_mass_mail(
|
||||
datatuple: List[Tuple[str, str, str, List[str]]],
|
||||
fail_silently: bool = ...,
|
||||
auth_user: None = ...,
|
||||
auth_password: None = ...,
|
||||
connection: BaseEmailBackend = ...,
|
||||
) -> int: ...
|
||||
def mail_admins(
|
||||
subject: str,
|
||||
message: str,
|
||||
fail_silently: bool = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def mail_managers(
|
||||
subject: str,
|
||||
message: str,
|
||||
fail_silently: bool = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
html_message: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
121
django-stubs/core/mail/message.pyi
Normal file
121
django-stubs/core/mail/message.pyi
Normal file
@@ -0,0 +1,121 @@
|
||||
import email
|
||||
from email.mime.message import MIMEMessage
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from django.core.mail.backends.base import BaseEmailBackend
|
||||
from django.utils.safestring import SafeText
|
||||
|
||||
utf8_charset: Any
|
||||
utf8_charset_qp: Any
|
||||
DEFAULT_ATTACHMENT_MIME_TYPE: str
|
||||
RFC5322_EMAIL_LINE_LENGTH_LIMIT: int
|
||||
|
||||
class BadHeaderError(ValueError): ...
|
||||
|
||||
ADDRESS_HEADERS: Any
|
||||
|
||||
def forbid_multi_line_headers(name: str, val: str, encoding: str) -> Tuple[str, str]: ...
|
||||
def split_addr(addr: str, encoding: str) -> Tuple[str, str]: ...
|
||||
def sanitize_address(addr: Union[Tuple[str, str], str], encoding: str) -> str: ...
|
||||
|
||||
class MIMEMixin:
|
||||
def as_string(self, unixfrom: bool = ..., linesep: str = ...) -> str: ...
|
||||
def as_bytes(self, unixfrom: bool = ..., linesep: str = ...) -> bytes: ...
|
||||
|
||||
class SafeMIMEMessage(MIMEMixin, MIMEMessage):
|
||||
defects: List[Any]
|
||||
epilogue: None
|
||||
policy: email._policybase.Compat32
|
||||
preamble: None
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
|
||||
class SafeMIMEText(MIMEMixin, MIMEText):
|
||||
defects: List[Any]
|
||||
epilogue: None
|
||||
policy: email._policybase.Compat32
|
||||
preamble: None
|
||||
encoding: str = ...
|
||||
def __init__(self, _text: str, _subtype: str = ..., _charset: str = ...) -> None: ...
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
def set_payload(self, payload: str, charset: str = ...) -> None: ...
|
||||
|
||||
class SafeMIMEMultipart(MIMEMixin, MIMEMultipart):
|
||||
defects: List[Any]
|
||||
epilogue: None
|
||||
policy: email._policybase.Compat32
|
||||
preamble: None
|
||||
encoding: str = ...
|
||||
def __init__(
|
||||
self, _subtype: str = ..., boundary: None = ..., _subparts: None = ..., encoding: str = ..., **_params: Any
|
||||
) -> None: ...
|
||||
def __setitem__(self, name: str, val: str) -> None: ...
|
||||
|
||||
class EmailMessage:
|
||||
content_subtype: str = ...
|
||||
mixed_subtype: str = ...
|
||||
encoding: Any = ...
|
||||
to: List[str] = ...
|
||||
cc: List[Any] = ...
|
||||
bcc: List[Any] = ...
|
||||
reply_to: List[Any] = ...
|
||||
from_email: str = ...
|
||||
subject: str = ...
|
||||
body: str = ...
|
||||
attachments: List[Any] = ...
|
||||
extra_headers: Dict[Any, Any] = ...
|
||||
connection: None = ...
|
||||
def __init__(
|
||||
self,
|
||||
subject: str = ...,
|
||||
body: Optional[str] = ...,
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[Union[List[str], Tuple[str, str], str]] = ...,
|
||||
bcc: Optional[Union[List[str], Tuple[str], str]] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
cc: Optional[Union[List[str], Tuple[str, str], str]] = ...,
|
||||
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
|
||||
) -> None: ...
|
||||
def get_connection(self, fail_silently: bool = ...) -> BaseEmailBackend: ...
|
||||
def message(self) -> MIMEMixin: ...
|
||||
def recipients(self) -> List[str]: ...
|
||||
def send(self, fail_silently: bool = ...) -> int: ...
|
||||
def attach(
|
||||
self,
|
||||
filename: Optional[Union[MIMEText, str]] = ...,
|
||||
content: Optional[Union[bytes, EmailMessage, SafeMIMEText, str]] = ...,
|
||||
mimetype: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def attach_file(self, path: str, mimetype: Optional[str] = ...) -> None: ...
|
||||
|
||||
class EmailMultiAlternatives(EmailMessage):
|
||||
attachments: List[Any]
|
||||
bcc: List[Any]
|
||||
body: SafeText
|
||||
cc: List[Any]
|
||||
connection: None
|
||||
extra_headers: Dict[Any, Any]
|
||||
from_email: str
|
||||
reply_to: List[Any]
|
||||
subject: str
|
||||
to: List[str]
|
||||
alternative_subtype: str = ...
|
||||
alternatives: Any = ...
|
||||
def __init__(
|
||||
self,
|
||||
subject: str = ...,
|
||||
body: str = ...,
|
||||
from_email: Optional[str] = ...,
|
||||
to: Optional[List[str]] = ...,
|
||||
bcc: Optional[List[str]] = ...,
|
||||
connection: Optional[BaseEmailBackend] = ...,
|
||||
attachments: None = ...,
|
||||
headers: Optional[Dict[str, str]] = ...,
|
||||
alternatives: Optional[List[Tuple[str, str]]] = ...,
|
||||
cc: None = ...,
|
||||
reply_to: None = ...,
|
||||
) -> None: ...
|
||||
def attach_alternative(self, content: str, mimetype: str) -> None: ...
|
||||
6
django-stubs/core/mail/utils.pyi
Normal file
6
django-stubs/core/mail/utils.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import Any
|
||||
|
||||
class CachedDnsName:
|
||||
def get_fqdn(self) -> str: ...
|
||||
|
||||
DNS_NAME: Any
|
||||
20
django-stubs/core/management/__init__.pyi
Normal file
20
django-stubs/core/management/__init__.pyi
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
def find_commands(management_dir: str) -> List[str]: ...
|
||||
def load_command_class(app_name: str, name: str) -> BaseCommand: ...
|
||||
def get_commands() -> Dict[str, str]: ...
|
||||
def call_command(command_name: Union[Tuple[str], BaseCommand, str], *args: Any, **options: Any) -> Optional[str]: ...
|
||||
|
||||
class ManagementUtility:
|
||||
argv: List[str] = ...
|
||||
prog_name: str = ...
|
||||
settings_exception: None = ...
|
||||
def __init__(self, argv: List[str] = ...) -> None: ...
|
||||
def main_help_text(self, commands_only: bool = ...): ...
|
||||
def fetch_command(self, subcommand: str) -> BaseCommand: ...
|
||||
def autocomplete(self) -> None: ...
|
||||
def execute(self) -> None: ...
|
||||
|
||||
def execute_from_command_line(argv: List[str] = ...) -> None: ...
|
||||
92
django-stubs/core/management/base.pyi
Normal file
92
django-stubs/core/management/base.pyi
Normal file
@@ -0,0 +1,92 @@
|
||||
from argparse import ArgumentParser, HelpFormatter, Namespace
|
||||
from io import StringIO, TextIOBase, TextIOWrapper
|
||||
from typing import Any, Callable, List, Optional, Tuple, Union, Type
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.core.management.color import Style
|
||||
|
||||
class CommandError(Exception): ...
|
||||
class SystemCheckError(CommandError): ...
|
||||
|
||||
class CommandParser(ArgumentParser):
|
||||
add_help: bool
|
||||
allow_abbrev: bool
|
||||
argument_default: None
|
||||
conflict_handler: str
|
||||
description: str
|
||||
epilog: None
|
||||
formatter_class: Type[DjangoHelpFormatter]
|
||||
fromfile_prefix_chars: None
|
||||
prefix_chars: str
|
||||
prog: str
|
||||
usage: None
|
||||
missing_args_message: None = ...
|
||||
called_from_command_line: bool = ...
|
||||
def __init__(self, **kwargs: Any) -> None: ...
|
||||
def parse_args(self, args: List[str] = ..., namespace: None = ...) -> Namespace: ...
|
||||
def error(self, message: str) -> Any: ...
|
||||
|
||||
def handle_default_options(options: Namespace) -> None: ...
|
||||
def no_translations(handle_func: Callable) -> Callable: ...
|
||||
|
||||
class DjangoHelpFormatter(HelpFormatter):
|
||||
show_last: Any = ...
|
||||
def add_usage(self, usage: None, actions: List[Any], *args: Any, **kwargs: Any) -> None: ...
|
||||
def add_arguments(self, actions: List[Any]) -> None: ...
|
||||
|
||||
class OutputWrapper(TextIOBase):
|
||||
@property
|
||||
def style_func(self): ...
|
||||
@style_func.setter
|
||||
def style_func(self, style_func: Any): ...
|
||||
style_func: Any = ...
|
||||
ending: str = ...
|
||||
def __init__(
|
||||
self, out: Union[StringIO, TextIOWrapper], style_func: Optional[Callable] = ..., ending: str = ...
|
||||
) -> None: ...
|
||||
def __getattr__(self, name: str) -> Callable: ...
|
||||
def isatty(self) -> bool: ...
|
||||
def write(self, msg: str, style_func: Optional[Callable] = ..., ending: Optional[str] = ...) -> None: ...
|
||||
|
||||
class BaseCommand:
|
||||
help: str = ...
|
||||
output_transaction: bool = ...
|
||||
requires_migrations_checks: bool = ...
|
||||
requires_system_checks: bool = ...
|
||||
base_stealth_options: Any = ...
|
||||
stealth_options: Any = ...
|
||||
stdout: OutputWrapper = ...
|
||||
stderr: OutputWrapper = ...
|
||||
style: Style = ...
|
||||
def __init__(
|
||||
self, stdout: Optional[StringIO] = ..., stderr: Optional[StringIO] = ..., no_color: bool = ...
|
||||
) -> None: ...
|
||||
def get_version(self) -> str: ...
|
||||
def create_parser(self, prog_name: str, subcommand: str) -> CommandParser: ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def print_help(self, prog_name: str, subcommand: str) -> None: ...
|
||||
def run_from_argv(self, argv: List[str]) -> None: ...
|
||||
def execute(self, *args: Any, **options: Any) -> Optional[Union[Tuple, str]]: ...
|
||||
def check(
|
||||
self,
|
||||
app_configs: Optional[List[AppConfig]] = ...,
|
||||
tags: Optional[List[str]] = ...,
|
||||
display_num_errors: bool = ...,
|
||||
include_deployment_checks: bool = ...,
|
||||
fail_level: int = ...,
|
||||
) -> None: ...
|
||||
def check_migrations(self) -> None: ...
|
||||
def handle(self, *args: Any, **options: Any) -> None: ...
|
||||
|
||||
class AppCommand(BaseCommand):
|
||||
missing_args_message: str = ...
|
||||
def add_arguments(self, parser: Any) -> None: ...
|
||||
def handle(self, *app_labels: Any, **options: Any): ...
|
||||
def handle_app_config(self, app_config: Any, **options: Any) -> None: ...
|
||||
|
||||
class LabelCommand(BaseCommand):
|
||||
label: str = ...
|
||||
missing_args_message: Any = ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
def handle(self, *labels: Any, **options: Any) -> str: ...
|
||||
def handle_label(self, label: Any, **options: Any) -> None: ...
|
||||
7
django-stubs/core/management/color.pyi
Normal file
7
django-stubs/core/management/color.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
def supports_color() -> bool: ...
|
||||
|
||||
class Style: ...
|
||||
|
||||
def make_style(config_string: str = ...) -> Style: ...
|
||||
def no_style(): ...
|
||||
def color_style() -> Style: ...
|
||||
9
django-stubs/core/management/sql.pyi
Normal file
9
django-stubs/core/management/sql.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import Any, List
|
||||
|
||||
from django.core.management.color import Style
|
||||
|
||||
def sql_flush(
|
||||
style: Style, connection: Any, only_django: bool = ..., reset_sequences: bool = ..., allow_cascade: bool = ...
|
||||
) -> List[str]: ...
|
||||
def emit_pre_migrate_signal(verbosity: int, interactive: bool, db: str, **kwargs: Any) -> None: ...
|
||||
def emit_post_migrate_signal(verbosity: int, interactive: bool, db: str, **kwargs: Any) -> None: ...
|
||||
20
django-stubs/core/management/templates.pyi
Normal file
20
django-stubs/core/management/templates.pyi
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
class TemplateCommand(BaseCommand):
|
||||
requires_system_checks: bool = ...
|
||||
url_schemes: Any = ...
|
||||
rewrite_template_suffixes: Any = ...
|
||||
def add_arguments(self, parser: CommandParser) -> None: ...
|
||||
app_or_project: Any = ...
|
||||
paths_to_remove: Any = ...
|
||||
verbosity: Any = ...
|
||||
def handle(self, app_or_project: Any, name: Any, target: Optional[Any] = ..., **options: Any): ...
|
||||
def handle_template(self, template: Any, subdir: Any): ...
|
||||
def validate_name(self, name: Any, app_or_project: Any) -> None: ...
|
||||
def download(self, url: Any): ...
|
||||
def splitext(self, the_path: Any): ...
|
||||
def extract(self, filename: Any): ...
|
||||
def is_url(self, template: Any): ...
|
||||
def make_writeable(self, filename: Any) -> None: ...
|
||||
10
django-stubs/core/management/utils.pyi
Normal file
10
django-stubs/core/management/utils.pyi
Normal file
@@ -0,0 +1,10 @@
|
||||
from typing import List, Optional, Set, Tuple, Type
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
from django.db.models.base import Model
|
||||
|
||||
def popen_wrapper(args: List[str], stdout_encoding: str = ...) -> Tuple[str, str, int]: ...
|
||||
def handle_extensions(extensions: List[str]) -> Set[str]: ...
|
||||
def find_command(cmd: str, path: None = ..., pathext: None = ...) -> Optional[str]: ...
|
||||
def get_random_secret_key(): ...
|
||||
def parse_apps_and_model_labels(labels: List[str]) -> Tuple[Set[Type[Model]], Set[AppConfig]]: ...
|
||||
52
django-stubs/core/paginator.pyi
Normal file
52
django-stubs/core/paginator.pyi
Normal file
@@ -0,0 +1,52 @@
|
||||
import collections.abc
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
class UnorderedObjectListWarning(RuntimeWarning): ...
|
||||
class InvalidPage(Exception): ...
|
||||
class PageNotAnInteger(InvalidPage): ...
|
||||
class EmptyPage(InvalidPage): ...
|
||||
|
||||
class Paginator:
|
||||
object_list: QuerySet = ...
|
||||
per_page: int = ...
|
||||
orphans: int = ...
|
||||
allow_empty_first_page: bool = ...
|
||||
def __init__(
|
||||
self,
|
||||
object_list: Union[List[Dict[str, str]], List[Model], List[int], QuerySet, str],
|
||||
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: ...
|
||||
def page(self, number: Union[int, str]) -> Page: ...
|
||||
def count(self) -> int: ...
|
||||
def num_pages(self) -> int: ...
|
||||
@property
|
||||
def page_range(self) -> range: ...
|
||||
|
||||
QuerySetPaginator = Paginator
|
||||
|
||||
class Page(collections.abc.Sequence):
|
||||
object_list: QuerySet = ...
|
||||
number: int = ...
|
||||
paginator: Paginator = ...
|
||||
def __init__(
|
||||
self,
|
||||
object_list: Union[List[Dict[str, str]], List[Model], List[int], QuerySet, str],
|
||||
number: int,
|
||||
paginator: Paginator,
|
||||
) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __getitem__(self, index: Union[int, str]) -> Union[Model, str]: ...
|
||||
def has_next(self) -> bool: ...
|
||||
def has_previous(self) -> bool: ...
|
||||
def has_other_pages(self) -> bool: ...
|
||||
def next_page_number(self) -> int: ...
|
||||
def previous_page_number(self) -> int: ...
|
||||
def start_index(self) -> int: ...
|
||||
def end_index(self) -> int: ...
|
||||
30
django-stubs/core/serializers/__init__.pyi
Normal file
30
django-stubs/core/serializers/__init__.pyi
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
from django.core.serializers.xml_serializer import Deserializer
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
BUILTIN_SERIALIZERS: Any
|
||||
|
||||
class BadSerializer:
|
||||
internal_use_only: bool = ...
|
||||
exception: ModuleNotFoundError = ...
|
||||
def __init__(self, exception: ImportError) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
|
||||
def register_serializer(format: str, serializer_module: str, serializers: Optional[Dict[str, Any]] = ...) -> None: ...
|
||||
def unregister_serializer(format: str) -> None: ...
|
||||
def get_serializer(format: str) -> Union[Type[Serializer], BadSerializer]: ...
|
||||
def get_serializer_formats() -> List[str]: ...
|
||||
def get_public_serializer_formats() -> List[str]: ...
|
||||
def get_deserializer(format: str) -> Union[Callable, Type[Deserializer]]: ...
|
||||
def serialize(
|
||||
format: str, queryset: Union[Iterator[Any], List[Model], QuerySet], **options: Any
|
||||
) -> Optional[Union[List[OrderedDict], bytes, str]]: ...
|
||||
def deserialize(format: str, stream_or_string: Any, **options: Any) -> Union[Iterator[Any], Deserializer]: ...
|
||||
def sort_dependencies(
|
||||
app_list: Union[List[Tuple[AppConfig, None]], List[Tuple[str, List[Type[Model]]]]]
|
||||
) -> List[Type[Model]]: ...
|
||||
84
django-stubs/core/serializers/base.pyi
Normal file
84
django-stubs/core/serializers/base.pyi
Normal file
@@ -0,0 +1,84 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date
|
||||
from io import BufferedReader, StringIO, TextIOWrapper
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.management.base import OutputWrapper
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.related import ForeignKey, ManyToManyField
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
class SerializerDoesNotExist(KeyError): ...
|
||||
class SerializationError(Exception): ...
|
||||
|
||||
class DeserializationError(Exception):
|
||||
@classmethod
|
||||
def WithData(
|
||||
cls, original_exc: Exception, model: str, fk: Union[int, str], field_value: Optional[Union[List[str], str]]
|
||||
) -> DeserializationError: ...
|
||||
|
||||
class M2MDeserializationError(Exception):
|
||||
original_exc: Exception = ...
|
||||
pk: List[str] = ...
|
||||
def __init__(self, original_exc: Exception, pk: Union[List[str], str]) -> None: ...
|
||||
|
||||
class ProgressBar:
|
||||
progress_width: int = ...
|
||||
output: None = ...
|
||||
total_count: int = ...
|
||||
prev_done: int = ...
|
||||
def __init__(self, output: Optional[Union[StringIO, OutputWrapper]], total_count: int) -> None: ...
|
||||
def update(self, count: int) -> None: ...
|
||||
|
||||
class Serializer:
|
||||
internal_use_only: bool = ...
|
||||
progress_class: Any = ...
|
||||
stream_class: Any = ...
|
||||
options: Any = ...
|
||||
stream: Any = ...
|
||||
selected_fields: Any = ...
|
||||
use_natural_foreign_keys: Any = ...
|
||||
use_natural_primary_keys: Any = ...
|
||||
first: bool = ...
|
||||
def serialize(
|
||||
self,
|
||||
queryset: Union[Iterator[Any], List[Model], QuerySet],
|
||||
*,
|
||||
stream: Optional[Any] = ...,
|
||||
fields: Optional[Any] = ...,
|
||||
use_natural_foreign_keys: bool = ...,
|
||||
use_natural_primary_keys: bool = ...,
|
||||
progress_output: Optional[Any] = ...,
|
||||
object_count: int = ...,
|
||||
**options: Any
|
||||
) -> Optional[Union[List[OrderedDict], bytes, str]]: ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def start_object(self, obj: Any) -> None: ...
|
||||
def end_object(self, obj: Any) -> None: ...
|
||||
def handle_field(self, obj: Any, field: Any) -> None: ...
|
||||
def handle_fk_field(self, obj: Any, field: Any) -> None: ...
|
||||
def handle_m2m_field(self, obj: Any, field: Any) -> None: ...
|
||||
def getvalue(self) -> Optional[Union[bytes, str]]: ...
|
||||
|
||||
class Deserializer:
|
||||
options: Any = ...
|
||||
stream: Any = ...
|
||||
def __init__(self, stream_or_string: Union[BufferedReader, TextIOWrapper, str], **options: Any) -> None: ...
|
||||
def __iter__(self) -> Deserializer: ...
|
||||
def __next__(self) -> None: ...
|
||||
|
||||
class DeserializedObject:
|
||||
object: Model = ...
|
||||
m2m_data: Dict[Any, Any] = ...
|
||||
def __init__(self, obj: Model, m2m_data: Optional[Dict[str, List[int]]] = ...) -> None: ...
|
||||
def save(self, save_m2m: bool = ..., using: Optional[str] = ..., **kwargs: Any) -> None: ...
|
||||
|
||||
def build_instance(Model: Type[Model], data: Dict[str, Optional[Union[date, int, str, UUID]]], db: str) -> Model: ...
|
||||
def deserialize_m2m_values(
|
||||
field: ManyToManyField, field_value: Union[List[List[str]], List[int]], using: str
|
||||
) -> List[int]: ...
|
||||
def deserialize_fk_value(
|
||||
field: ForeignKey, field_value: Optional[Union[List[str], Tuple[str], int, str]], using: str
|
||||
) -> Optional[Union[int, str, UUID]]: ...
|
||||
33
django-stubs/core/serializers/json.pyi
Normal file
33
django-stubs/core/serializers/json.pyi
Normal file
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from io import TextIOWrapper
|
||||
from typing import Any, Optional, Union, Dict, Type
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.serializers.python import Serializer as PythonSerializer
|
||||
from django.db.models.base import Model
|
||||
|
||||
class Serializer(PythonSerializer):
|
||||
json_kwargs: Dict[str, Optional[Type[DjangoJSONEncoder]]]
|
||||
options: Dict[str, None]
|
||||
selected_fields: None
|
||||
stream: TextIOWrapper
|
||||
use_natural_foreign_keys: bool
|
||||
use_natural_primary_keys: bool
|
||||
internal_use_only: bool = ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def end_object(self, obj: Model) -> None: ...
|
||||
def getvalue(self) -> Optional[Union[bytes, str]]: ...
|
||||
|
||||
def Deserializer(stream_or_string: Any, **options: Any) -> None: ...
|
||||
|
||||
class DjangoJSONEncoder(json.JSONEncoder):
|
||||
allow_nan: bool
|
||||
check_circular: bool
|
||||
ensure_ascii: bool
|
||||
indent: None
|
||||
skipkeys: bool
|
||||
sort_keys: bool
|
||||
def default(self, o: Union[datetime, Decimal, UUID]) -> str: ...
|
||||
40
django-stubs/core/serializers/python.pyi
Normal file
40
django-stubs/core/serializers/python.pyi
Normal file
@@ -0,0 +1,40 @@
|
||||
from collections import OrderedDict
|
||||
from io import TextIOWrapper
|
||||
from typing import Any, Dict, Iterator, List, Optional, Union
|
||||
|
||||
from django.core.serializers.base import DeserializedObject
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.related import ForeignKey, ManyToManyField
|
||||
|
||||
from django.core.serializers import base
|
||||
from django.db.models.fields import Field
|
||||
|
||||
class Serializer(base.Serializer):
|
||||
options: Dict[Any, Any]
|
||||
selected_fields: None
|
||||
stream: TextIOWrapper
|
||||
use_natural_foreign_keys: bool
|
||||
use_natural_primary_keys: bool
|
||||
internal_use_only: bool = ...
|
||||
objects: List[Any] = ...
|
||||
def start_serialization(self) -> None: ...
|
||||
def end_serialization(self) -> None: ...
|
||||
def start_object(self, obj: Model) -> None: ...
|
||||
def end_object(self, obj: Model) -> None: ...
|
||||
def get_dump_object(self, obj: Model) -> OrderedDict: ...
|
||||
def handle_field(self, obj: Model, field: Field) -> None: ...
|
||||
def handle_fk_field(self, obj: Model, field: ForeignKey) -> None: ...
|
||||
def handle_m2m_field(self, obj: Model, field: ManyToManyField) -> None: ...
|
||||
def getvalue(self) -> List[OrderedDict]: ...
|
||||
|
||||
def Deserializer(
|
||||
object_list: Union[
|
||||
List[Dict[str, Optional[Union[Dict[str, Optional[str]], str]]]],
|
||||
List[Dict[str, Union[Dict[str, Union[List[int], int, str]], int, str]]],
|
||||
List[OrderedDict],
|
||||
],
|
||||
*,
|
||||
using: Any = ...,
|
||||
ignorenonexistent: bool = ...,
|
||||
**options: Any
|
||||
) -> Iterator[DeserializedObject]: ...
|
||||
0
django-stubs/core/servers/__init__.pyi
Normal file
0
django-stubs/core/servers/__init__.pyi
Normal file
37
django-stubs/core/servers/basehttp.pyi
Normal file
37
django-stubs/core/servers/basehttp.pyi
Normal file
@@ -0,0 +1,37 @@
|
||||
import socketserver
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict
|
||||
from wsgiref import simple_server
|
||||
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
|
||||
class WSGIServer(simple_server.WSGIServer):
|
||||
request_queue_size: int = ...
|
||||
address_family: Any = ...
|
||||
allow_reuse_address: Any = ...
|
||||
def __init__(self, *args: Any, ipv6: bool = ..., allow_reuse_address: bool = ..., **kwargs: Any) -> None: ...
|
||||
def handle_error(self, request: Any, client_address: Any) -> None: ...
|
||||
|
||||
class ThreadedWSGIServer(socketserver.ThreadingMixIn, WSGIServer): ...
|
||||
|
||||
class ServerHandler(simple_server.ServerHandler):
|
||||
http_version: str = ...
|
||||
def handle_error(self) -> None: ...
|
||||
|
||||
class WSGIRequestHandler(simple_server.WSGIRequestHandler):
|
||||
client_address: str
|
||||
close_connection: bool
|
||||
connection: WSGIRequest
|
||||
request: WSGIRequest
|
||||
rfile: BytesIO
|
||||
server: None
|
||||
wfile: socketserver._SocketWriter
|
||||
protocol_version: str = ...
|
||||
def address_string(self) -> str: ...
|
||||
def log_message(self, format: str, *args: Any) -> None: ...
|
||||
def get_environ(self) -> Dict[str, str]: ...
|
||||
raw_requestline: bytes = ...
|
||||
requestline: str = ...
|
||||
request_version: str = ...
|
||||
command: None = ...
|
||||
def handle(self) -> None: ...
|
||||
48
django-stubs/core/signing.pyi
Normal file
48
django-stubs/core/signing.pyi
Normal file
@@ -0,0 +1,48 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Type, Union
|
||||
|
||||
from django.contrib.sessions.serializers import PickleSerializer
|
||||
|
||||
class BadSignature(Exception): ...
|
||||
class SignatureExpired(BadSignature): ...
|
||||
|
||||
def b64_encode(s: bytes) -> bytes: ...
|
||||
def b64_decode(s: bytes) -> bytes: ...
|
||||
def base64_hmac(salt: str, value: Union[bytes, str], key: Union[bytes, str]) -> str: ...
|
||||
def get_cookie_signer(salt: str = ...) -> TimestampSigner: ...
|
||||
|
||||
class JSONSerializer:
|
||||
def dumps(self, obj: Union[Dict[str, Union[int, str]], List[str], str]) -> bytes: ...
|
||||
def loads(self, data: bytes) -> Dict[str, Union[int, str]]: ...
|
||||
|
||||
def dumps(
|
||||
obj: Union[Dict[str, Union[datetime, str]], List[str], str],
|
||||
key: None = ...,
|
||||
salt: str = ...,
|
||||
serializer: Type[Union[PickleSerializer, JSONSerializer]] = ...,
|
||||
compress: bool = ...,
|
||||
) -> str: ...
|
||||
def loads(
|
||||
s: str,
|
||||
key: None = ...,
|
||||
salt: str = ...,
|
||||
serializer: Type[Union[PickleSerializer, JSONSerializer]] = ...,
|
||||
max_age: Optional[int] = ...,
|
||||
) -> Union[Dict[str, Union[datetime, str]], Dict[str, Union[int, str]], List[str], str]: ...
|
||||
|
||||
class Signer:
|
||||
key: str = ...
|
||||
sep: str = ...
|
||||
salt: Any = ...
|
||||
def __init__(self, key: Optional[Union[bytes, str]] = ..., sep: str = ..., salt: Optional[str] = ...) -> None: ...
|
||||
def signature(self, value: Union[bytes, str]) -> str: ...
|
||||
def sign(self, value: str) -> str: ...
|
||||
def unsign(self, signed_value: str) -> str: ...
|
||||
|
||||
class TimestampSigner(Signer):
|
||||
key: str
|
||||
salt: str
|
||||
sep: str
|
||||
def timestamp(self) -> str: ...
|
||||
def sign(self, value: str) -> str: ...
|
||||
def unsign(self, value: str, max_age: Optional[int] = ...) -> str: ...
|
||||
144
django-stubs/core/validators.pyi
Normal file
144
django-stubs/core/validators.pyi
Normal file
@@ -0,0 +1,144 @@
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from re import RegexFlag
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from uuid import UUID
|
||||
|
||||
from django.core.files.base import File
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
EMPTY_VALUES: Any
|
||||
|
||||
class RegexValidator:
|
||||
regex: SimpleLazyObject = ...
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
inverse_match: bool = ...
|
||||
flags: int = ...
|
||||
def __init__(
|
||||
self,
|
||||
regex: Optional[str] = ...,
|
||||
message: Optional[str] = ...,
|
||||
code: Optional[str] = ...,
|
||||
inverse_match: Optional[bool] = ...,
|
||||
flags: Optional[RegexFlag] = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, value: Optional[Union[float, str]]) -> None: ...
|
||||
def __eq__(self, other: Union[ProhibitNullCharactersValidator, RegexValidator]) -> bool: ...
|
||||
|
||||
class URLValidator(RegexValidator):
|
||||
ul: str = ...
|
||||
ipv4_re: str = ...
|
||||
ipv6_re: str = ...
|
||||
hostname_re: Any = ...
|
||||
domain_re: Any = ...
|
||||
tld_re: Any = ...
|
||||
host_re: Any = ...
|
||||
regex: SimpleLazyObject = ...
|
||||
message: Any = ...
|
||||
schemes: Any = ...
|
||||
def __init__(self, schemes: Optional[List[str]] = ..., **kwargs: Any) -> None: ...
|
||||
def __call__(self, value: str) -> None: ...
|
||||
|
||||
integer_validator: Any
|
||||
|
||||
def validate_integer(value: Optional[Union[float, str]]) -> None: ...
|
||||
|
||||
class EmailValidator:
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
user_regex: Any = ...
|
||||
domain_regex: Any = ...
|
||||
literal_regex: Any = ...
|
||||
domain_whitelist: Any = ...
|
||||
def __init__(
|
||||
self, message: Optional[str] = ..., code: Optional[str] = ..., whitelist: Optional[List[str]] = ...
|
||||
) -> None: ...
|
||||
def __call__(self, value: Optional[str]) -> None: ...
|
||||
def validate_domain_part(self, domain_part: str) -> bool: ...
|
||||
def __eq__(self, other: EmailValidator) -> bool: ...
|
||||
|
||||
validate_email: Any
|
||||
slug_re: Any
|
||||
validate_slug: Any
|
||||
slug_unicode_re: Any
|
||||
validate_unicode_slug: Any
|
||||
|
||||
def validate_ipv4_address(value: str) -> None: ...
|
||||
def validate_ipv6_address(value: str) -> None: ...
|
||||
def validate_ipv46_address(value: str) -> None: ...
|
||||
|
||||
ip_address_validator_map: Any
|
||||
|
||||
def ip_address_validators(protocol: str, unpack_ipv4: bool) -> Any: ...
|
||||
def int_list_validator(
|
||||
sep: str = ..., message: None = ..., code: str = ..., allow_negative: bool = ...
|
||||
) -> RegexValidator: ...
|
||||
|
||||
validate_comma_separated_integer_list: Any
|
||||
|
||||
class BaseValidator:
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
limit_value: bool = ...
|
||||
def __init__(
|
||||
self, limit_value: Optional[Union[datetime, Decimal, float, str]], message: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def __call__(self, value: Union[bytes, datetime, Decimal, float, str]) -> None: ...
|
||||
def __eq__(self, other: BaseValidator) -> bool: ...
|
||||
def compare(self, a: bool, b: bool) -> bool: ...
|
||||
def clean(self, x: Union[datetime, Decimal, float]) -> Union[datetime, Decimal, float]: ...
|
||||
|
||||
class MaxValueValidator(BaseValidator):
|
||||
limit_value: Decimal
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: Union[datetime, Decimal, float], b: Union[datetime, Decimal, float]) -> bool: ...
|
||||
|
||||
class MinValueValidator(BaseValidator):
|
||||
limit_value: int
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: Union[datetime, Decimal, float], b: Union[datetime, Decimal, float]) -> bool: ...
|
||||
|
||||
class MinLengthValidator(BaseValidator):
|
||||
limit_value: int
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: int, b: int) -> bool: ...
|
||||
def clean(self, x: str) -> int: ...
|
||||
|
||||
class MaxLengthValidator(BaseValidator):
|
||||
limit_value: int
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def compare(self, a: int, b: int) -> bool: ...
|
||||
def clean(self, x: Union[bytes, str]) -> int: ...
|
||||
|
||||
class DecimalValidator:
|
||||
messages: Any = ...
|
||||
max_digits: int = ...
|
||||
decimal_places: int = ...
|
||||
def __init__(self, max_digits: Optional[Union[int, str]], decimal_places: Optional[Union[int, str]]) -> None: ...
|
||||
def __call__(self, value: Decimal) -> None: ...
|
||||
def __eq__(self, other: Union[DecimalValidator, MinValueValidator]) -> bool: ...
|
||||
|
||||
class FileExtensionValidator:
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
allowed_extensions: List[str] = ...
|
||||
def __init__(
|
||||
self, allowed_extensions: Optional[List[str]] = ..., message: Optional[str] = ..., code: Optional[str] = ...
|
||||
) -> None: ...
|
||||
def __call__(self, value: File) -> None: ...
|
||||
def __eq__(self, other: FileExtensionValidator) -> bool: ...
|
||||
|
||||
def get_available_image_extensions() -> List[str]: ...
|
||||
def validate_image_file_extension(value: File) -> None: ...
|
||||
|
||||
class ProhibitNullCharactersValidator:
|
||||
message: Any = ...
|
||||
code: str = ...
|
||||
def __init__(self, message: Optional[str] = ..., code: Optional[str] = ...) -> None: ...
|
||||
def __call__(self, value: Optional[Union[Dict[Any, Any], str, UUID]]) -> None: ...
|
||||
def __eq__(self, other: Union[ProhibitNullCharactersValidator, RegexValidator]) -> bool: ...
|
||||
3
django-stubs/core/wsgi.pyi
Normal file
3
django-stubs/core/wsgi.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.core.handlers.wsgi import WSGIHandler
|
||||
|
||||
def get_wsgi_application() -> WSGIHandler: ...
|
||||
@@ -60,7 +60,7 @@ class AlterOrderWithRespectTo(FieldRelatedOptionOperation):
|
||||
class AlterModelOptions(ModelOptionOperation):
|
||||
ALTER_OPTION_KEYS: Any = ...
|
||||
options: Dict[str, str] = ...
|
||||
def __init__(self, name: str, options: Dict[str, str]) -> None: ...
|
||||
def __init__(self, name: str, options: Dict[str, Any]) -> None: ...
|
||||
|
||||
class AlterModelManagers(ModelOptionOperation):
|
||||
serialization_expand_args: Any = ...
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
from typing import Any, Optional, Set, Tuple, Union
|
||||
|
||||
from django.db import DefaultConnectionProxy, models
|
||||
from django.db import models
|
||||
from django.db.backends.base.base import BaseDatabaseWrapper
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from .exceptions import MigrationSchemaMissing
|
||||
|
||||
class MigrationRecorder:
|
||||
class Migration(models.Model):
|
||||
app: Any = ...
|
||||
@@ -15,8 +13,8 @@ class MigrationRecorder:
|
||||
apps: Any = ...
|
||||
app_label: str = ...
|
||||
db_table: str = ...
|
||||
connection: Any = ...
|
||||
def __init__(self, connection: Optional[Union[DefaultConnectionProxy, BaseDatabaseWrapper]]) -> None: ...
|
||||
connection: Optional[BaseDatabaseWrapper] = ...
|
||||
def __init__(self, connection: Optional[BaseDatabaseWrapper]) -> None: ...
|
||||
@property
|
||||
def migration_qs(self) -> QuerySet: ...
|
||||
def has_table(self) -> bool: ...
|
||||
|
||||
@@ -11,6 +11,7 @@ from .fields import (
|
||||
BigIntegerField as BigIntegerField,
|
||||
CharField as CharField,
|
||||
EmailField as EmailField,
|
||||
URLField as URLField,
|
||||
Field as Field,
|
||||
SlugField as SlugField,
|
||||
TextField as TextField,
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Any, Optional
|
||||
from django.db.models.query_utils import RegisterLookupMixin
|
||||
|
||||
class Field(RegisterLookupMixin):
|
||||
def __init__(self, primary_key: bool = False, **kwargs): ...
|
||||
def __init__(self, **kwargs: Any): ...
|
||||
def __get__(self, instance, owner) -> Any: ...
|
||||
|
||||
class IntegerField(Field):
|
||||
@@ -21,12 +21,13 @@ class AutoField(Field):
|
||||
def __get__(self, instance, owner) -> int: ...
|
||||
|
||||
class CharField(Field):
|
||||
def __init__(self, max_length: int, **kwargs): ...
|
||||
def __init__(self, max_length: int, **kwargs: Any): ...
|
||||
def __set__(self, instance, value: str) -> None: ...
|
||||
def __get__(self, instance, owner) -> str: ...
|
||||
|
||||
class SlugField(CharField): ...
|
||||
class EmailField(CharField): ...
|
||||
class URLField(CharField): ...
|
||||
|
||||
class TextField(Field):
|
||||
def __set__(self, instance, value: str) -> None: ...
|
||||
@@ -53,7 +54,6 @@ class GenericIPAddressField(Field):
|
||||
name: Optional[Any] = ...,
|
||||
protocol: str = ...,
|
||||
unpack_ipv4: bool = ...,
|
||||
*args: Any,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
from datetime import date, datetime
|
||||
from typing import TypeVar, Optional, Any, Type, Dict, Union, overload, List, Iterator, Tuple, Callable, Iterable, Sized
|
||||
from typing import TypeVar, Optional, Any, Type, Dict, Union, overload, List, Iterator, Tuple, Iterable, Sized, Sequence
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Manager
|
||||
@@ -31,20 +31,12 @@ class QuerySet(Iterable[_T], Sized):
|
||||
def __and__(self, other: QuerySet) -> QuerySet: ...
|
||||
def __or__(self, other: QuerySet) -> QuerySet: ...
|
||||
def iterator(self, chunk_size: int = ...) -> Iterator[_T]: ...
|
||||
def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Optional[Union[datetime, float]]]: ...
|
||||
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: Union[Iterator[Any], List[models.Model]], batch_size: Optional[int] = ...
|
||||
) -> List[_T]: ...
|
||||
def get_or_create(
|
||||
self, defaults: Optional[Union[Dict[str, date], Dict[str, models.Model]]] = ..., **kwargs: Any
|
||||
) -> Tuple[_T, bool]: ...
|
||||
def update_or_create(
|
||||
self,
|
||||
defaults: Optional[Union[Dict[str, Callable], Dict[str, date], Dict[str, models.Model], Dict[str, str]]] = ...,
|
||||
**kwargs: Any
|
||||
) -> Tuple[_T, bool]: ...
|
||||
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 earliest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
|
||||
def latest(self, *fields: Any, field_name: Optional[Any] = ...) -> _T: ...
|
||||
def first(self) -> Optional[_T]: ...
|
||||
@@ -80,12 +72,12 @@ class QuerySet(Iterable[_T], Sized):
|
||||
def distinct(self, *field_names: Any) -> QuerySet[_T]: ...
|
||||
def extra(
|
||||
self,
|
||||
select: Optional[Union[Dict[str, int], Dict[str, str], OrderedDict]] = ...,
|
||||
select: Optional[Dict[str, Any]] = ...,
|
||||
where: Optional[List[str]] = ...,
|
||||
params: Optional[Union[List[int], List[str]]] = ...,
|
||||
params: Optional[List[Any]] = ...,
|
||||
tables: Optional[List[str]] = ...,
|
||||
order_by: Optional[Union[List[str], Tuple[str]]] = ...,
|
||||
select_params: Optional[Union[List[int], List[str], Tuple[int]]] = ...,
|
||||
order_by: Optional[Sequence[str]] = ...,
|
||||
select_params: Optional[Sequence[Any]] = ...,
|
||||
) -> QuerySet[_T]: ...
|
||||
def reverse(self) -> QuerySet[_T]: ...
|
||||
def defer(self, *fields: Any) -> QuerySet[_T]: ...
|
||||
|
||||
@@ -66,7 +66,6 @@ class HttpResponse(HttpResponseBase):
|
||||
context: Optional[Context]
|
||||
cookies: cookies.SimpleCookie
|
||||
csrf_cookie_set: bool
|
||||
json: Callable[[], Dict]
|
||||
redirect_chain: List[Tuple[str, int]]
|
||||
request: Dict[str, Any]
|
||||
resolver_match: ResolverMatch
|
||||
@@ -92,11 +91,14 @@ class HttpResponse(HttpResponseBase):
|
||||
def writelines(self, lines: List[str]) -> None: ...
|
||||
@property
|
||||
def url(self) -> str: ...
|
||||
def json(self) -> Dict[str, Any]: ...
|
||||
|
||||
class StreamingHttpResponse(HttpResponseBase):
|
||||
def __init__(self, streaming_content: Iterable[bytes] = ..., *args: Any, **kwargs: Any) -> None: ...
|
||||
@property
|
||||
def content(self) -> bytes: ...
|
||||
@content.setter
|
||||
def content(self, value: Any) -> None: ...
|
||||
@property
|
||||
def streaming_content(self) -> Iterator[bytes]: ...
|
||||
@streaming_content.setter
|
||||
@@ -110,7 +112,6 @@ class FileResponse(StreamingHttpResponse):
|
||||
context: None
|
||||
cookies: cookies.SimpleCookie
|
||||
file_to_stream: Optional[BytesIO]
|
||||
json: Callable[[], Dict]
|
||||
request: Dict[str, str]
|
||||
resolver_match: ResolverMatch
|
||||
templates: List[Any]
|
||||
@@ -120,6 +121,7 @@ class FileResponse(StreamingHttpResponse):
|
||||
filename: str = ...
|
||||
def __init__(self, *args: Any, as_attachment: bool = ..., filename: str = ..., **kwargs: Any) -> None: ...
|
||||
def set_headers(self, filelike: BytesIO) -> None: ...
|
||||
def json(self) -> Dict[str, Any]: ...
|
||||
|
||||
class HttpResponseRedirectBase(HttpResponse):
|
||||
allowed_schemes = ... # type: List[str]
|
||||
|
||||
Reference in New Issue
Block a user