From f2511e9af707abd4925d94b1a917e8802d372f7d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2024 11:07:39 -0300 Subject: [PATCH 1/2] Drop Python 3.8 EOL and add Python 3.12 and 3.13 --- .github/workflows/test.yml | 2 +- CHANGELOG.rst | 9 +++++++++ README.rst | 15 --------------- setup.py | 5 +++-- tox.ini | 2 +- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05d8b9c..8d84e6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] os: [ubuntu-latest, windows-latest] steps: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2dfe224..ca973e8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,12 @@ +UNRELEASED +---------- + +*UNRELEASED* + +* Python 3.12 and 3.13 are now officially supported. +* Python 3.8 (EOL) is no longer supported. + + 2.6.0 ----- diff --git a/README.rst b/README.rst index d72c57a..4419c8b 100644 --- a/README.rst +++ b/README.rst @@ -38,21 +38,6 @@ can be used to verify that future runs produce the same data. See `the docs `_ for examples and API usage. -Requirements ------------- - -* ``pytest>=3.5`` -* Python 3.6+. - - -Installation ------------- - -You can install "pytest-regressions" via `pip`_ from `PyPI`_:: - - $ pip install pytest-regressions - - Contributing ------------ Contributions are very welcome. Tests can be run with `tox`_, please ensure diff --git a/setup.py b/setup.py index e5bab7e..f5007e2 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def read(fname: str) -> str: long_description_content_type="text/x-rst", packages=find_packages("src"), package_dir={"": "src"}, - python_requires=">=3.8", + python_requires=">=3.9", package_data={ "pytest_regressions": ["py.typed"], }, @@ -54,10 +54,11 @@ def read(fname: str) -> str: "Intended Audience :: Developers", "Topic :: Software Development :: Testing", "Programming Language :: Python :: 3", - "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", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", diff --git a/tox.ini b/tox.ini index 8fe7a78..5aca2ce 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38,py39,py310,py311,pytest6 +envlist = py39,py310,py311,py312,py313,pytest6 [testenv] download = true From 9f41630dc67dd0d558dc4198815765df1a15b33e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2024 11:09:59 -0300 Subject: [PATCH 2/2] Run pyupgrade --py39-plus on all files --- src/pytest_regressions/common.py | 11 +++++------ src/pytest_regressions/data_regression.py | 3 +-- src/pytest_regressions/dataframe_regression.py | 9 ++++----- src/pytest_regressions/ndarrays_regression.py | 15 +++++++-------- src/pytest_regressions/num_regression.py | 9 ++++----- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/pytest_regressions/common.py b/src/pytest_regressions/common.py index 4992f11..c59860c 100644 --- a/src/pytest_regressions/common.py +++ b/src/pytest_regressions/common.py @@ -1,10 +1,9 @@ import difflib import os +from collections.abc import MutableMapping +from collections.abc import MutableSequence from pathlib import Path from typing import Callable -from typing import List -from typing import MutableMapping -from typing import MutableSequence from typing import Optional from typing import TypeVar from typing import Union @@ -19,7 +18,7 @@ def import_error_message(libname: str) -> str: def check_text_files( obtained_fn: "os.PathLike[str]", expected_fn: "os.PathLike[str]", - fix_callback: Callable[[List[str]], List[str]] = lambda x: x, + fix_callback: Callable[[list[str]], list[str]] = lambda x: x, encoding: Optional[str] = None, ) -> None: """ @@ -94,7 +93,7 @@ def perform_regression_check( force_regen: bool = False, with_test_class_names: bool = False, obtained_filename: Optional["os.PathLike[str]"] = None, - dump_aux_fn: Callable[[Path], List[str]] = lambda filename: [], + dump_aux_fn: Callable[[Path], list[str]] = lambda filename: [], ) -> None: """ First run of this check will generate a expected file. Following attempts will always try to @@ -144,7 +143,7 @@ def perform_regression_check( filename = datadir / (basename + extension) source_filename = original_datadir / (basename + extension) - def make_location_message(banner: str, filename: Path, aux_files: List[str]) -> str: + def make_location_message(banner: str, filename: Path, aux_files: list[str]) -> str: msg = [banner, f"- {filename}"] if aux_files: msg.append("Auxiliary:") diff --git a/src/pytest_regressions/data_regression.py b/src/pytest_regressions/data_regression.py index b86298e..ca261c8 100644 --- a/src/pytest_regressions/data_regression.py +++ b/src/pytest_regressions/data_regression.py @@ -3,7 +3,6 @@ from pathlib import Path from typing import Any from typing import Callable -from typing import Dict from typing import Optional import pytest @@ -30,7 +29,7 @@ def __init__( def check( self, - data_dict: Dict[str, Any], + data_dict: dict[str, Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, round_digits: Optional[int] = None, diff --git a/src/pytest_regressions/dataframe_regression.py b/src/pytest_regressions/dataframe_regression.py index adcba3c..7b4740a 100644 --- a/src/pytest_regressions/dataframe_regression.py +++ b/src/pytest_regressions/dataframe_regression.py @@ -1,7 +1,6 @@ import os from pathlib import Path from typing import Any -from typing import Dict from typing import Optional import pytest @@ -22,8 +21,8 @@ class DataFrameRegressionFixture: def __init__( self, datadir: Path, original_datadir: Path, request: pytest.FixtureRequest ) -> None: - self._tolerances_dict: Dict[str, Dict[str, float]] = {} - self._default_tolerance: Dict[str, float] = {} + self._tolerances_dict: dict[str, dict[str, float]] = {} + self._default_tolerance: dict[str, float] = {} self.request = request self.datadir = datadir @@ -187,8 +186,8 @@ def check( data_frame: Any, basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, - tolerances: Optional[Dict[str, Dict[str, float]]] = None, - default_tolerance: Optional[Dict[str, float]] = None, + tolerances: Optional[dict[str, dict[str, float]]] = None, + default_tolerance: Optional[dict[str, float]] = None, ) -> None: """ Checks a pandas dataframe, containing only numeric data, against a previously recorded version, or generate a new file. diff --git a/src/pytest_regressions/ndarrays_regression.py b/src/pytest_regressions/ndarrays_regression.py index 09a7252..53e82de 100644 --- a/src/pytest_regressions/ndarrays_regression.py +++ b/src/pytest_regressions/ndarrays_regression.py @@ -2,7 +2,6 @@ import zipfile from pathlib import Path from typing import Any -from typing import Dict from typing import Optional import pytest @@ -22,8 +21,8 @@ class NDArraysRegressionFixture: def __init__( self, datadir: Path, original_datadir: Path, request: pytest.FixtureRequest ) -> None: - self._tolerances_dict: Dict[str, Dict[str, float]] = {} - self._default_tolerance: Dict[str, float] = {} + self._tolerances_dict: dict[str, dict[str, float]] = {} + self._default_tolerance: dict[str, float] = {} self.request = request self.datadir = datadir @@ -239,7 +238,7 @@ def _check_fn(self, obtained_filename: Path, expected_filename: Path) -> None: raise AssertionError(error_msg) - def _load_fn(self, filename: Path) -> Dict[str, Any]: + def _load_fn(self, filename: Path) -> dict[str, Any]: """ Load dict contents from the given filename. """ @@ -260,7 +259,7 @@ def _load_fn(self, filename: Path) -> Dict[str, Any]: ) from e return result - def _dump_fn(self, data_dict: Dict[str, Any], filename: Path) -> None: + def _dump_fn(self, data_dict: dict[str, Any], filename: Path) -> None: """ Dump dict contents to the given filename. """ @@ -273,11 +272,11 @@ def _dump_fn(self, data_dict: Dict[str, Any], filename: Path) -> None: def check( self, - data_dict: Dict[str, Any], + data_dict: dict[str, Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, - tolerances: Optional[Dict[str, Dict[str, float]]] = None, - default_tolerance: Optional[Dict[str, float]] = None, + tolerances: Optional[dict[str, dict[str, float]]] = None, + default_tolerance: Optional[dict[str, float]] = None, ) -> None: """ Checks a dictionary of NumPy ndarrays, containing only numeric data, against a previously recorded version, or generate a new file. diff --git a/src/pytest_regressions/num_regression.py b/src/pytest_regressions/num_regression.py index a67efbc..f683977 100644 --- a/src/pytest_regressions/num_regression.py +++ b/src/pytest_regressions/num_regression.py @@ -1,8 +1,7 @@ import os +from collections.abc import Sequence from typing import Any -from typing import Dict from typing import Optional -from typing import Sequence from .common import import_error_message from .dataframe_regression import DataFrameRegressionFixture @@ -15,11 +14,11 @@ class NumericRegressionFixture(DataFrameRegressionFixture): def check( self, - data_dict: Dict[str, Any], + data_dict: dict[str, Any], basename: Optional[str] = None, fullpath: Optional["os.PathLike[str]"] = None, - tolerances: Optional[Dict[str, Dict[str, float]]] = None, - default_tolerance: Optional[Dict[str, float]] = None, + tolerances: Optional[dict[str, dict[str, float]]] = None, + default_tolerance: Optional[dict[str, float]] = None, data_index: Optional[Sequence[int]] = None, fill_different_shape_with_nan: bool = True, ) -> None: