From b2e66bda273ed65e87e9d1a08336bdeb20d0c477 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 2 Apr 2024 10:57:49 -0400 Subject: [PATCH] chore: require Python 3.8+ (#581) * chore: drop Python 3.7, add Python 3.12 Signed-off-by: Henry Schreiner * ci: speed up with uv Signed-off-by: Henry Schreiner * Revert "ci: speed up with uv" This reverts commit c2fbd07a20004177d3bc199e2f9c9bc5d069b4a4. --------- Signed-off-by: Henry Schreiner --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 15 +++++++-------- README.md | 2 +- environment.yml | 2 +- noxfile.py | 2 +- pyproject.toml | 6 +++--- src/particle/_compat/typing.py | 11 +---------- src/particle/typing.py | 4 ++-- tests/test_module_apis.py | 18 ------------------ 9 files changed, 17 insertions(+), 45 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 19e4e812..a52c7bad 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -38,7 +38,7 @@ jobs: - uses: wntrblm/nox@2024.03.02 with: - python-versions: "3.7" + python-versions: "3.8" - name: Make ZipApp run: nox -s zipapp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72718745..5f91d056 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,12 +36,12 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] include: - - {os: macos-latest, python-version: '3.7'} - - {os: macos-latest, python-version: '3.11'} - - {os: windows-latest, python-version: '3.7'} - - {os: windows-latest, python-version: '3.11'} + - {os: macos-latest, python-version: '3.8'} + - {os: macos-latest, python-version: '3.12'} + - {os: windows-latest, python-version: '3.8'} + - {os: windows-latest, python-version: '3.12'} steps: - uses: actions/checkout@v4 @@ -62,11 +62,10 @@ jobs: run: python -m pytest ./tests --cov=src/particle --cov-report=xml - name: Test coverage with Codecov - if: "runner.os != 'Windows' && matrix.python-version != 3.7" uses: codecov/codecov-action@v4 - name: Test docstrings with doctest - if: "runner.os == 'Linux' && matrix.python-version == 3.11" + if: "runner.os == 'Linux' && matrix.python-version == 3.12" run: python -m pytest --doctest-modules src/particle --ignore=src/particle/particle/convert.py notebooks: @@ -101,7 +100,7 @@ jobs: - uses: wntrblm/nox@2024.03.02 with: - python-versions: 3.7 + python-versions: "3.8" - name: Make ZipApp run: nox -s zipapp diff --git a/README.md b/README.md index 0378e934..598f0605 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ or similar (use `--user`, `virtualenv`, etc. if you wish). ## Strict dependencies -- [Python](http://docs.python-guide.org/en/latest/starting/installation/) (3.7+) +- [Python](http://docs.python-guide.org/en/latest/starting/installation/) (3.8+) - [importlib_resources backport](http://importlib-resources.readthedocs.io/en/latest/) if using Python < 3.9 - [attrs](http://www.attrs.org/en/stable/) provides classes without boilerplate (similar to DataClasses in Python 3.7) - [hepunits](https://github.com/scikit-hep/hepunits)\_ provides units for the Scikit-HEP packages diff --git a/environment.yml b/environment.yml index f181881b..70b38382 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ name: particle_demo channels: - conda-forge dependencies: - - python>=3.7 + - python>=3.8 # Setting recent versions to make the conda solve faster - numpy>=1.16 - pandas>=0.24 diff --git a/noxfile.py b/noxfile.py index d0be7440..3165fdab 100644 --- a/noxfile.py +++ b/noxfile.py @@ -47,7 +47,7 @@ def build(session: nox.Session) -> None: ) -@nox.session(python="3.7") +@nox.session(python="3.8") def zipapp(session: nox.Session) -> None: tmpdir = session.create_tmp() diff --git a/pyproject.toml b/pyproject.toml index 376156d7..17a99341 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "particle" description = "Extended PDG particle data and MC identification codes" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.8" authors = [ { name = "Eduardo Rodrigues", email = "eduardo.rodrigues@cern.ch" }, { name = "Henry Schreiner", email = "henryfs@princeton.edu" }, @@ -32,11 +32,11 @@ classifiers = [ "Programming Language :: Python", "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", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering", ] dependencies = [ @@ -111,7 +111,7 @@ filterwarnings = [ ] [tool.pylint] -master.py-version = "3.7" +master.py-version = "3.8" reports.output-format = "colorized" similarities.ignore-imports = "yes" master.jobs = "0" diff --git a/src/particle/_compat/typing.py b/src/particle/_compat/typing.py index 62e35264..5f621cc3 100644 --- a/src/particle/_compat/typing.py +++ b/src/particle/_compat/typing.py @@ -8,11 +8,6 @@ import sys -if sys.version_info < (3, 8): - from typing_extensions import Protocol, runtime_checkable -else: - from typing import Protocol, runtime_checkable - if sys.version_info < (3, 9): from importlib_resources.abc import Traversable elif sys.version_info < (3, 11): @@ -21,8 +16,4 @@ from importlib.resources.abc import Traversable -__all__ = ( - "Protocol", - "runtime_checkable", - "Traversable", -) +__all__ = ("Traversable",) diff --git a/src/particle/typing.py b/src/particle/typing.py index 2a5edefc..16f99941 100644 --- a/src/particle/typing.py +++ b/src/particle/typing.py @@ -6,9 +6,9 @@ from __future__ import annotations -from typing import IO, Any, Union +from typing import IO, Any, Protocol, Union, runtime_checkable -from ._compat.typing import Protocol, Traversable, runtime_checkable +from ._compat.typing import Traversable __all__ = ( "StringOrIO", diff --git a/tests/test_module_apis.py b/tests/test_module_apis.py index 3c61d592..6205371c 100644 --- a/tests/test_module_apis.py +++ b/tests/test_module_apis.py @@ -1,17 +1,8 @@ from __future__ import annotations -from sys import version_info - -import pytest - import particle -python37plus_only = pytest.mark.skipif( - version_info < (3, 7), reason="requires Python3.7+" -) - -@python37plus_only def test_top_level_api(): assert dir(particle) == [ "Charge", @@ -33,7 +24,6 @@ def test_top_level_api(): ] -@python37plus_only def test_api_converters(): assert dir(particle.converters) == [ "Corsika72PDGIDBiMap", @@ -45,22 +35,18 @@ def test_api_converters(): ] -@python37plus_only def test_api_corsika(): assert dir(particle.corsika) == ["Corsika7ID"] -@python37plus_only def test_api_data(): assert dir(particle.data) == ["basepath"] -@python37plus_only def test_api_geant(): assert dir(particle.geant) == ["Geant3ID"] -@python37plus_only def test_api_lhcb(): assert dir(particle.lhcb) == [ "LHCbName2PDGIDBiMap", @@ -69,12 +55,10 @@ def test_api_lhcb(): ] -@python37plus_only def test_api_lhcb_data(): assert dir(particle.lhcb.data) == ["basepath"] -@python37plus_only def test_api_particle(): assert dir(particle.particle) == [ "Charge", @@ -93,7 +77,6 @@ def test_api_particle(): ] -@python37plus_only def test_api_pdgid(): assert dir(particle.pdgid) == sorted( [ @@ -145,6 +128,5 @@ def test_api_pdgid(): ) -@python37plus_only def test_api_pythia(): assert dir(particle.pythia) == ["PythiaID"]