From 326074687b7a50a7b9cc6de0244f9fbbc3c3e14b Mon Sep 17 00:00:00 2001 From: Jose Tomas Robles Hahn Date: Wed, 9 Aug 2023 19:25:46 -0400 Subject: [PATCH] fix: Fix type checking of Setuptools configuration - Fix incorrect type annotation of `get_version()` in `setup.py`. - Add missing type annotations to `setup_requirements` and `test_requirements` in `setup.py`. - Update Mypy configuration to ignore missing imports for `setuptools`. --- mypy.ini | 3 +++ setup.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index 849c4612..64634425 100644 --- a/mypy.ini +++ b/mypy.ini @@ -31,6 +31,9 @@ ignore_missing_imports = True [mypy-rest_framework.*] ignore_missing_imports = True +[mypy-setuptools.*] +ignore_missing_imports = True + [pydantic-mypy] init_forbid_extra = True init_typed = True diff --git a/setup.py b/setup.py index 1ab992c0..0ec8a63a 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import find_packages, setup -def get_version(*file_paths: Sequence[str]) -> str: +def get_version(*file_paths: str) -> str: filename = os.path.join(os.path.dirname(__file__), *file_paths) version_file = open(filename).read() version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) @@ -37,9 +37,9 @@ def get_version(*file_paths: Sequence[str]) -> str: 'djangorestframework': ['djangorestframework>=3.10.3,<3.15'], } -setup_requirements = [] +setup_requirements: Sequence[str] = [] -test_requirements = [ +test_requirements: Sequence[str] = [ # note: include here only packages **imported** in test code (e.g. 'requests-mock'), NOT those # like 'coverage' or 'tox'. ]