From 124a8d9f55c95f496d129fbd1e479ea39bd46695 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 12 Oct 2022 00:53:46 -0400 Subject: [PATCH] feat: Drop Python 3.7 support (#2044) * Drop Python 3.7 support to follow NEP 29 development recommendations. - c.f. https://github.com/scikit-hep/pyhf/discussions/2042 * Drop typing_extensions as a requirement as that is needed by Python 3.7 only. * Update lower bound of the supported scipy versions to v1.3.2, the first scipy release with Python 3.8 wheels. * Update pre-commit hooks to use Python 3.8. --- .github/workflows/ci.yml | 2 +- .github/workflows/lower-bound-requirements.yml | 2 +- .github/workflows/release_tests.yml | 2 +- .pre-commit-config.yaml | 6 +++--- codemeta.json | 1 - pyproject.toml | 4 ++-- setup.cfg | 6 ++---- src/pyhf/contrib/utils.py | 2 +- src/pyhf/typing.py | 18 +++++++++++------- tests/constraints.txt | 3 +-- tests/test_optim.py | 3 +-- 11 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 699a9a517e..def16ecf0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10'] include: - os: macos-latest python-version: '3.10' diff --git a/.github/workflows/lower-bound-requirements.yml b/.github/workflows/lower-bound-requirements.yml index eec586eace..71a4696ccd 100644 --- a/.github/workflows/lower-bound-requirements.yml +++ b/.github/workflows/lower-bound-requirements.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [ubuntu-latest] # minimum supported Python - python-version: ['3.7'] + python-version: ['3.8'] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release_tests.yml b/.github/workflows/release_tests.yml index c161badf75..66b2fa2d84 100644 --- a/.github/workflows/release_tests.yml +++ b/.github/workflows/release_tests.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10'] include: - os: macos-latest python-version: '3.10' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e054983450..5d16963c80 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: rev: v2.38.2 hooks: - id: pyupgrade - args: ["--py37-plus"] + args: ["--py38-plus"] - repo: https://github.com/MarcoGorelli/absolufy-imports rev: v0.3.1 @@ -66,11 +66,11 @@ repos: hooks: - &mypy id: mypy - name: mypy with Python 3.7 + name: mypy with Python 3.8 files: src additional_dependencies: ['numpy', 'types-tqdm', 'click', 'types-jsonpatch', 'types-pyyaml', 'types-jsonschema', 'importlib_metadata', 'packaging'] - args: ["--python-version=3.7"] + args: ["--python-version=3.8"] - <<: *mypy name: mypy with Python 3.10 args: ["--python-version=3.10"] diff --git a/codemeta.json b/codemeta.json index db699d0352..890068d861 100644 --- a/codemeta.json +++ b/codemeta.json @@ -58,7 +58,6 @@ "Python 3", "Python 3 Only", "Python 3.10", - "Python 3.7", "Python 3.8", "Python 3.9", "Python Implementation CPython" diff --git a/pyproject.toml b/pyproject.toml index 4214261f18..37e8725f04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ local_scheme = "no-local-version" [tool.black] line-length = 88 -target-version = ['py37', 'py38'] +target-version = ['py38', 'py39', 'py310'] skip-string-normalization = true include = '\.pyi?$' exclude = ''' @@ -96,7 +96,7 @@ filterwarnings = [ pyupgrade = 1 [tool.nbqa.addopts] -pyupgrade = ["--py37-plus"] +pyupgrade = ["--py38-plus"] [tool.mypy] files = "src" diff --git a/setup.cfg b/setup.cfg index 635512862f..ddf5c9d250 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,6 @@ classifiers = Topic :: Scientific/Engineering :: Physics Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -33,16 +32,15 @@ packages = find_namespace: package_dir = = src include_package_data = True -python_requires = >=3.7 +python_requires = >=3.8 install_requires = - scipy>=1.2.0 # requires numpy, which is required by pyhf and tensorflow + scipy>=1.3.2 # requires numpy, which is required by pyhf and tensorflow click>=8.0.0 # for console scripts tqdm>=4.56.0 # for readxml jsonschema>=4.15.0 # for utils jsonpatch>=1.15 pyyaml>=5.1 # for parsing CLI equal-delimited options importlib_resources>=1.4.0; python_version < "3.9" # for resources in schema - typing_extensions>=3.7.4.3; python_version == "3.7" # for SupportsIndex numpy # compatible versions controlled through scipy [options.packages.find] diff --git a/src/pyhf/contrib/utils.py b/src/pyhf/contrib/utils.py index da6daedd32..be9694d094 100644 --- a/src/pyhf/contrib/utils.py +++ b/src/pyhf/contrib/utils.py @@ -81,7 +81,7 @@ def download(archive_url, output_directory, force=False, compress=False): archive.write(response.content) else: # Support for file-like objects for tarfile.is_tarfile was added - # in Python 3.9, so as pyhf is currently Python 3.7+ then can't + # in Python 3.9, so as pyhf is currently Python 3.8+ then can't # do tarfile.is_tarfile(BytesIO(response.content)). # Instead, just use a 'try except' block to determine if the # archive is a valid tarfile. diff --git a/src/pyhf/typing.py b/src/pyhf/typing.py index ee874d5b17..f012e3af22 100644 --- a/src/pyhf/typing.py +++ b/src/pyhf/typing.py @@ -1,11 +1,15 @@ import os -import sys -from typing import Any, MutableSequence, Sequence, Tuple, Union - -if sys.version_info >= (3, 8): - from typing import Literal, Protocol, SupportsIndex, TypedDict -else: - from typing_extensions import Literal, Protocol, SupportsIndex, TypedDict +from typing import ( + Any, + Literal, + MutableSequence, + Protocol, + Sequence, + SupportsIndex, + Tuple, + TypedDict, + Union, +) __all__ = ( "PathOrStr", diff --git a/tests/constraints.txt b/tests/constraints.txt index 4e2e4d860c..9181755d8e 100644 --- a/tests/constraints.txt +++ b/tests/constraints.txt @@ -1,12 +1,11 @@ # core -scipy==1.2.0 # c.f. PR #1274 +scipy==1.3.2 # c.f. PR #2044 click==8.0.0 # c.f. PR #1958, #1909 tqdm==4.56.0 jsonschema==4.15.0 # c.f. PR #1979 jsonpatch==1.15 pyyaml==5.1 importlib_resources==1.4.0 # c.f. PR #1979 -typing-extensions==3.7.4.3 # c.f. PR #1961, #1940 # xmlio uproot==4.1.1 # minuit diff --git a/tests/test_optim.py b/tests/test_optim.py index cc245833d0..323561ddd3 100644 --- a/tests/test_optim.py +++ b/tests/test_optim.py @@ -515,8 +515,7 @@ def test_init_pars_sync_fixed_values_minuit(mocker): minuit = mocker.patch.object(getattr(opt_minuit, 'iminuit'), 'Minuit') minimizer = opt._get_minimizer(None, [9, 9, 9], [(0, 10)] * 3, fixed_vals=[(0, 1)]) assert minuit.called - # python 3.7 does not have ::args attribute on ::call_args - # assert minuit.call_args.args[1] == [1, 9, 9] + assert minuit.call_args.args[1] == [1, 9, 9] assert minuit.call_args[0][1] == [1, 9, 9] assert minimizer.fixed == [True, False, False]