From 58b8ae48f8a98aec416e4401b7e2cd76de6cd1c7 Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Fri, 10 May 2024 19:31:37 +0300 Subject: [PATCH 1/2] Mypy: Don't ignore missing imports (remove `ignore_missing_imports`) --- mypy.ini | 3 +-- rest_framework-stubs/compat.pyi | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index e140bf240..dde983ce5 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,7 +1,6 @@ [mypy] allow_redefinition = true check_untyped_defs = true -ignore_missing_imports = true incremental = true strict_optional = true show_traceback = true @@ -11,7 +10,7 @@ warn_unused_configs = true warn_unreachable = true disallow_untyped_defs = true disallow_incomplete_defs = true -disable_error_code = empty-body +disable_error_code = empty-body,import-untyped # TODO: update our test error messages to match new mypy output show_error_codes = false force_uppercase_builtins = true diff --git a/rest_framework-stubs/compat.pyi b/rest_framework-stubs/compat.pyi index 35de44c18..e48b4126d 100644 --- a/rest_framework-stubs/compat.pyi +++ b/rest_framework-stubs/compat.pyi @@ -24,7 +24,7 @@ try: except ImportError: yaml: TypeAlias = None # type: ignore[no-redef] try: - import inflection + import inflection # type: ignore[import-not-found,unused-ignore] except ImportError: inflection: TypeAlias = None # type: ignore[no-redef] try: From 0730a47d9574c756dc00c84b39227fef13b7ab4b Mon Sep 17 00:00:00 2001 From: Marti Raudsepp Date: Fri, 10 May 2024 19:43:58 +0300 Subject: [PATCH 2/2] type:ignore instead of mypy.ini; add types-Pygments --- mypy.ini | 2 +- requirements.txt | 1 + rest_framework-stubs/compat.pyi | 4 ++-- rest_framework-stubs/pagination.pyi | 2 +- rest_framework-stubs/test.pyi | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mypy.ini b/mypy.ini index dde983ce5..375b3d093 100644 --- a/mypy.ini +++ b/mypy.ini @@ -10,7 +10,7 @@ warn_unused_configs = true warn_unreachable = true disallow_untyped_defs = true disallow_incomplete_defs = true -disable_error_code = empty-body,import-untyped +disable_error_code = empty-body # TODO: update our test error messages to match new mypy output show_error_codes = false force_uppercase_builtins = true diff --git a/requirements.txt b/requirements.txt index 65d7b899e..51f64ba94 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ djangorestframework==3.15.1 types-pytz==2024.1.0.20240417 types-requests==2.31.0.20240406 types-urllib3==1.26.25.14 +types-Pygments==2.18.0.20240506 django-stubs[compatible-mypy] @ git+https://github.com/typeddjango/django-stubs django-stubs-ext @ git+https://github.com/typeddjango/django-stubs#subdirectory=ext -e .[compatible-mypy,coreapi,markdown] diff --git a/rest_framework-stubs/compat.pyi b/rest_framework-stubs/compat.pyi index e48b4126d..bb68ebc90 100644 --- a/rest_framework-stubs/compat.pyi +++ b/rest_framework-stubs/compat.pyi @@ -8,7 +8,7 @@ try: except ImportError: postgres_fields: TypeAlias = None # type: ignore[no-redef] try: - import coreapi + import coreapi # type: ignore[import-untyped] except ImportError: coreapi: TypeAlias = None # type: ignore[no-redef] try: @@ -16,7 +16,7 @@ try: except ImportError: uritemplate: TypeAlias = None # type: ignore[no-redef] try: - import coreschema + import coreschema # type: ignore[import-untyped] except ImportError: coreschema: TypeAlias = None # type: ignore[no-redef] try: diff --git a/rest_framework-stubs/pagination.pyi b/rest_framework-stubs/pagination.pyi index c9ed3fbe7..a61291b7e 100644 --- a/rest_framework-stubs/pagination.pyi +++ b/rest_framework-stubs/pagination.pyi @@ -1,7 +1,7 @@ from collections.abc import Callable, Sequence from typing import Any, NamedTuple, TypeVar -from coreapi import Field as CoreAPIField +from coreapi import Field as CoreAPIField # type: ignore[import-untyped] from django.core.paginator import Page, Paginator from django.db.models import Model, QuerySet from rest_framework.request import Request diff --git a/rest_framework-stubs/test.pyi b/rest_framework-stubs/test.pyi index 493b31ec0..156ce89ed 100644 --- a/rest_framework-stubs/test.pyi +++ b/rest_framework-stubs/test.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from collections.abc import Iterable, Mapping from typing import Any -import coreapi +import coreapi # type: ignore[import-untyped] import requests import urllib3 from django.contrib.auth.base_user import AbstractBaseUser