diff --git a/dev-requirements.txt b/dev-requirements.txt index 5a224c9..7fb4b92 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,5 +1,5 @@ black -pytest-mypy-plugins==1.0.3 +pytest-mypy-plugins==1.1.0 psycopg2 flake8==3.7.8 flake8-pyi==19.3.0 diff --git a/django-stubs/forms/forms.pyi b/django-stubs/forms/forms.pyi index 24cab6e..65451ff 100644 --- a/django-stubs/forms/forms.pyi +++ b/django-stubs/forms/forms.pyi @@ -8,8 +8,7 @@ from django.forms.utils import ErrorDict, ErrorList from django.forms.widgets import Media, MediaDefiningClass from django.utils.safestring import SafeText -class DeclarativeFieldsMetaclass(MediaDefiningClass): - def __new__(mcs, name: str, bases: Sequence[Type[BaseForm]], attrs: Dict[str, Any]) -> Type[BaseForm]: ... +class DeclarativeFieldsMetaclass(MediaDefiningClass): ... class BaseForm: class Meta: diff --git a/django-stubs/forms/models.pyi b/django-stubs/forms/models.pyi index b186b4d..3ee18c0 100644 --- a/django-stubs/forms/models.pyi +++ b/django-stubs/forms/models.pyi @@ -54,8 +54,7 @@ class ModelFormOptions: field_classes: Optional[Dict[str, Type[Field]]] = ... def __init__(self, options: Optional[type] = ...) -> None: ... -class ModelFormMetaclass(DeclarativeFieldsMetaclass): - def __new__(mcs, name: str, bases: Sequence[Type[Any]], attrs: Dict[str, Any]) -> Type[ModelForm]: ... +class ModelFormMetaclass(DeclarativeFieldsMetaclass): ... class BaseModelForm(BaseForm): instance: Any = ... @@ -73,7 +72,6 @@ class BaseModelForm(BaseForm): use_required_attribute: Optional[bool] = ..., renderer: Any = ..., ) -> None: ... - def clean(self) -> Dict[str, Any]: ... def validate_unique(self) -> None: ... save_m2m: Any = ... def save(self, commit: bool = ...) -> Any: ... diff --git a/django-stubs/forms/widgets.pyi b/django-stubs/forms/widgets.pyi index cf606b5..0aeafe7 100644 --- a/django-stubs/forms/widgets.pyi +++ b/django-stubs/forms/widgets.pyi @@ -27,8 +27,7 @@ class Media: def merge(list_1: Iterable[Any], list_2: Iterable[Any]) -> Iterable[Any]: ... def __add__(self, other: Media) -> Media: ... -class MediaDefiningClass(type): - def __new__(mcs, name: str, bases: Sequence[Any], attrs: Dict[str, Any]) -> type: ... +class MediaDefiningClass(type): ... class Widget: needs_multipart_form: bool = ... @@ -70,9 +69,7 @@ class HiddenInput(Input): choices: Iterable[Tuple[str, str]] class MultipleHiddenInput(HiddenInput): ... - -class FileInput(Input): - needs_multipart_form: bool = ... +class FileInput(Input): ... class ClearableFileInput(FileInput): clear_checkbox_label: Any = ... @@ -102,7 +99,7 @@ class ChoiceWidget(Widget): allow_multiple_selected: bool = ... input_type: Optional[str] = ... template_name: Optional[str] = ... - option_template_name: Any = ... + option_template_name: str = ... add_id_index: bool = ... checked_attribute: Any = ... option_inherits_attrs: bool = ... @@ -130,10 +127,8 @@ class SelectMultiple(Select): class RadioSelect(ChoiceWidget): can_add_related: bool - option_template_name: str = ... -class CheckboxSelectMultiple(ChoiceWidget): - def id_for_label(self, id_: str, index: Optional[str] = ...) -> str: ... +class CheckboxSelectMultiple(ChoiceWidget): ... class MultiWidget(Widget): template_name: str = ... diff --git a/scripts/enabled_test_modules.py b/scripts/enabled_test_modules.py index 24d7d1a..48b6c87 100644 --- a/scripts/enabled_test_modules.py +++ b/scripts/enabled_test_modules.py @@ -69,7 +69,8 @@ IGNORED_ERRORS = { 'SimpleLazyObject' ], 'aggregation': [ - re.compile(r'got "Optional\[(Author|Publisher)\]", expected "Union\[(Author|Publisher), Combinable\]"') + re.compile(r'got "Optional\[(Author|Publisher)\]", expected "Union\[(Author|Publisher), Combinable\]"'), + 'Argument 2 for "super" not an instance of argument 1', ], 'annotations': [ 'Incompatible type for "store" of "Employee" (got "Optional[Store]", expected "Union[Store, Combinable]")' @@ -151,7 +152,8 @@ IGNORED_ERRORS = { ], 'file_uploads': [ '"Iterable[Any]" has no attribute', - '"IO[Any]" has no attribute' + '"IO[Any]" has no attribute', + 'has no attribute "content_type"', ], 'file_storage': [ 'Incompatible types in assignment (expression has type "Callable"' diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index df32598..df3b639 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -76,8 +76,7 @@ if __name__ == '__main__': mypy_options = ['--cache-dir', str(mypy_config_file.parent / '.mypy_cache'), '--config-file', str(mypy_config_file), '--show-traceback', - # '--no-error-summary', - # '--no-pretty', + '--no-error-summary', '--hide-error-context' ] mypy_options += [str(tests_root)] diff --git a/setup.py b/setup.py index 856fca8..259b81d 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ with open('README.md', 'r') as f: readme = f.read() dependencies = [ - 'mypy>=0.720,<0.730', + 'mypy>=0.730,<0.740', 'typing-extensions', 'django', ] diff --git a/test-data/typecheck/test_settings.yml b/test-data/typecheck/test_settings.yml index 507c319..ed5debd 100644 --- a/test-data/typecheck/test_settings.yml +++ b/test-data/typecheck/test_settings.yml @@ -5,7 +5,7 @@ # standard settings reveal_type(settings.AUTH_USER_MODEL) # N: Revealed type is 'builtins.str' reveal_type(settings.ROOT_DIR) # N: Revealed type is 'builtins.str' - reveal_type(settings.APPS_DIR) # N: Revealed type is 'pathlib.Path' + reveal_type(settings.APPS_DIR) # N: Revealed type is 'pathlib.Path*' reveal_type(settings.NUMBERS) # N: Revealed type is 'builtins.list[builtins.str*]' reveal_type(settings.DICT) # N: Revealed type is 'builtins.dict[Any, Any]' custom_settings: | @@ -40,7 +40,7 @@ from settings.basic_settings import * main: | from django.conf import settings - reveal_type(settings.MEDIA_ROOT) # N: Revealed type is 'pathlib.Path' + reveal_type(settings.MEDIA_ROOT) # N: Revealed type is 'pathlib.Path*' reveal_type(settings.MEDIA_ROOT / 'part') # N: Revealed type is 'pathlib.Path*' files: - path: settings/__init__.py