From 7fda998c51e2d383bf3d1538e4fa1c3213740e0d Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Mon, 27 Feb 2023 13:57:38 -0800 Subject: [PATCH] dev: Pin types-requests on Python 3.6 to a version that works with mypy on 3.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mypy 0.971 is the last version to support Python 3.6, so this is what pip installs on 3.6. types-requests 2.28.11.12 is the last version to support mypy <1.0.0, due to changes in how the "Self" type is handled.¹ However, there's no way to declare that in package metadata (without requiring mypy, which is inappropriate for a typeshed package), so we have to resolve this dependency ourselves.² With a too-new types-requests, mypy fails on 3.6 with errors like: nextstrain/cli/remote/nextstrain_dot_org.py:230: error: Self? has no attribute "auth" which we saw in CI failures.³ We'll drop support for Python 3.6 sooner than later, but for now, keep it going. ¹ ² It would be possible if, for example, Python package metadata supported a "Conflicts" field, as many packaging systems do. ³ --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b2c1316e..041b11ca 100644 --- a/setup.py +++ b/setup.py @@ -140,7 +140,8 @@ def find_namespaced_packages(namespace): "sphinx_rtd_theme", "types-docutils", "types-setuptools", - "types-requests", + "types-requests; python_version != '3.6'", + "types-requests <=2.28.11.12; python_version == '3.6'", ], }, )