From 36c5e8a7154ac7ac17d512f79e00a3562c7ecb33 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Mon, 6 Feb 2023 12:42:05 -0800 Subject: [PATCH 1/4] Upgrade to Mypy 1.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 13bec7e45..5ecafe7e8 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def find_stub_files(name): ] extras_require = { - "compatible-mypy": ["mypy>=0.991,<0.1000"], + "compatible-mypy": ["mypy>=1.0,<1.1"], "coreapi": ["coreapi>=2.0.0"], "markdown": ["types-Markdown>=0.1.5"], } From 257c2babb03f66200ec5713fa4dba84acd9c3912 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Fri, 17 Feb 2023 16:20:47 -0800 Subject: [PATCH 2/4] Fix tests --- scripts/typecheck_tests.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index bf71f3561..74a372db8 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -154,9 +154,9 @@ "test_permissions.py": [ '"ResolverMatch" has incompatible type "str"; expected "Callable[..., Any]"', "_SupportsHasPermission", - "Invalid type alias: expression is not a valid type", - '"object" not callable', 'Cannot assign multiple types to name "composed_perm" without an explicit "Type[...]" annotation', + '"" not callable', + ' not callable', ], "test_relations.py": [ 'Invalid index type "int" for "Union[str, _StrPromise, List[Any], Dict[str, Any]]"; expected type "str"', @@ -188,8 +188,6 @@ "base class", '"CharField" has incompatible type "Collection[Any]"', 'Name "foo" is not defined', - 'Unsupported left operand type for | ("ReturnDict")', - 'Unsupported left operand type for | ("Dict[str, str]")', ], "test_serializer_lists.py": [ 'Name "foo" is not defined', @@ -208,7 +206,6 @@ "test_testing.py": [ '"Client" has no attribute "force_authenticate"', '"Client" has no attribute "credentials"', - 'has no attribute "addClassCleanup"', ], "test_throttling.py": [ 'has incompatible type "Dict[, ]"', @@ -237,6 +234,7 @@ "rest_framework.decorators", 'Argument 1 to "include" has incompatible type "Tuple[List[object], str]"', 'Incompatible types in assignment (expression has type "Type[FakeResolverMatch]", variable has type "Optional[ResolverMatch]"', # noqa: E501 + '"None" not callable' ], "test_viewsets.py": [ '(expression has type "None", variable has type "Request")', From ddb97a784dd3cc9e5d79d7bd2285176edb6c3a04 Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Mon, 20 Feb 2023 14:14:25 -0800 Subject: [PATCH 3/4] Appease pre-commit --- scripts/typecheck_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index 74a372db8..e58adb314 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -156,7 +156,7 @@ "_SupportsHasPermission", 'Cannot assign multiple types to name "composed_perm" without an explicit "Type[...]" annotation', '"" not callable', - ' not callable', + " not callable", ], "test_relations.py": [ 'Invalid index type "int" for "Union[str, _StrPromise, List[Any], Dict[str, Any]]"; expected type "str"', @@ -234,7 +234,7 @@ "rest_framework.decorators", 'Argument 1 to "include" has incompatible type "Tuple[List[object], str]"', 'Incompatible types in assignment (expression has type "Type[FakeResolverMatch]", variable has type "Optional[ResolverMatch]"', # noqa: E501 - '"None" not callable' + '"None" not callable', ], "test_viewsets.py": [ '(expression has type "None", variable has type "Request")', From 0dac7f651176dc08ec2c1863612380889b91992f Mon Sep 17 00:00:00 2001 From: Christian Bundy Date: Mon, 20 Feb 2023 14:16:41 -0800 Subject: [PATCH 4/4] Re-add ignores from other Python versions --- scripts/typecheck_tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index e58adb314..1b215d3ed 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -154,6 +154,8 @@ "test_permissions.py": [ '"ResolverMatch" has incompatible type "str"; expected "Callable[..., Any]"', "_SupportsHasPermission", + "Invalid type alias: expression is not a valid type", + '"object" not callable', 'Cannot assign multiple types to name "composed_perm" without an explicit "Type[...]" annotation', '"" not callable', " not callable", @@ -188,6 +190,8 @@ "base class", '"CharField" has incompatible type "Collection[Any]"', 'Name "foo" is not defined', + 'Unsupported left operand type for | ("ReturnDict")', + 'Unsupported left operand type for | ("Dict[str, str]")', ], "test_serializer_lists.py": [ 'Name "foo" is not defined', @@ -206,6 +210,7 @@ "test_testing.py": [ '"Client" has no attribute "force_authenticate"', '"Client" has no attribute "credentials"', + 'has no attribute "addClassCleanup"', ], "test_throttling.py": [ 'has incompatible type "Dict[, ]"',