Pin to 0.740 and fix CI (#225)

* update django sources

* pin mypy version, update to 0.740

* fix tests typechecking

* fix lint
This commit is contained in:
Maksim Kurnikov
2019-11-12 05:17:36 +03:00
committed by GitHub
parent 6601121db2
commit 287c64d6fb
19 changed files with 160 additions and 108 deletions

View File

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

View File

@@ -27,7 +27,7 @@ class ResultList(list):
def results(cl: ChangeList) -> Iterator[ResultList]: ...
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
def result_list(
cl: ChangeList
cl: ChangeList,
) -> Dict[
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
]: ...

View File

@@ -37,7 +37,7 @@ def get_finders() -> Iterator[BaseFinder]: ...
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
@overload
def get_finder(
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"]
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"],
) -> AppDirectoriesFinder: ...
@overload
def get_finder(import_path: str) -> BaseFinder: ...

View File

@@ -20,7 +20,7 @@ class BaseDatabaseWrapper:
ops: Any = ...
vendor: str = ...
display_name: str = ...
SchemaEditorClass: Any = ...
SchemaEditorClass: Optional[BaseDatabaseSchemaEditor] = ...
client_class: Any = ...
creation_class: Any = ...
features_class: Any = ...

View File

@@ -1,4 +1,4 @@
from datetime import date, datetime, timedelta
from datetime import date, datetime, timedelta, time
from decimal import Decimal
from typing import Any, List, Optional, Sequence, Tuple, Type, Union
@@ -79,7 +79,7 @@ class BaseDatabaseOperations:
def adapt_unknown_value(self, value: Any) -> Any: ...
def adapt_datefield_value(self, value: Optional[date]) -> Optional[str]: ...
def adapt_datetimefield_value(self, value: Optional[datetime]) -> Optional[str]: ...
def adapt_timefield_value(self, value: Optional[datetime]) -> Optional[str]: ...
def adapt_timefield_value(self, value: Optional[Union[datetime, time]]) -> Optional[str]: ...
def adapt_decimalfield_value(
self, value: Optional[Decimal], max_digits: Optional[int] = ..., decimal_places: Optional[int] = ...
) -> Optional[str]: ...

View File

@@ -64,6 +64,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
choices: Optional[_FieldChoices] = ...
db_column: Optional[str]
column: str
default: Any
error_messages: _ErrorMessagesToOverride
def __init__(
self,
@@ -132,7 +133,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
class IntegerField(Field[_ST, _GT]):
_pyi_private_set_type: Union[float, int, str, Combinable]
_pyi_private_get_type: int
_pyi_lookup_exact_type: int
_pyi_lookup_exact_type: Union[str, int]
class PositiveIntegerRelDbTypeMixin:
def rel_db_type(self, connection: Any): ...
@@ -180,7 +181,7 @@ class DecimalField(Field[_ST, _GT]):
class AutoField(Field[_ST, _GT]):
_pyi_private_set_type: Union[Combinable, int, str]
_pyi_private_get_type: int
_pyi_lookup_exact_type: int
_pyi_lookup_exact_type: Union[str, int]
class CharField(Field[_ST, _GT]):
_pyi_private_set_type: Union[str, int, Combinable]
@@ -389,7 +390,8 @@ class FilePathField(Field[_ST, _GT]):
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class BinaryField(Field[_ST, _GT]): ...
class BinaryField(Field[_ST, _GT]):
_pyi_private_get_type: bytes
class DurationField(Field[_ST, _GT]):
_pyi_private_get_type: timedelta

View File

@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Iterable, List, Optional, Tuple, Type, Union, Mapping, TypeVar, Generic, Sequence
from typing import Any, Iterable, List, Optional, Tuple, Type, Union, Mapping, TypeVar, Generic
from django.db.backends.sqlite3.base import DatabaseWrapper
from django.db.models.expressions import Expression, Func
@@ -31,9 +31,7 @@ class Lookup(Generic[_T]):
def process_lhs(
self, compiler: SQLCompiler, connection: DatabaseWrapper, lhs: Optional[Expression] = ...
) -> Tuple[str, List[Union[int, str]]]: ...
def process_rhs(
self, compiler: SQLCompiler, connection: DatabaseWrapper
) -> Tuple[str, Sequence[Union[int, str]]]: ...
def process_rhs(self, compiler: SQLCompiler, connection: DatabaseWrapper) -> Tuple[str, List[Union[int, str]]]: ...
def rhs_is_direct_value(self) -> bool: ...
def relabeled_clone(self: _T, relabels: Mapping[str, str]) -> _T: ...
def get_group_by_cols(self) -> List[Expression]: ...

View File

@@ -10,7 +10,7 @@ class BaseManager(QuerySet[_T]):
auto_created: bool = ...
use_in_migrations: bool = ...
name: str = ...
model: Type[Model] = ...
model: Type[_T] = ...
db: str
def __init__(self) -> None: ...
def deconstruct(self) -> Tuple[bool, str, None, Tuple, Dict[str, int]]: ...

View File

@@ -1,5 +1,5 @@
from collections import namedtuple
from typing import Any, Collection, Dict, Iterator, List, Mapping, Optional, Sequence, Set, Tuple, Type, Union
from typing import Any, Collection, Dict, Iterator, List, Mapping, Optional, Sequence, Set, Tuple, Type
from django.db.models.base import Model
from django.db.models.fields.mixins import FieldCacheMixin
@@ -23,12 +23,8 @@ class QueryWrapper:
def as_sql(self, compiler: SQLCompiler = ..., connection: Any = ...) -> Any: ...
class Q(tree.Node):
children: Union[List[Dict[str, str]], List[Tuple[str, Any]], List[Q]]
connector: str
negated: bool
AND: str = ...
OR: str = ...
default: Any = ...
conditional: bool = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def __or__(self, other: Any) -> Q: ...
@@ -47,7 +43,6 @@ class Q(tree.Node):
class DeferredAttribute:
field_name: str = ...
def __init__(self, field_name: str) -> None: ...
def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Any: ...
class RegisterLookupMixin:
lookup_name: str

View File

@@ -25,7 +25,7 @@ class SQLCompiler:
def setup_query(self) -> None: ...
has_extra_select: Any = ...
def pre_sql_setup(
self
self,
) -> Tuple[
List[Tuple[Expression, Tuple[str, Union[List[Any], Tuple[str, str]]], None]],
List[Tuple[Expression, Tuple[str, List[Union[int, str]], bool]]],
@@ -40,7 +40,7 @@ class SQLCompiler:
self, expressions: List[Expression], having: Union[List[Expression], Tuple]
) -> List[Expression]: ...
def get_select(
self
self,
) -> Tuple[
List[Tuple[Expression, Tuple[str, List[Union[int, str]]], Optional[str]]],
Optional[Dict[str, Any]],

View File

@@ -63,7 +63,7 @@ class HttpRequest(BytesIO):
self, key: str, default: Any = ..., salt: str = ..., max_age: Optional[int] = ...
) -> Optional[str]: ...
def get_raw_uri(self) -> str: ...
def build_absolute_uri(self, location: str = ...) -> str: ...
def build_absolute_uri(self, location: Optional[str] = ...) -> str: ...
@property
def scheme(self) -> Optional[str]: ...
def is_secure(self) -> bool: ...

View File

@@ -63,7 +63,7 @@ class HttpResponseBase(Iterable[Any]):
class HttpResponse(HttpResponseBase):
client: Client
context: Optional[Context]
context: Context
csrf_cookie_set: bool
redirect_chain: List[Tuple[str, int]]
request: Dict[str, Any]

View File

@@ -9,6 +9,8 @@ from django.http.cookie import SimpleCookie
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase
from django.core.handlers.wsgi import WSGIRequest
BOUNDARY: str = ...
MULTIPART_CONTENT: str = ...
CONTENT_TYPE_RE: Pattern = ...
@@ -40,13 +42,13 @@ class RequestFactory:
cookies: SimpleCookie = ...
errors: BytesIO = ...
def __init__(self, *, json_encoder: Any = ..., **defaults: Any) -> None: ...
def request(self, **request: Any) -> HttpRequest: ...
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpRequest: ...
def request(self, **request: Any) -> WSGIRequest: ...
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
) -> HttpRequest: ...
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpRequest: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> HttpRequest: ...
) -> 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,
@@ -54,16 +56,16 @@ class RequestFactory:
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> HttpRequest: ...
) -> WSGIRequest: ...
def put(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpRequest: ...
) -> WSGIRequest: ...
def patch(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpRequest: ...
) -> WSGIRequest: ...
def delete(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpRequest: ...
) -> WSGIRequest: ...
def generic(
self,
method: str,
@@ -72,7 +74,7 @@ class RequestFactory:
content_type: Optional[str] = ...,
secure: bool = ...,
**extra: Any
) -> HttpRequest: ...
) -> WSGIRequest: ...
class Client:
json_encoder: Type[DjangoJSONEncoder] = ...
@@ -82,13 +84,11 @@ class Client:
handler: ClientHandler = ...
exc_info: None = ...
def __init__(self, enforce_csrf_checks: bool = ..., **defaults: Any) -> None: ...
def request(self, **request: Any) -> HttpResponse: ...
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponse: ...
def post(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> HttpResponse: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> HttpResponse: ...
def request(self, **request: Any) -> Any: ...
def get(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> Any: ...
def post(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> Any: ...
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> Any: ...
def trace(self, path: str, secure: bool = ..., **extra: Any) -> Any: ...
def options(
self,
path: str,
@@ -96,16 +96,10 @@ class Client:
content_type: str = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
def put(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def patch(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
def delete(
self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any
) -> HttpResponse: ...
) -> Any: ...
def put(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> Any: ...
def patch(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> Any: ...
def delete(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> Any: ...
def generic(
self,
method: str,
@@ -114,7 +108,7 @@ class Client:
content_type: Optional[str] = ...,
secure: bool = ...,
**extra: Any
) -> HttpResponse: ...
) -> Any: ...
def store_exc_info(self, **kwargs: Any) -> None: ...
@property
def session(self) -> SessionBase: ...

View File

@@ -1,7 +1,7 @@
import threading
import unittest
from datetime import date
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, ClassVar
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import WSGIHandler
@@ -47,7 +47,8 @@ class SimpleTestCase(unittest.TestCase):
client_class: Any = ...
client: Client
allow_database_queries: bool = ...
databases: Set[str] = ...
# TODO: str -> Literal['__all__']
databases: Union[Set[str], str] = ...
def __call__(self, result: Optional[unittest.TestResult] = ...) -> None: ...
def settings(self, **kwargs: Any) -> Any: ...
def modify_settings(self, **kwargs: Any) -> Any: ...
@@ -198,13 +199,12 @@ class LiveServerThread(threading.Thread):
def terminate(self) -> None: ...
class LiveServerTestCase(TransactionTestCase):
live_server_url: ClassVar[str]
host: str = ...
port: int = ...
server_thread_class: Type[Any] = ...
server_thread: Any
static_handler: Any = ...
@classmethod
def live_server_url(cls): ...
class SerializeMixin:
lockfile: Any = ...

View File

@@ -1,16 +1,16 @@
from typing import Any, Dict, Iterable, Optional, Tuple, Union, Sequence
from typing import Any, Dict, Iterable, Optional, Tuple, Union, Sequence, List
from django.db.models.sql.where import NothingNode
_NodeChildren = Iterable[Union["Node", NothingNode, Sequence[Any]]]
class Node:
default: str = ...
children: List[Any]
default: Any = ...
connector: str = ...
negated: bool = ...
def __init__(
self,
children: Optional[Iterable[Union[Node, NothingNode, Sequence[Any]]]] = ...,
connector: Optional[str] = ...,
negated: bool = ...,
self, children: Optional[_NodeChildren] = ..., connector: Optional[str] = ..., negated: bool = ...,
) -> None: ...
def __deepcopy__(self, memodict: Dict[Any, Any]) -> Node: ...
def __len__(self) -> int: ...