From 78870fa0e76eb0f43d1c987c5c4fa83c59f806a9 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 4 Jun 2022 14:08:00 -0700 Subject: [PATCH] Move mypy version upper bound to a [compatible-mypy] extra (#979) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move mypy version upper bound to a [compatible-mypy] extra Due to a bug in mypy 0.940 (#870), we made two changes in #871: • pinned mypy==0.931 in requirements.txt (for running our tests); • bounded mypy<0.940 in setup.py (for downstream users). After the mypy bug was quickly fixed upstream in 0.941, our setup.py bound has been repeatedly raised but not removed (#886, #939, #973). The only changes in those commits have been to the precise wording of error messages expected in our tests. Those wording changes don’t impact compatibility for downstream users, so it should be safe to go back to allowing them to upgrade mypy independently. Since mypy doesn’t yet guarantee backwards compatibility in the plugin API (although in practice it has rarely been an issue), add a django-stubs[compatible-mypy] extra for users who prefer a known-good version of mypy even if it’s a little out of date. Signed-off-by: Anders Kaseorg * Update setup.py Co-authored-by: Nikita Sobolev --- README.md | 2 +- requirements.txt | 2 +- setup.py | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 23213e2015..98c2780283 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This package contains [type stubs](https://www.python.org/dev/peps/pep-0561/) an ## Installation ```bash -pip install django-stubs +pip install django-stubs[compatible-mypy] ``` To make mypy aware of the plugin, you need to add diff --git a/requirements.txt b/requirements.txt index 411fbf78ec..00588b530f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ pytest==7.1.2 pytest-mypy-plugins==1.9.3 psycopg2-binary -e ./django_stubs_ext --e . +-e .[compatible-mypy] # Overrides: mypy==0.960 diff --git a/setup.py b/setup.py index 7ed868da00..cc8c4a61f4 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def find_stub_files(name: str) -> List[str]: readme = f.read() dependencies = [ - "mypy>=0.930,<0.970", + "mypy>=0.930", "django", "django-stubs-ext>=0.4.0", "tomli", @@ -30,6 +30,10 @@ def find_stub_files(name: str) -> List[str]: "types-PyYAML", ] +extras_require = { + "compatible-mypy": ["mypy>=0.930,<0.970"], +} + setup( name="django-stubs", version="1.11.1", @@ -43,6 +47,7 @@ def find_stub_files(name: str) -> List[str]: py_modules=[], python_requires=">=3.7", install_requires=dependencies, + extras_require=extras_require, packages=["django-stubs", *find_packages(exclude=["scripts"])], package_data={ "django-stubs": find_stub_files("django-stubs"),