improved version

This commit is contained in:
Maxim Kurnikov
2018-07-29 20:06:41 +03:00
parent c180555415
commit 89bb6eac75
160 changed files with 1007 additions and 607 deletions

View File

@@ -19,5 +19,5 @@ class CacheHandler:
class DefaultCacheProxy:
def __contains__(self, key: str) -> bool: ...
def __getattr__(self, name: str) -> Union[OrderedDict, Callable, Dict[str, float]]: ...
def __getattr__(self, name: str) -> Union[OrderedDict, Dict[str, float], Callable]: ...
def __setattr__(self, name: str, value: Callable) -> None: ...

View File

@@ -27,7 +27,7 @@ class BaseCache:
def get_or_set(
self,
key: str,
default: Optional[Union[str, Callable, int]],
default: Optional[Union[str, int, Callable]],
timeout: object = ...,
version: Optional[int] = ...
) -> Optional[Union[str, int]]: ...
@@ -36,7 +36,7 @@ class BaseCache:
def make_key(self, key: Union[str, int], version: Optional[Union[str, int]] = ...) -> str: ...
def set_many(
self,
data: Union[Dict[str, str], Dict[str, Union[Dict[str, int], str]], Dict[str, int], OrderedDict],
data: Union[Dict[str, Union[Dict[str, int], str]], OrderedDict, Dict[str, str], Dict[str, int]],
timeout: object = ...,
version: Optional[int] = ...
) -> List[Any]: ...

View File

@@ -10,11 +10,11 @@ from typing import (
class BaseDatabaseCache:
def __init__(self, table: str, params: Dict[str, Union[int, Callable, str, Dict[str, int]]]) -> None: ...
def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], str, int]]) -> None: ...
class DatabaseCache:
def _base_set(self, mode: str, key: str, value: Any, timeout: object = ...): ...
def _base_set(self, mode: str, key: str, value: object, timeout: object = ...): ...
def _cull(self, db: str, cursor: CursorWrapper, now: datetime) -> None: ...
def add(
self,

View File

@@ -14,7 +14,7 @@ class DummyCache:
def set(
self,
key: str,
value: Union[str, int, Dict[str, Any]],
value: Union[str, Dict[str, Any], int],
timeout: object = ...,
version: Optional[str] = ...
) -> None: ...

View File

@@ -13,7 +13,7 @@ from typing import (
)
def _write_content(f: Union[BufferedRandom, BufferedWriter], expiry: float, value: Any) -> None: ...
def _write_content(f: Union[BufferedRandom, BufferedWriter], expiry: float, value: object) -> None: ...
class FileBasedCache:

View File

@@ -14,7 +14,7 @@ class LocMemCache:
def add(
self,
key: str,
value: Union[int, Dict[str, int], str, Dict[str, str]],
value: Union[int, str, Dict[str, str], Dict[str, int]],
timeout: object = ...,
version: Optional[int] = ...
): ...
@@ -31,7 +31,7 @@ class LocMemCache:
def set(
self,
key: Union[str, int],
value: Any,
value: object,
timeout: object = ...,
version: Optional[int] = ...
) -> None: ...

View File

@@ -1,7 +1,4 @@
from typing import (
Any,
Optional,
)
from typing import Optional
class CheckMessage:
@@ -11,7 +8,7 @@ class CheckMessage:
level: int,
msg: str,
hint: Optional[str] = ...,
obj: Any = ...,
obj: object = ...,
id: Optional[str] = ...
) -> None: ...
def __str__(self) -> str: ...

View File

@@ -16,5 +16,5 @@ class CheckRegistry:
app_configs: None = ...,
tags: Optional[List[str]] = ...,
include_deployment_checks: bool = ...
) -> Union[List[str], List[Warning], List[int]]: ...
) -> Union[List[int], List[str], List[Warning]]: ...
def tag_exists(self, tag: str, include_deployment_checks: bool = ...) -> bool: ...

View File

@@ -22,8 +22,8 @@ def _load_all_namespaces(resolver: URLResolver, parents: Tuple = ...) -> List[st
def check_resolver(
resolver: Union[URLResolver, URLPattern]
) -> Union[List[Error], List[Warning]]: ...
resolver: Union[URLPattern, URLResolver]
) -> Union[List[Warning], List[Error]]: ...
def check_url_config(app_configs: None, **kwargs) -> List[Warning]: ...

View File

@@ -1,3 +1,4 @@
from collections.abc import Iterable
from django.forms.utils import ErrorDict
from typing import (
Any,
@@ -11,7 +12,12 @@ from typing import (
class ValidationError:
def __init__(self, message: Any, code: Optional[str] = ..., params: Any = ...) -> None: ...
def __init__(
self,
message: Iterable,
code: Optional[str] = ...,
params: Any = ...
) -> None: ...
def __iter__(self) -> Iterator[Union[str, Tuple[str, List[str]]]]: ...
def __str__(self) -> str: ...
@property

View File

@@ -6,11 +6,12 @@ from typing import (
List,
Optional,
Tuple,
Type,
Union,
)
def get_storage_class(import_path: Optional[str] = ...) -> Any: ...
def get_storage_class(import_path: Optional[str] = ...) -> Type[Storage]: ...
class FileSystemStorage:
@@ -46,7 +47,7 @@ class FileSystemStorage:
def listdir(
self,
path: str
) -> Union[Tuple[List[Any], List[Any]], Tuple[List[Any], List[str]], Tuple[List[str], List[Any]], Tuple[List[str], List[str]]]: ...
) -> Union[Tuple[List[str], List[Any]], Tuple[List[Any], List[Any]], Tuple[List[Any], List[str]], Tuple[List[str], List[str]]]: ...
@cached_property
def location(self) -> str: ...
def path(self, name: str) -> str: ...

View File

@@ -45,7 +45,7 @@ class TemporaryUploadedFile:
class UploadedFile:
def __init__(
self,
file: Optional[Union[_TemporaryFileWrapper, StringIO, BytesIO]] = ...,
file: Optional[Union[StringIO, _TemporaryFileWrapper, BytesIO]] = ...,
name: str = ...,
content_type: str = ...,
size: Optional[int] = ...,

View File

@@ -1,7 +1,18 @@
from django.core.exceptions import (
PermissionDenied,
SuspiciousOperation,
)
from django.core.handlers.wsgi import WSGIRequest
from django.http.response import HttpResponse
from django.http.multipartparser import MultiPartParserError
from django.http.response import (
Http404,
HttpResponse,
)
from django.urls.resolvers import URLResolver
from typing import Callable
from typing import (
Callable,
Union,
)
def convert_exception_to_response(get_response: Callable) -> Callable: ...
@@ -11,7 +22,7 @@ def get_exception_response(
request: WSGIRequest,
resolver: URLResolver,
status_code: int,
exception: Exception,
exception: Union[MultiPartParserError, PermissionDenied, Http404, SuspiciousOperation],
sender: None = ...
) -> HttpResponse: ...

View File

@@ -1,5 +1,4 @@
from django.core.mail.backends.base import BaseEmailBackend
from mail.custombackend import EmailBackend
from typing import (
List,
Optional,
@@ -50,5 +49,5 @@ def send_mass_mail(
fail_silently: bool = ...,
auth_user: None = ...,
auth_password: None = ...,
connection: EmailBackend = ...
connection: BaseEmailBackend = ...
) -> int: ...

View File

@@ -2,7 +2,6 @@ from django.core.mail.backends.base import BaseEmailBackend
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from typing import (
Any,
Dict,
List,
Optional,
@@ -28,7 +27,7 @@ class EmailMessage:
from_email: Optional[str] = ...,
to: Optional[List[str]] = ...,
bcc: None = ...,
connection: Any = ...,
connection: Optional[BaseEmailBackend] = ...,
attachments: Optional[List[MIMEText]] = ...,
headers: Optional[Dict[str, str]] = ...,
cc: Optional[List[str]] = ...,
@@ -37,7 +36,7 @@ class EmailMessage:
def _create_attachment(
self,
filename: Optional[str],
content: Union[str, bytes, SafeMIMEText],
content: Union[bytes, str, SafeMIMEText],
mimetype: str = ...
) -> MIMEBase: ...
def _create_attachments(
@@ -71,7 +70,7 @@ class EmailMultiAlternatives:
from_email: Optional[str] = ...,
to: List[str] = ...,
bcc: None = ...,
connection: Any = ...,
connection: Optional[BaseEmailBackend] = ...,
attachments: None = ...,
headers: Optional[Dict[str, str]] = ...,
alternatives: None = ...,

View File

@@ -19,7 +19,7 @@ class Command:
connection: DatabaseWrapper,
table_name: str,
row: FieldInfo
) -> Union[Tuple[str, OrderedDict, List[str]], Tuple[str, OrderedDict, List[Any]]]: ...
) -> Union[Tuple[str, OrderedDict, List[Any]], Tuple[str, OrderedDict, List[str]]]: ...
def get_meta(
self,
table_name: str,
@@ -34,4 +34,4 @@ class Command:
col_name: str,
used_column_names: List[str],
is_relation: bool
) -> Union[Tuple[str, Dict[str, str], List[str]], Tuple[str, Dict[Any, Any], List[Any]]]: ...
) -> Union[Tuple[str, Dict[Any, Any], List[Any]], Tuple[str, Dict[str, str], List[str]]]: ...

View File

@@ -16,11 +16,11 @@ class Command:
def fixture_dirs(self) -> List[str]: ...
def handle(self, *fixture_labels, **options) -> None: ...
def load_label(self, fixture_label: str) -> None: ...
def loaddata(self, fixture_labels: Union[Tuple[str], Tuple[str, str]]) -> None: ...
def loaddata(self, fixture_labels: Union[Tuple[str, str], Tuple[str]]) -> None: ...
def parse_name(
self,
fixture_name: str
) -> Union[Tuple[str, str, str], Tuple[str, str, None], Tuple[str, None, None]]: ...
) -> Union[Tuple[str, None, None], Tuple[str, str, None], Tuple[str, str, str]]: ...
class SingleZipReader:

View File

@@ -1,8 +1,10 @@
from django.core.management.base import CommandParser
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.migrations.migration import Migration
from typing import (
Any,
List,
Optional,
Set,
)
@@ -10,5 +12,10 @@ from typing import (
class Command:
def _run_checks(self, **kwargs) -> List[Any]: ...
def add_arguments(self, parser: CommandParser) -> None: ...
def migration_progress_callback(self, action: str, migration: Any = ..., fake: bool = ...) -> None: ...
def migration_progress_callback(
self,
action: str,
migration: Optional[Migration] = ...,
fake: bool = ...
) -> None: ...
def sync_apps(self, connection: DatabaseWrapper, app_labels: Set[str]) -> None: ...

View File

@@ -8,10 +8,10 @@ from typing import (
class Page:
def __getitem__(self, index: Union[slice, int]) -> Union[str, List[Model]]: ...
def __getitem__(self, index: Union[slice, int]) -> Union[List[Model], str]: ...
def __init__(
self,
object_list: Union[QuerySet, str, List[object], List[int]],
object_list: Union[List[int], str, List[object], QuerySet],
number: int,
paginator: Paginator
) -> None: ...
@@ -28,7 +28,7 @@ class Page:
class Paginator:
def __init__(
self,
object_list: Union[List[object], QuerySet, List[int]],
object_list: Union[List[int], QuerySet, List[object]],
per_page: Union[str, int],
orphans: Union[str, int] = ...,
allow_empty_first_page: bool = ...
@@ -43,4 +43,4 @@ class Paginator:
def page(self, number: Union[str, int]) -> Page: ...
@property
def page_range(self) -> range: ...
def validate_number(self, number: Optional[Union[str, float, int]]) -> int: ...
def validate_number(self, number: Optional[Union[float, str]]) -> int: ...

View File

@@ -50,7 +50,7 @@ def serialize(
def sort_dependencies(
app_list: Union[List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None], Tuple[AppConfig, None]]], List[Tuple[str, List[Type[Model]]]], List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None]]]]
app_list: Union[List[Tuple[str, List[Type[Model]]]], List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None], Tuple[AppConfig, None]]], List[Union[Tuple[SitesConfig, None], Tuple[SimpleAdminConfig, None]]]]
) -> List[Type[Model]]: ...

View File

@@ -17,12 +17,17 @@ from typing import (
Dict,
List,
Optional,
Type,
Union,
)
from uuid import UUID
def build_instance(Model: Any, data: Dict[str, Any], db: str) -> Model: ...
def build_instance(
Model: Type[Model],
data: Dict[str, Any],
db: str
) -> Model: ...
def deserialize_fk_value(
@@ -34,7 +39,7 @@ def deserialize_fk_value(
def deserialize_m2m_values(
field: ManyToManyField,
field_value: Union[List[List[str]], List[Union[int, str]], List[int]],
field_value: Union[List[List[str]], List[int], List[Union[int, str]]],
using: str
) -> List[int]: ...
@@ -57,7 +62,7 @@ class DeserializedObject:
class Deserializer:
def __init__(self, stream_or_string: Union[str, BufferedReader, TextIOWrapper], **options) -> None: ...
def __init__(self, stream_or_string: Union[str, TextIOWrapper, BufferedReader], **options) -> None: ...
def __iter__(self) -> Deserializer: ...

View File

@@ -16,7 +16,7 @@ def Deserializer(stream_or_string: Any, **options) -> None: ...
class DjangoJSONEncoder:
def default(self, o: Union[Decimal, UUID, date, timedelta]) -> str: ...
def default(self, o: Union[Decimal, date, timedelta, UUID]) -> str: ...
class Serializer:

View File

@@ -1,4 +1,5 @@
from collections import OrderedDict
from datetime import datetime
from django.core.serializers.base import DeserializedObject
from django.db.models.base import Model
from django.db.models.fields import Field
@@ -10,6 +11,9 @@ from typing import (
Any,
Iterator,
List,
Optional,
Type,
Union,
)
@@ -22,11 +26,15 @@ def Deserializer(
) -> Iterator[DeserializedObject]: ...
def _get_model(model_identifier: str) -> Any: ...
def _get_model(model_identifier: str) -> Type[Model]: ...
class Serializer:
def _value_from_field(self, obj: Model, field: Field) -> Any: ...
def _value_from_field(
self,
obj: Model,
field: Field
) -> Optional[Union[str, float, datetime]]: ...
def end_object(self, obj: Model) -> None: ...
def end_serialization(self) -> None: ...
def get_dump_object(self, obj: Model) -> OrderedDict: ...

View File

@@ -10,9 +10,9 @@ from django.db.models.fields.related import (
ManyToManyField,
)
from typing import (
Any,
List,
Optional,
Type,
Union,
)
from xml.dom.minidom import Element
@@ -36,7 +36,7 @@ class Deserializer:
**options
) -> None: ...
def __next__(self) -> DeserializedObject: ...
def _get_model_from_node(self, node: Element, attr: str) -> Any: ...
def _get_model_from_node(self, node: Element, attr: str) -> Type[Model]: ...
def _handle_fk_field_node(
self,
node: Element,

View File

@@ -20,10 +20,10 @@ def base64_hmac(salt: str, value: Union[str, bytes], key: Union[str, bytes]) ->
def dumps(
obj: Union[str, Dict[str, str], Dict[str, Union[str, datetime]], List[str]],
obj: Union[str, List[str], Dict[str, Union[str, datetime]], Dict[str, str]],
key: None = ...,
salt: str = ...,
serializer: Type[Union[JSONSerializer, PickleSerializer]] = ...,
serializer: Type[Union[PickleSerializer, JSONSerializer]] = ...,
compress: bool = ...
) -> str: ...
@@ -35,14 +35,14 @@ def loads(
s: str,
key: None = ...,
salt: str = ...,
serializer: Type[Union[JSONSerializer, PickleSerializer]] = ...,
serializer: Type[Union[PickleSerializer, JSONSerializer]] = ...,
max_age: Optional[int] = ...
) -> Union[str, Dict[str, str], List[str]]: ...
) -> Union[str, List[str], Dict[str, str]]: ...
class JSONSerializer:
def dumps(self, obj: Any) -> bytes: ...
def loads(self, data: bytes) -> Union[Dict[str, str], List[str]]: ...
def loads(self, data: bytes) -> Union[List[str], Dict[str, str]]: ...
class Signer:

View File

@@ -4,7 +4,6 @@ from django.core.files.base import ContentFile
from django.utils.functional import SimpleLazyObject
from re import RegexFlag
from typing import (
Any,
List,
Optional,
Union,
@@ -38,12 +37,16 @@ def validate_ipv6_address(value: str) -> None: ...
class BaseValidator:
def __call__(self, value: Any) -> None: ...
def __init__(self, limit_value: Any, message: None = ...) -> None: ...
def __call__(self, value: Union[Decimal, float, str, datetime]) -> None: ...
def __init__(
self,
limit_value: Optional[Union[Decimal, float, datetime]],
message: None = ...
) -> None: ...
def clean(
self,
x: Union[float, datetime, int, Decimal]
) -> Union[float, datetime, int, Decimal]: ...
x: Union[Decimal, datetime, float]
) -> Union[Decimal, datetime, float]: ...
def compare(self, a: bool, b: bool) -> bool: ...
@@ -82,7 +85,7 @@ class MaxLengthValidator:
class MaxValueValidator:
def compare(self, a: Union[float, Decimal, int], b: Union[float, Decimal, int]) -> bool: ...
def compare(self, a: Union[float, Decimal], b: Union[float, Decimal]) -> bool: ...
class MinLengthValidator:
@@ -93,8 +96,8 @@ class MinLengthValidator:
class MinValueValidator:
def compare(
self,
a: Union[float, Decimal, int, datetime],
b: Union[float, Decimal, int, datetime]
a: Union[float, Decimal, datetime],
b: Union[float, Decimal, datetime]
) -> bool: ...
@@ -102,7 +105,7 @@ class ProhibitNullCharactersValidator:
def __call__(self, value: Optional[str]) -> None: ...
def __eq__(
self,
other: Union[RegexValidator, ProhibitNullCharactersValidator]
other: Union[ProhibitNullCharactersValidator, RegexValidator]
) -> bool: ...
def __init__(self, message: Optional[str] = ..., code: Optional[str] = ...) -> None: ...