Skip to content

Commit

Permalink
Merge pull request #145 from khaeru/remove-distutils
Browse files Browse the repository at this point in the history
Update data source tests for Python 3.12
  • Loading branch information
khaeru authored Oct 29, 2023
2 parents 59a8c17 + 6a7417b commit c28f50a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ jobs:
- "3.8" # Earliest supported version
- "3.9"
- "3.10"
- "3.11" # Latest supported version
- "3.11"
- "3.12" # Latest supported version
# commented: only enable once next Python version enters RC
# - "3.12.0-rc.1" # Development version
# - "3.13.0-rc.1" # Development version

fail-fast: false

Expand All @@ -53,7 +54,7 @@ jobs:
run: python -m pip install --upgrade pip wheel

- name: Install the Python package and dependencies
run: pip install .[cache,docs,tests]
run: pip install .[cache,tests]

- name: Run pytest
env:
Expand All @@ -68,10 +69,6 @@ jobs:
- name: Upload test coverage to Codecov.io
uses: codecov/codecov-action@v3

- name: Test documentation build using Sphinx
if: contains(matrix.os, 'ubuntu')
run: make --directory=doc html

pre-commit:
name: Code quality

Expand All @@ -80,4 +77,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with: { python-version: 3.x }

- name: Force recreation of pre-commit virtual environment for mypy
if: github.event_name == 'schedule' # Comment this line to run on a PR
run: gh cache list -L 999 | cut -f2 | grep pre-commit | xargs -I{} gh cache delete "{}" || true
env: { GH_TOKEN: "${{ github.token }}" }

- uses: pre-commit/[email protected]
10 changes: 4 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v1.6.1
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -14,11 +14,9 @@ repos:
- types-PyYAML
- types-requests
args: []
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.1.2
hooks:
- id: ruff
- id: ruff-format
args: [ --check ]
6 changes: 4 additions & 2 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
What's new?
***********

.. Next release
.. ============
Next release
============

- Python 3.12 (released 2023-10-02) is fully supported (:pull:`145`).

v2.12.0 (2023-10-11)
====================
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Information Analysis",
]
Expand Down Expand Up @@ -88,6 +89,7 @@ markers = [

[tool.ruff]
select = ["C9", "E", "F", "I", "W"]
ignore = ["E501", "W191"]

[tool.ruff.mccabe]
# Exceptions:
Expand Down
20 changes: 8 additions & 12 deletions sdmx/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import importlib
from distutils import version
from typing import Optional, Tuple

import pytest
from packaging.version import Version


# thanks to xarray
def _importorskip(modname, minversion=None):
def _importorskip(
modname: str, minversion: Optional[str] = None
) -> Tuple[bool, pytest.MarkDecorator]:
try:
mod = importlib.import_module(modname)
has = True
if minversion is not None:
if LooseVersion(mod.__version__) < LooseVersion(minversion):
if minversion is not None: # pragma: no cover
if Version(mod.__version__) < Version(minversion):
raise ImportError("Minimum version not satisfied")
except ImportError:
has = False
func = pytest.mark.skipif(not has, reason="requires {}".format(modname))
func = pytest.mark.skipif(not has, reason=f"requires {modname}")
return has, func


def LooseVersion(vstring):
# When the development version is something like '0.10.9+aac7bfc', this
# function will just discard the git commit id.
vstring = vstring.split("+")[0]
return version.LooseVersion(vstring)


has_requests_cache, requires_requests_cache = _importorskip("requests_cache")
3 changes: 1 addition & 2 deletions sdmx/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

@pytest.mark.skipif(has_requests_cache, reason="test without requests_cache")
def test_session_without_requests_cache(): # pragma: no cover
# Passing cache= arguments when requests_cache is not installed triggers a
# warning
# Passing cache= arguments when requests_cache is not installed triggers a warning
with pytest.warns(RuntimeWarning):
Session(cache_name="test")

Expand Down
3 changes: 2 additions & 1 deletion sdmx/writer/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ def write_dataset(

# NB mypy errors here on CI, but not locally
result: Union[pd.Series, pd.DataFrame] = pd.DataFrame.from_dict(
data, orient="index" # type: ignore [arg-type]
data,
orient="index", # type: ignore [arg-type]
)

if len(result):
Expand Down

0 comments on commit c28f50a

Please sign in to comment.