From 4fe1f9d2a623f825e5008b3d054295fdcfb39e60 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 7 Feb 2023 17:59:30 +0200 Subject: [PATCH 1/3] Upgrade to django-stubs 1.14.0 --- requirements.txt | 2 +- scripts/typecheck_tests.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index fe4a04402..e4d3546a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,6 @@ djangorestframework==3.14.0 types-pytz==2022.7.1.0 types-requests==2.28.11.8 types-urllib3==1.26.25.4 -django-stubs==1.13.0 +django-stubs==1.14.0 django-stubs-ext==0.7.0 -e .[compatible-mypy,coreapi,markdown] diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index 6a6484e9f..78f389127 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -56,6 +56,7 @@ '"_MonkeyPatchedWSGIResponse" has no attribute "content"', '"_MonkeyPatchedWSGIResponse" has no attribute "data"', '" defined here', + '" has no attribute "id"' ], "authentication": [ 'Argument 1 to "post" of "APIClient" has incompatible type "None"; expected "str', @@ -82,7 +83,6 @@ 'Incompatible types in assignment (expression has type "AsView[GenericView]", variable has type "AsView[Callable[[HttpRequest], Any]]")', # noqa: E501 'Argument "patterns" to "SchemaGenerator" has incompatible type "List[object]"', 'Argument 1 to "field_to_schema" has incompatible type "object"; expected "Field[Any, Any, Any, Any]"', - 'Argument "help_text" to "CharField" has incompatible type "_StrPromise"', '"Module rest_framework.schemas.coreapi" does not explicitly export attribute "coreapi"', ], "browsable_api": [ @@ -91,6 +91,7 @@ "models.py": [ '"ForeignKeyTarget" has no attribute "sources"', '"CustomManager" not callable', + 'Incompatible types in assignment (expression has type "Type[BaseManager[Any]]", variable has type "Type[CustomManager]")', # noqa: E501 ], "test_authtoken.py": [ 'Item "None" of "Optional[Token]" has no attribute "key"', @@ -127,7 +128,8 @@ "test_generics.py": [ 'has incompatible type "str"', '"Response" has no attribute "serializer"', - ' Incompatible types in assignment (expression has type "Type[SlugSerializer]", base class "InstanceView" defined the type as "Type[BasicSerializer]")', # noqa: E501 + 'Incompatible types in assignment (expression has type "Type[SlugSerializer]", base class "InstanceView" defined the type as "Type[BasicSerializer]")', # noqa: E501 + 'Incompatible types in assignment (expression has type "_QuerySet[SlugBasedModel, SlugBasedModel]", base class "InstanceView" defined the type as "_QuerySet[BasicModel, BasicModel]")' # noqa: E501 ], "test_htmlrenderer.py": [ 'to "get_template_names" of "TemplateHTMLRenderer" has incompatible type', @@ -138,18 +140,20 @@ "test_model_serializer.py": [ '"Field[Any, Any, Any, Any]" has no attribute', 'base class "Meta" defined the type as', + '"OneFieldModel" has no attribute "additional_attr"', ], "test_negotiation.py": ['has incompatible type "None"'], "test_pagination.py": [ "(not iterable)", 'has incompatible type "range"', 'expected "Iterable[Any]"', + 'Value of type variable "_MT" of "paginate_queryset" of "CursorPagination" cannot be "object"', + 'Value of type "Union[object, Any]" is not indexable', ], "test_parsers.py": ['"object" has no attribute', 'Argument 1 to "isnan" has incompatible type'], "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', ], @@ -160,7 +164,6 @@ 'Argument 2 to "re_path" has incompatible type "Callable[[], None]"; expected "Callable[..., HttpResponseBase]"', # noqa: E501 ], "test_relations_pk.py": [ - '"OneToOneTarget" has no attribute "id"', '"Field[Any, Any, Any, Any]" has no attribute "get_queryset', ], "test_renderers.py": [ @@ -180,15 +183,10 @@ '"BasenameTestCase" has no attribute "router"', 'Unexpected keyword argument "use_regex_path" for "SimpleRouter"', ], - "test_reverse.py": [ - 'Incompatible types in assignment (expression has type "MockVersioningScheme", variable has type "Optional[BaseVersioning]', # noqa: E501 - ], "test_serializer.py": [ "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', @@ -207,7 +205,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[, ]"', From 4b09a14f01803cf6a5f0d465713e5c61aa080fb1 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 7 Feb 2023 18:05:50 +0200 Subject: [PATCH 2/3] A few ignore reversions --- scripts/typecheck_tests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/typecheck_tests.py b/scripts/typecheck_tests.py index 78f389127..32215c00c 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -154,6 +154,7 @@ "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', ], @@ -187,6 +188,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', @@ -205,6 +208,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[, ]"', From 2b3e2b654e800030a008f6343ee2fb054f06c588 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Tue, 7 Feb 2023 18:08:28 +0200 Subject: [PATCH 3/3] Trailing commas --- 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 32215c00c..bf71f3561 100644 --- a/scripts/typecheck_tests.py +++ b/scripts/typecheck_tests.py @@ -56,7 +56,7 @@ '"_MonkeyPatchedWSGIResponse" has no attribute "content"', '"_MonkeyPatchedWSGIResponse" has no attribute "data"', '" defined here', - '" has no attribute "id"' + '" has no attribute "id"', ], "authentication": [ 'Argument 1 to "post" of "APIClient" has incompatible type "None"; expected "str', @@ -129,7 +129,7 @@ 'has incompatible type "str"', '"Response" has no attribute "serializer"', 'Incompatible types in assignment (expression has type "Type[SlugSerializer]", base class "InstanceView" defined the type as "Type[BasicSerializer]")', # noqa: E501 - 'Incompatible types in assignment (expression has type "_QuerySet[SlugBasedModel, SlugBasedModel]", base class "InstanceView" defined the type as "_QuerySet[BasicModel, BasicModel]")' # noqa: E501 + 'Incompatible types in assignment (expression has type "_QuerySet[SlugBasedModel, SlugBasedModel]", base class "InstanceView" defined the type as "_QuerySet[BasicModel, BasicModel]")', # noqa: E501 ], "test_htmlrenderer.py": [ 'to "get_template_names" of "TemplateHTMLRenderer" has incompatible type',