From faefdcca5b6ffbf0cf9d4857e83c359d53a8dc3e Mon Sep 17 00:00:00 2001 From: Maxim Kurnikov Date: Mon, 11 Feb 2019 01:12:59 +0300 Subject: [PATCH] fix ci --- django-stubs/contrib/admin/options.pyi | 2 +- django-stubs/db/models/fields/__init__.pyi | 4 +++- django-stubs/test/client.pyi | 2 +- scripts/typecheck_tests.py | 6 +++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/django-stubs/contrib/admin/options.pyi b/django-stubs/contrib/admin/options.pyi index 1f070b3..5b2146c 100644 --- a/django-stubs/contrib/admin/options.pyi +++ b/django-stubs/contrib/admin/options.pyi @@ -81,7 +81,7 @@ class BaseModelAdmin: def get_sortable_by(self, request: WSGIRequest) -> Union[List[Callable], List[str], Tuple]: ... def lookup_allowed(self, lookup: str, value: str) -> bool: ... def to_field_allowed(self, request: WSGIRequest, to_field: str) -> bool: ... - def has_add_permission(self, request: WSGIRequest) -> bool: ... + def has_add_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ... def has_change_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ... def has_delete_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ... def has_view_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ... diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index b358e79..4305953 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -3,6 +3,8 @@ from datetime import date, time, datetime, timedelta from typing import Any, Optional, Tuple, Iterable, Callable, Dict, Union, Type, TypeVar import decimal +from typing_extensions import Literal + from django.db.models import Model from django.db.models.query_utils import RegisterLookupMixin @@ -62,7 +64,7 @@ class Field(RegisterLookupMixin): def to_python(self, value: Any) -> Any: ... class IntegerField(Field): - def __set__(self, instance, value: Union[int, Combinable]) -> None: ... + def __set__(self, instance, value: Union[int, Combinable, Literal['']]) -> None: ... def __get__(self, instance, owner) -> int: ... class PositiveIntegerRelDbTypeMixin: diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 481d944..1b4b1b3 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -124,4 +124,4 @@ class Client: def force_login(self, user: User, backend: Optional[str] = ...) -> None: ... def logout(self) -> None: ... -def conditional_content_removal(request: HttpRequest, response: HttpResponse) -> HttpResponse: ... +def conditional_content_removal(request: HttpRequest, response: HttpResponseBase) -> HttpResponse: ... diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index c82b360..3d8a773 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -181,6 +181,9 @@ IGNORED_ERRORS = { ], 'modeladmin': [ 'BandAdmin', + 'base class "ModelAdmin" defined the type a', + 'base class "InlineModelAdmin" defined the type a', + 'List item 0 has incompatible type "Type[ValidationTestInline]"; expected "Type[BaseModelAdmin]"' ], 'migrate_signals': [ 'Value of type "None" is not indexable', @@ -237,6 +240,7 @@ IGNORED_ERRORS = { ], 'test_client': [ 'Incompatible types in assignment (expression has type "StreamingHttpResponse", variable has type "HttpResponse")', + 'Incompatible types in assignment (expression has type "HttpResponse", variable has type "StreamingHttpResponse")' ], 'test_client_regress': [ 'Incompatible types in assignment (expression has type "Dict[, ]", variable has type "SessionBase")' @@ -541,7 +545,7 @@ def is_ignored(line: str, test_folder_name: str) -> bool: def replace_with_clickable_location(error: str, abs_test_folder: Path) -> str: raw_path, _, error_line = error.partition(': ') - fname, _,line_number = raw_path.partition(':') + fname, _, line_number = raw_path.partition(':') try: path = abs_test_folder.joinpath(fname).relative_to(PROJECT_DIRECTORY)