From b755f6c58e0d5fc67645721619952d70046450f5 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 15 Nov 2022 12:59:42 +0200 Subject: [PATCH 1/5] Update to mypy 0.991 for compatible-mypy & CI --- mypy.ini | 3 ++- requirements.txt | 2 +- scripts/enabled_test_modules.py | 3 +++ setup.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index ef5b0612f..fa0b71fc6 100644 --- a/mypy.ini +++ b/mypy.ini @@ -7,13 +7,14 @@ ignore_missing_imports = True incremental = True strict_optional = True show_traceback = True -warn_no_return = False warn_unused_ignores = True warn_redundant_casts = True warn_unused_configs = True warn_unreachable = True disallow_untyped_defs = true disallow_incomplete_defs = true +show_error_codes = False +disable_error_code = empty-body plugins = mypy_django_plugin.main diff --git a/requirements.txt b/requirements.txt index 40ff97e6a..615de924a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,4 @@ psycopg2-binary -e .[compatible-mypy] # Overrides: -mypy==0.982 +mypy==0.991 diff --git a/scripts/enabled_test_modules.py b/scripts/enabled_test_modules.py index 6c6b7f24d..787ba68d6 100644 --- a/scripts/enabled_test_modules.py +++ b/scripts/enabled_test_modules.py @@ -113,6 +113,9 @@ 'error: "HttpResponse" has no attribute "streaming_content"', 'error: "HttpResponse" has no attribute "context_data"', 'Duplicate module named "apps"', + "Function is missing a return type annotation", + "Function is missing a type annotation", + "Library stubs not installed for ", ], "admin_checks": ['Argument 1 to "append" of "list" has incompatible type "str"; expected "CheckMessage"'], "admin_default_site": [ diff --git a/setup.py b/setup.py index 6649dac60..15937ed2f 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def find_stub_files(name: str) -> List[str]: ] extras_require = { - "compatible-mypy": ["mypy>=0.980,<0.990"], + "compatible-mypy": ["mypy>=0.991,<0.1000"], } setup( From d37b2809fcf6ae6a8dd93974b6dac63ff9635459 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 15 Nov 2022 13:16:07 +0200 Subject: [PATCH 2/5] Fix "Missing return statement" --- mypy_django_plugin/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mypy_django_plugin/main.py b/mypy_django_plugin/main.py index 86bbd80ec..4ec953997 100644 --- a/mypy_django_plugin/main.py +++ b/mypy_django_plugin/main.py @@ -249,6 +249,8 @@ def get_customize_class_mro_hook(self, fullname: str) -> Optional[Callable[[Clas and sym.node.has_base(fullnames.BASE_MANAGER_CLASS_FULLNAME) ): return reparametrize_any_manager_hook + else: + return None def get_base_class_hook(self, fullname: str) -> Optional[Callable[[ClassDefContext], None]]: # Base class is a Model class definition @@ -309,6 +311,8 @@ def get_type_analyze_hook(self, fullname: str) -> Optional[Callable[[AnalyzeType "django_stubs_ext.annotations.WithAnnotations", ): return partial(handle_annotated_type, django_context=self.django_context) + else: + return None def get_dynamic_class_hook(self, fullname: str) -> Optional[Callable[[DynamicClassDefContext], None]]: # Create a new manager class definition when a manager's '.from_queryset' classmethod is called From d2971a9369dbd96730a3200ff82b41368afa6d9d Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 15 Nov 2022 13:30:17 +0200 Subject: [PATCH 3/5] Fix "invalid syntax" --- scripts/enabled_test_modules.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/enabled_test_modules.py b/scripts/enabled_test_modules.py index 787ba68d6..d29126595 100644 --- a/scripts/enabled_test_modules.py +++ b/scripts/enabled_test_modules.py @@ -515,6 +515,11 @@ "wsgi": [ '"HttpResponse" has no attribute "block_size"', ], + # test_runner_apps/tagged/tests_syntax_error.py + "test_runner_apps": [ + "invalid syntax", + "invalid decimal literal", + ], } From aca1b8cb2c78aa47337cda3ca17c09c64aca82bd Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Thu, 15 Dec 2022 17:30:24 +0200 Subject: [PATCH 4/5] Fix test_options.yml --- tests/typecheck/contrib/admin/test_options.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/typecheck/contrib/admin/test_options.yml b/tests/typecheck/contrib/admin/test_options.yml index 4e9bd7e64..b9c9ac7ed 100644 --- a/tests/typecheck/contrib/admin/test_options.yml +++ b/tests/typecheck/contrib/admin/test_options.yml @@ -107,7 +107,7 @@ from django.contrib import admin class A(admin.ModelAdmin): - fieldsets = [ # type: ignore + fieldsets = [ (None, {}), # E: Missing key "fields" for TypedDict "_FieldOpts" ] - case: errors_on_invalid_radio_fields From 91158911c7036f62bc0d7a9f0fcacb72bd5712f2 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Mon, 23 Jan 2023 13:08:11 +0200 Subject: [PATCH 5/5] Fix mypy 1.0 (again) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 15937ed2f..f685e7d4e 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def find_stub_files(name: str) -> List[str]: ] extras_require = { - "compatible-mypy": ["mypy>=0.991,<0.1000"], + "compatible-mypy": ["mypy>=0.991,<1.0"], } setup(