From 91d5a7ea8090d440662b2d00bdbbaa6feb3a565f Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Sun, 29 Oct 2023 21:33:12 +0000 Subject: [PATCH] chore: bump dependencies (#97) Co-authored-by: Bizordec --- .github/dependabot.yml | 7 +++++++ .github/workflows/tests.yml | 36 +++++++++++---------------------- .pre-commit-config.yaml | 2 +- .readthedocs.yml | 6 +++++- pyproject.toml | 16 +++++++-------- sphinx_external_toc/__init__.py | 2 +- tests/conftest.py | 31 ++++++++++++++++++++++++++++ tests/test_sphinx.py | 13 ++++++++++-- tox.ini | 4 ++-- 9 files changed, 78 insertions(+), 39 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6fddca0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e37b71a..639d2f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,35 +12,23 @@ on: jobs: - pre-commit: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - uses: pre-commit/action@v2.0.0 - tests: strategy: fail-fast: false matrix: os: [ubuntu-latest] - python-version: [3.7, 3.8, 3.9, "3.10"] + python-version: ["3.9", "3.10", "3.11", "3.12"] include: - os: windows-latest - python-version: 3.8 + python-version: 3.9 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -51,27 +39,27 @@ jobs: run: | pytest --cov=sphinx_external_toc --cov-report=xml --cov-report=term-missing - name: Upload to Codecov - if: matrix.python-version == 3.8 - uses: codecov/codecov-action@v1 + if: matrix.python-version == 3.11 + uses: codecov/codecov-action@v3 with: - name: pytests-py3.8 + name: pytests-py3.11 flags: pytests file: ./coverage.xml fail_ci_if_error: true publish: - name: Publish to PyPi - needs: [pre-commit, tests] + name: Publish to PyPI + needs: [tests] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.11 - name: install flit run: | pip install flit~=3.4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 75d3ff0..dd29ea5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort diff --git a/.readthedocs.yml b/.readthedocs.yml index a2bb886..22ecdd7 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,7 +1,11 @@ version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.11" + python: - version: 3 install: - method: pip path: . diff --git a/pyproject.toml b/pyproject.toml index 0e361d1..b7ba5f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,20 +15,20 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "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", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup", ] keywords = ["sphinx","extension", "toc"] -requires-python = "~=3.7" +requires-python = ">=3.9" dependencies = [ - "click>=7.1,<9", + "click>=7.1", "pyyaml", - "sphinx>=4,<6", + "sphinx>=5", ] [project.urls] @@ -39,14 +39,14 @@ Documentation = "https://sphinx-external-toc.readthedocs.io" "jb.cmdline" = {toc = "sphinx_external_toc.cli:main"} [project.optional-dependencies] -code_style = ["pre-commit~=2.12"] +code_style = ["pre-commit>=2.12"] rtd = [ - "myst-parser~=0.17.0", + "myst-parser>=1.0.0", "sphinx-book-theme>=0.0.36", ] testing = [ "coverage", - "pytest~=7.1", + "pytest>=7.1", "pytest-cov", "pytest-regressions", ] diff --git a/sphinx_external_toc/__init__.py b/sphinx_external_toc/__init__.py index b4c2fc9..2011964 100644 --- a/sphinx_external_toc/__init__.py +++ b/sphinx_external_toc/__init__.py @@ -1,6 +1,6 @@ """A sphinx extension that allows the project toctree to be defined in a single file.""" -__version__ = "0.3.1" +__version__ = "1.0.0rc0" from typing import TYPE_CHECKING diff --git a/tests/conftest.py b/tests/conftest.py index 970578a..3de3fe6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1 +1,32 @@ +import re + +import pytest + pytest_plugins = "sphinx.testing.fixtures" + + +# comparison files will need updating +# alternatively the resolution of https://github.com/ESSS/pytest-regressions/issues/32 +@pytest.fixture() +def file_regression(file_regression): + return FileRegression(file_regression) + + +class FileRegression: + ignores = ( + # TODO: Remove when support for Sphinx<=6 is dropped, + re.escape(" translation_progress=\"{'total': 0, 'translated': 0}\""), + # TODO: Remove when support for Sphinx<7.2 is dropped, + r"original_uri=\"[^\"]*\"\s", + ) + + def __init__(self, file_regression): + self.file_regression = file_regression + + def check(self, data, **kwargs): + return self.file_regression.check(self._strip_ignores(data), **kwargs) + + def _strip_ignores(self, data): + for ig in self.ignores: + data = re.sub(ig, "", data) + return data diff --git a/tests/test_sphinx.py b/tests/test_sphinx.py index e88884f..b89069a 100644 --- a/tests/test_sphinx.py +++ b/tests/test_sphinx.py @@ -2,7 +2,7 @@ from pathlib import Path import pytest -from sphinx.testing.path import path as sphinx_path +from sphinx import version_info as sphinx_version_info from sphinx.testing.util import SphinxTestApp from sphinx_external_toc.tools import create_site_from_toc @@ -47,7 +47,16 @@ def outdir(self): @pytest.fixture() def sphinx_build_factory(make_app): def _func(src_path: Path, **kwargs) -> SphinxBuild: - app = make_app(srcdir=sphinx_path(os.path.abspath(str(src_path))), **kwargs) + # For compatibility with multiple versions of sphinx, convert pathlib.Path to + # sphinx.testing.path.path here. + if sphinx_version_info >= (7, 2): + app_srcdir = src_path + else: + from sphinx.testing.path import path + + app_srcdir = path(os.fspath(src_path)) + + app = make_app(srcdir=app_srcdir, **kwargs) return SphinxBuild(app, src_path) yield _func diff --git a/tox.ini b/tox.ini index 0487cc5..8446b72 100644 --- a/tox.ini +++ b/tox.ini @@ -4,12 +4,12 @@ # then run `tox` or `tox -- {pytest args}` # run in parallel using `tox -p` [tox] -envlist = py38 +envlist = py310 [testenv] usedevelop = true -[testenv:py{36,37,38,39}] +[testenv:py{39,310,311,312}] extras = testing commands = pytest {posargs}