Update typecheck_tests to django 2.2 branch, remove unused ignores (#98)

* update typecheck_tests to django 2.2 branch, remove unused ignores

* lint fixes
This commit is contained in:
Maxim Kurnikov
2019-07-01 18:44:34 +03:00
committed by GitHub
parent 4e1c32f6a3
commit a77d5b27d8
14 changed files with 124 additions and 215 deletions

View File

@@ -1,10 +1,10 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Union
from typing import Any, Dict, Optional, Tuple, Union
from uuid import UUID
from django.contrib.admin.sites import AdminSite
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel
from django.forms.models import ModelChoiceIterator
from django.forms.widgets import ChoiceWidget, Media
from django.forms.widgets import Media
from django import forms
@@ -43,7 +43,7 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ...
class RelatedFieldWidgetWrapper(forms.Widget):
template_name: str = ...
choices: ModelChoiceIterator = ...
widget: AutocompleteSelect = ...
widget: forms.Widget = ...
rel: ManyToOneRel = ...
can_add_related: bool = ...
can_change_related: bool = ...
@@ -52,7 +52,7 @@ class RelatedFieldWidgetWrapper(forms.Widget):
admin_site: AdminSite = ...
def __init__(
self,
widget: ChoiceWidget,
widget: forms.Widget,
rel: ForeignObjectRel,
admin_site: AdminSite,
can_add_related: Optional[bool] = ...,

View File

@@ -42,10 +42,14 @@ class BaseCommand:
stderr: OutputWrapper = ...
style: Style = ...
def __init__(
self, stdout: Optional[StringIO] = ..., stderr: Optional[StringIO] = ..., no_color: bool = ...
self,
stdout: Optional[StringIO] = ...,
stderr: Optional[StringIO] = ...,
no_color: bool = ...,
force_color: bool = ...,
) -> None: ...
def get_version(self) -> str: ...
def create_parser(self, prog_name: str, subcommand: str) -> CommandParser: ...
def create_parser(self, prog_name: str, subcommand: str, **kwargs: Any) -> 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: ...

View File

@@ -47,7 +47,7 @@ class MigrationGraph:
def iterative_dfs(self, start: Any, forwards: bool = ...): ...
def root_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ...
def leaf_nodes(self, app: Optional[str] = ...) -> List[Tuple[str, str]]: ...
def ensure_not_cyclic(self, start: Union[Tuple[str, str], Node], get_children: Callable) -> None: ...
def ensure_not_cyclic(self) -> None: ...
def make_state(
self, nodes: Optional[Tuple[str, str]] = ..., at_end: bool = ..., real_apps: List[str] = ...
) -> ProjectState: ...

View File

@@ -8,7 +8,7 @@ MIGRATIONS_MODULE_NAME: str
class MigrationLoader:
connection: Any = ...
disk_migrations: Dict[Tuple[str, str], Migration] = ...
applied_migrations: None = ...
applied_migrations: Set[Tuple[str, str]] = ...
ignore_no_migrations: bool = ...
def __init__(self, connection: Any, load: bool = ..., ignore_no_migrations: bool = ...) -> None: ...
@classmethod

View File

@@ -1,20 +1,20 @@
from typing import Any
from typing import Any, Optional
from django.db.models.fields import Field
from .base import Operation
class FieldOperation(Operation):
model_name: Any = ...
model_name: str = ...
model_name_lower: str
name: Any = ...
def __init__(self, model_name: str, name: str) -> None: ...
name: str = ...
def __init__(self, model_name: str, name: str, field: Optional[Field] = ...) -> None: ...
def name_lower(self) -> str: ...
def is_same_model_operation(self, operation: FieldOperation) -> bool: ...
def is_same_field_operation(self, operation: AddField) -> bool: ...
class AddField(FieldOperation):
field: Any = ...
preserve_default: Any = ...
field: Field = ...
preserve_default: bool = ...
def __init__(self, model_name: str, name: str, field: Field, preserve_default: bool = ...) -> None: ...
class RemoveField(FieldOperation): ...

View File

@@ -21,7 +21,7 @@ class OperationWriter:
class MigrationWriter:
migration: Migration = ...
needs_manual_porting: bool = ...
def __init__(self, migration: Union[type, Migration]) -> None: ...
def __init__(self, migration: Union[type, Migration], include_header: bool = ...) -> None: ...
def as_string(self) -> str: ...
@property
def basedir(self) -> str: ...

View File

@@ -1,21 +1,14 @@
from typing import Any, Optional
from django.db.models.expressions import Func
from django.db.models.query_utils import Q
class Aggregate(Func):
name: Any = ...
filter_template: str = ...
window_compatible: bool = ...
filter: Any = ...
def __init__(self, *args: Any, filter: Optional[Any] = ..., **kwargs: Any) -> None: ...
def __init__(self, *expressions: Any, distinct: bool = ..., filter: Optional[Any] = ..., **extra: Any) -> None: ...
class Avg(Aggregate): ...
class Count(Aggregate):
template: str = ...
def __init__(self, expression: str, distinct: bool = ..., filter: Optional[Q] = ..., **extra: Any) -> None: ...
class Count(Aggregate): ...
class Max(Aggregate): ...
class Min(Aggregate): ...
class StdDev(Aggregate): ...

View File

@@ -10,4 +10,6 @@ def PROTECT(collector, field, sub_objs, using): ...
def SET(value: Any) -> Callable: ...
class ProtectedError(IntegrityError): ...
class Collector: ...
class Collector:
def __init__(self, using: str) -> None: ...

View File

@@ -25,13 +25,15 @@ class Length(Transform): ...
class Lower(Transform): ...
class LPad(BytesToCharFieldConversionMixin, Func):
def __init__(self, expression: str, length: Union[Length, int], fill_text: Value = ..., **extra: Any) -> None: ...
def __init__(
self, expression: str, length: Optional[Union[Length, int]], fill_text: Value = ..., **extra: Any
) -> None: ...
class LTrim(Transform): ...
class Ord(Transform): ...
class Repeat(BytesToCharFieldConversionMixin, Func):
def __init__(self, expression: Union[Value, str], number: Union[Length, int], **extra: Any) -> None: ...
def __init__(self, expression: Union[Value, str], number: Optional[Union[Length, int]], **extra: Any) -> None: ...
class Replace(Func):
def __init__(self, expression: Combinable, text: Value, replacement: Value = ..., **extra: Any) -> None: ...

View File

@@ -1,23 +1,34 @@
from typing import Any, Dict, List, Optional, Tuple, Type, Union
from typing import Any, List, Optional, Sequence, Tuple, Type
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.ddl_references import Statement
from django.db.models.base import Model
from django.db.models.query_utils import Q
class Index:
model: Type[Model]
suffix: str = ...
max_name_length: int = ...
fields: List[str] = ...
fields_orders: List[Tuple[str, str]] = ...
fields: Sequence[str] = ...
fields_orders: Sequence[Tuple[str, str]] = ...
name: str = ...
db_tablespace: Optional[str] = ...
def __init__(self, *, fields: Any = ..., name: Optional[Any] = ..., db_tablespace: Optional[Any] = ...) -> None: ...
opclasses: Sequence[str] = ...
condition: Optional[Q] = ...
def __init__(
self,
*,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
def check_name(self) -> List[str]: ...
def create_sql(
self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor, using: str = ...
) -> Statement: ...
def remove_sql(self, model: Type[Model], schema_editor: BaseDatabaseSchemaEditor) -> str: ...
def deconstruct(self) -> Tuple[str, Tuple, Dict[str, Union[List[str], str]]]: ...
def deconstruct(self) -> Any: ...
def clone(self) -> Index: ...
def set_name_with_model(self, model: Type[Model]) -> None: ...

View File

@@ -79,7 +79,9 @@ class QuerySet(Generic[_T, _Row], Collection[_Row], Sized):
def aggregate(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
def get(self, *args: Any, **kwargs: Any) -> _Row: ...
def create(self, **kwargs: Any) -> _T: ...
def bulk_create(self, objs: Iterable[Model], batch_size: Optional[int] = ...) -> List[_T]: ...
def bulk_create(
self, objs: Iterable[Model], batch_size: Optional[int] = ..., ignore_conflicts: bool = ...
) -> List[_T]: ...
def get_or_create(self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any) -> Tuple[_T, bool]: ...
def update_or_create(
self, defaults: Optional[MutableMapping[str, Any]] = ..., **kwargs: Any

View File

@@ -48,7 +48,7 @@ def last(value: List[str]) -> str: ...
def length(value: Any) -> int: ...
def length_is(value: Optional[Any], arg: Union[SafeText, int]) -> Union[bool, str]: ...
def random(value: List[str]) -> str: ...
def slice_filter(value: Any, arg: str) -> Any: ...
def slice_filter(value: Any, arg: Union[str, int]) -> Any: ...
def unordered_list(value: Any, autoescape: bool = ...) -> Any: ...
def add(value: Any, arg: Any) -> Any: ...
def get_digit(value: Any, arg: int) -> Any: ...

View File

@@ -1,11 +1,8 @@
from typing import Any, Callable, List, Optional, Tuple, Union
from typing import Any, List, Optional, Tuple
from .resolvers import URLPattern, URLResolver
from .resolvers import URLResolver
def include(
arg: Union[List[Tuple[str, Callable]], List[URLPattern], List[URLResolver], Tuple[List[URLResolver], str], str],
namespace: Optional[str] = ...,
) -> Tuple[List[URLResolver], Optional[str], Optional[str]]: ...
def include(arg: Any, namespace: Optional[str] = ...) -> Tuple[List[URLResolver], Optional[str], Optional[str]]: ...
path: Any
re_path: Any