Skip to content

Commit

Permalink
Drop Python 3.8, add Python 3.12 and 3.13 (#181)
Browse files Browse the repository at this point in the history
* Drop Python 3.8 EOL and add Python 3.12 and 3.13

* Run pyupgrade --py39-plus on all files
  • Loading branch information
nicoddemus authored Dec 18, 2024
2 parents cc05910 + 9f41630 commit 05be0bb
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
15 changes: 0 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ can be used to verify that future runs produce the same data.
See `the docs <https://pytest-regressions.readthedocs.io/en/latest>`_ 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
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 5 additions & 6 deletions src/pytest_regressions/common.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:")
Expand Down
3 changes: 1 addition & 2 deletions src/pytest_regressions/data_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
9 changes: 4 additions & 5 deletions src/pytest_regressions/dataframe_regression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from pathlib import Path
from typing import Any
from typing import Dict
from typing import Optional

import pytest
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 7 additions & 8 deletions src/pytest_regressions/ndarrays_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import zipfile
from pathlib import Path
from typing import Any
from typing import Dict
from typing import Optional

import pytest
Expand All @@ -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
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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.
"""
Expand All @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions src/pytest_regressions/num_regression.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,py39,py310,py311,pytest6
envlist = py39,py310,py311,py312,py313,pytest6

[testenv]
download = true
Expand Down

0 comments on commit 05be0bb

Please sign in to comment.