From 5b964aed7db1368cc203fbfcb618b655cb2177b1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:39:52 +0100 Subject: [PATCH 01/21] Fix GitHub Release workflow --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index df853e7..857607f 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -80,7 +80,7 @@ jobs: id: get_version uses: actions/github-script@v6 with: - script: core.setOutput('version', context.ref.replace("refs/tags/v", "")) + script: core.setOutput('version', context.ref.replace("refs/tags/", "")) - name: Create GitHub release uses: softprops/action-gh-release@v1 From 010ed5629dd70e77c6df7cf753e6c93270254811 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:02:57 +0100 Subject: [PATCH 02/21] Test Sphinx's master branch distinctly from ordinary tests --- .github/workflows/test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 082f9ee..c459016 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,23 @@ jobs: if: "endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install .[test] + + - name: Test with pytest + run: python -m pytest --durations 25 + + test-latest-sphinx: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: "3" - name: Install dependencies run: | python -m pip install --upgrade pip From 5c00ac15e2ade99e99f36402b1f6befb1be1affa Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:08:03 +0100 Subject: [PATCH 03/21] Run pytest with ``-vv`` --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c459016..794d170 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,7 @@ jobs: python -m pip install .[test] - name: Test with pytest - run: python -m pytest --durations 25 + run: python -m pytest -vv --durations 25 test-latest-sphinx: runs-on: ubuntu-latest @@ -65,7 +65,7 @@ jobs: python -m pip install "Sphinx @ git+https://github.com/sphinx-doc/sphinx" - name: Test with pytest - run: python -m pytest --durations 25 + run: python -m pytest -vv --durations 25 lint: runs-on: ubuntu-latest From 4ba0bbc9cd166a2512d7e3a502fa8159f3669685 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 17:16:32 +0100 Subject: [PATCH 04/21] Restore support in tests for ``Sphinx<7.2`` --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index bad18f1..d4b08e5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,9 +2,16 @@ import pytest +import sphinx + pytest_plugins = 'sphinx.testing.fixtures' @pytest.fixture(scope='session') def rootdir(): + if sphinx.version_info[:2] < (7, 2): + from sphinx.testing.path import path + + return path(__file__).parent.abspath() / 'roots' + return Path(__file__).resolve().parent / 'roots' From 957d087692515b6cdd918ebd0c99591b7d04f76f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:11:29 +0100 Subject: [PATCH 05/21] Bump to 1.1.7 final --- CHANGES | 5 +++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 0c534dc..405ed78 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Release 1.1.7 (2023-08-09) +========================== + +* Fix tests for Sphinx 7.1 and below + Release 1.1.6 (2023-08-07) ========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 6f2c8b8..6a0b54e 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.6' -__version_info__ = (1, 1, 6) +__version__ = '1.1.7' +__version_info__ = (1, 1, 7) package_dir = path.abspath(path.dirname(__file__)) From b3ed89b4b2bf9eee553ff2272ae97fc5c0a9bc31 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:42:11 +0100 Subject: [PATCH 06/21] Use ``os.PathLike`` over ``pathlib.Path`` Sphinx 7.1 and earlier don't use ``pathlib`` internally. --- sphinxcontrib/serializinghtml/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 6a0b54e..26a5386 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -102,7 +102,7 @@ def handle_page(self, pagename: str, ctx: dict, templatename: str = 'page.html', def handle_finish(self) -> None: # dump the global context - outfilename = self.outdir / self.globalcontext_filename + outfilename = path.join(self.outdir, self.globalcontext_filename) self.dump_context(self.globalcontext, outfilename) # super here to dump the search index From fde139af6b2bfad8a6b8d20886b657a174f05c22 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:09:41 +0100 Subject: [PATCH 07/21] Bump to 1.1.8 final --- CHANGES | 5 +++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 405ed78..812c0fc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Release 1.1.8 (2023-08-14) +========================== + +* Use ``os.PathLike`` over ``pathlib.Path`` + Release 1.1.7 (2023-08-09) ========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 26a5386..99b6fb9 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.7' -__version_info__ = (1, 1, 7) +__version__ = '1.1.8' +__version_info__ = (1, 1, 8) package_dir = path.abspath(path.dirname(__file__)) From 5c62ad4219698d410426e99495203e9484d77f29 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 21 Aug 2023 00:20:10 +0100 Subject: [PATCH 08/21] Properly serialise css_files and script_files --- sphinxcontrib/serializinghtml/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 99b6fb9..22836e8 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -63,6 +63,11 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str: return docname + SEP def dump_context(self, context: dict, filename: str | os.PathLike[str]) -> None: + context = context.copy() + if 'css_files' in context: + context['css_files'] = [css.filename for css in context['css_files']] + if 'script_files' in context: + context['script_files'] = [js.filename for js in context['script_files']] if self.implementation_dumps_unicode: with open(filename, 'w', encoding='utf-8') as ft: self.implementation.dump(context, ft, *self.additional_dump_args) From ff4bcae545fb6e5b923cc51cc37944c18307a49a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 21 Aug 2023 00:26:37 +0100 Subject: [PATCH 09/21] Bump to 1.1.9 final --- CHANGES | 6 ++++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 812c0fc..c91fed7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Release 1.1.9 (2023-08-20) +========================== + +* Serialise context["script_files"] and context["css_files"] as their filenames + on Sphinx 7.2.0. + Release 1.1.8 (2023-08-14) ========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 22836e8..8940d80 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.8' -__version_info__ = (1, 1, 8) +__version__ = '1.1.9' +__version_info__ = (1, 1, 9) package_dir = path.abspath(path.dirname(__file__)) From f0b76043a49e8969be1f0bfed7ad5636d7361e3c Mon Sep 17 00:00:00 2001 From: phlax Date: Sat, 13 Jan 2024 02:35:03 +0000 Subject: [PATCH 10/21] Remove Sphinx as a required dependency (#10) Signed-off-by: Ryan Northey Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- CHANGES | 7 +++++++ pyproject.toml | 7 ++++--- sphinxcontrib/serializinghtml/__init__.py | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 794d170..8cd7db1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install .[test] + python -m pip install .[test,standalone] - name: Test with pytest run: python -m pytest -vv --durations 25 diff --git a/CHANGES b/CHANGES index c91fed7..48c08f4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Release 1.1.10 (unreleased) +=========================== + +* Remove Sphinx as a required dependency, as circular dependencies may cause + failure with package managers that expect a directed acyclic graph (DAG) + of dependencies. + Release 1.1.9 (2023-08-20) ========================== diff --git a/pyproject.toml b/pyproject.toml index 8c39008..7f88862 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,9 +40,7 @@ classifiers = [ "Topic :: Text Processing", "Topic :: Utilities", ] -dependencies = [ - "Sphinx>=5", -] +dependencies = [] dynamic = ["version"] [project.optional-dependencies] @@ -54,6 +52,9 @@ lint = [ "mypy", "docutils-stubs", ] +standalone = [ + "Sphinx>=5", +] [[project.authors]] name = "Georg Brandl" diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 8940d80..815705c 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -157,6 +157,7 @@ class JSONHTMLBuilder(SerializingHTMLBuilder): def setup(app: Sphinx) -> dict[str, Any]: + app.require_sphinx('5.0') app.setup_extension('sphinx.builders.html') app.add_builder(JSONHTMLBuilder) app.add_builder(PickleHTMLBuilder) From 941e0e81da47efad9509cc7df3eff44f40de43c2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 13 Jan 2024 02:48:14 +0000 Subject: [PATCH 11/21] Bump to 1.0.10 final --- CHANGES | 2 +- sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 48c08f4..98dbc74 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -Release 1.1.10 (unreleased) +Release 1.1.10 (2024-01-13) =========================== * Remove Sphinx as a required dependency, as circular dependencies may cause diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 815705c..11301c4 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -13,8 +13,8 @@ from sphinxcontrib.serializinghtml import jsonimpl -__version__ = '1.1.9' -__version_info__ = (1, 1, 9) +__version__ = '1.1.10' +__version_info__ = (1, 1, 10) package_dir = path.abspath(path.dirname(__file__)) From 3161d4768bcf16f9c372fb733b70399131824cc8 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sat, 27 Jul 2024 18:38:36 +0100 Subject: [PATCH 12/21] Update .gitignore --- .gitignore | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6101a7b..10cef94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,17 @@ *.pyc -*.egg -*.so -*.swp .DS_Store +idea/ +.vscode/ + .mypy_cache/ +.pytest_cache/ +.ruff_cache/ .tags .tox/ +.venv/ +venv/ + build/ dist/ -sphinxcontrib_serializinghtml.egg-info/ From c7a1ca2154a17d8350186bb5ac384c613471e4ee Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 05:02:26 +0100 Subject: [PATCH 13/21] Adopt Ruff and use stricter MyPy settings --- .flake8 | 4 -- .github/workflows/test.yml | 4 +- .ruff.toml | 53 +++++++++++++++++++++++ Makefile | 2 +- pyproject.toml | 36 +++++++++++++-- sphinxcontrib/serializinghtml/__init__.py | 24 +++++++--- sphinxcontrib/serializinghtml/jsonimpl.py | 6 +-- sphinxcontrib/serializinghtml/py.typed | 0 tests/conftest.py | 15 +++---- tests/test_serializinghtml.py | 11 ++++- tox.ini | 6 +-- 11 files changed, 128 insertions(+), 33 deletions(-) delete mode 100644 .flake8 create mode 100644 .ruff.toml create mode 100644 sphinxcontrib/serializinghtml/py.typed diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 5af0a95..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max-line-length = 95 -ignore = E116,E241,E251 -exclude = .git,.tox,.venv diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8cd7db1..856df5b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,7 +71,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - env: [flake8, mypy] + env: + - ruff + - mypy steps: - uses: actions/checkout@v3 diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..4b7dd2a --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,53 @@ +target-version = "py39" # Pin Ruff to Python 3.9 +output-format = "full" +line-length = 95 + +[lint] +preview = true +select = [ +# "ANN", # flake8-annotations + "C4", # flake8-comprehensions + "COM", # flake8-commas + "B", # flake8-bugbear + "DTZ", # flake8-datetimez + "E", # pycodestyle + "EM", # flake8-errmsg + "EXE", # flake8-executable + "F", # pyflakes + "FA", # flake8-future-annotations + "FLY", # flynt + "FURB", # refurb + "G", # flake8-logging-format + "I", # isort + "ICN", # flake8-import-conventions + "INT", # flake8-gettext + "LOG", # flake8-logging + "PERF", # perflint + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PT", # flake8-pytest-style + "SIM", # flake8-simplify + "SLOT", # flake8-slots + "TCH", # flake8-type-checking + "UP", # pyupgrade + "W", # pycodestyle + "YTT", # flake8-2020 +] +ignore = [ + "E116", + "E241", + "E251", +] + +[lint.per-file-ignores] +"tests/*" = [ + "ANN", # tests don't need annotations +] + +[lint.isort] +forced-separate = [ + "tests", +] +required-imports = [ + "from __future__ import annotations", +] diff --git a/Makefile b/Makefile index 26f411a..438ee54 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ clean-mypyfiles: .PHONY: style-check style-check: - @flake8 + @ruff check .PHONY: type-check type-check: diff --git a/pyproject.toml b/pyproject.toml index 7f88862..27d3008 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,9 +48,9 @@ test = [ "pytest", ] lint = [ - "flake8", + "ruff==0.5.5", "mypy", - "docutils-stubs", + "types-docutils", ] standalone = [ "Sphinx>=5", @@ -76,4 +76,34 @@ exclude = [ ] [tool.mypy] -ignore_missing_imports = true +python_version = "3.9" +packages = [ + "sphinxcontrib", + "tests", +] +exclude = [ + "tests/roots", +] +check_untyped_defs = true +disallow_any_generics = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +explicit_package_bases = true +extra_checks = true +no_implicit_reexport = true +show_column_numbers = true +show_error_context = true +strict_optional = true +warn_redundant_casts = true +warn_unused_configs = true +warn_unused_ignores = true +enable_error_code = [ + "type-arg", + "redundant-self", + "truthy-iterable", + "ignore-without-code", + "unused-awaitable", +] diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index 11301c4..ee41019 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -4,7 +4,7 @@ import pickle import types from os import path -from typing import Any +from typing import TYPE_CHECKING from sphinx.application import ENV_PICKLE_FILENAME, Sphinx from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder @@ -13,6 +13,16 @@ from sphinxcontrib.serializinghtml import jsonimpl +if TYPE_CHECKING: + from collections.abc import Sequence + from typing import Any, Protocol + + class SerialisingImplementation(Protocol): + def dump(self, obj: Any, file: Any, *args: Any, **kwargs: Any) -> None: ... + def dumps(self, obj: Any, *args: Any, **kwargs: Any) -> str | bytes: ... + def load(self, file: Any, *args: Any, **kwargs: Any) -> Any: ... + def loads(self, data: Any, *args: Any, **kwargs: Any) -> Any: ... + __version__ = '1.1.10' __version_info__ = (1, 1, 10) @@ -31,11 +41,11 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder): """ #: the serializing implementation to use. Set this to a module that #: implements a `dump`, `load`, `dumps` and `loads` functions - #: (pickle, simplejson etc.) - implementation: Any = None + #: (pickle, json etc.) + implementation: SerialisingImplementation implementation_dumps_unicode = False #: additional arguments for dump() - additional_dump_args: tuple = () + additional_dump_args: Sequence[Any] = () #: the filename for the global context file globalcontext_filename: str = '' @@ -62,7 +72,7 @@ def get_target_uri(self, docname: str, typ: str | None = None) -> str: return docname[:-5] # up to sep return docname + SEP - def dump_context(self, context: dict, filename: str | os.PathLike[str]) -> None: + def dump_context(self, context: dict[str, Any], filename: str | os.PathLike[str]) -> None: context = context.copy() if 'css_files' in context: context['css_files'] = [css.filename for css in context['css_files']] @@ -75,7 +85,7 @@ def dump_context(self, context: dict, filename: str | os.PathLike[str]) -> None: with open(filename, 'wb') as fb: self.implementation.dump(context, fb, *self.additional_dump_args) - def handle_page(self, pagename: str, ctx: dict, templatename: str = 'page.html', + def handle_page(self, pagename: str, ctx: dict[str, Any], templatename: str = 'page.html', outfilename: str | None = None, event_arg: Any = None) -> None: ctx['current_page_name'] = pagename ctx.setdefault('pathto', lambda p: p) @@ -132,7 +142,7 @@ class PickleHTMLBuilder(SerializingHTMLBuilder): implementation = pickle implementation_dumps_unicode = False - additional_dump_args = (pickle.HIGHEST_PROTOCOL,) + additional_dump_args: tuple[Any] = (pickle.HIGHEST_PROTOCOL,) indexer_format = pickle indexer_dumps_unicode = False out_suffix = '.fpickle' diff --git a/sphinxcontrib/serializinghtml/jsonimpl.py b/sphinxcontrib/serializinghtml/jsonimpl.py index e80c047..9b89875 100644 --- a/sphinxcontrib/serializinghtml/jsonimpl.py +++ b/sphinxcontrib/serializinghtml/jsonimpl.py @@ -4,7 +4,7 @@ import json from collections import UserString -from typing import Any, IO +from typing import IO, Any class SphinxJSONEncoder(json.JSONEncoder): @@ -15,9 +15,9 @@ def default(self, obj: Any) -> str: return super().default(obj) -def dump(obj: Any, fp: IO, *args: Any, **kwds: Any) -> None: +def dump(obj: Any, file: IO[str] | IO[bytes], *args: Any, **kwds: Any) -> None: kwds['cls'] = SphinxJSONEncoder - json.dump(obj, fp, *args, **kwds) + json.dump(obj, file, *args, **kwds) def dumps(obj: Any, *args: Any, **kwds: Any) -> str: diff --git a/sphinxcontrib/serializinghtml/py.typed b/sphinxcontrib/serializinghtml/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py index d4b08e5..3934d3f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,17 +1,14 @@ +from __future__ import annotations + from pathlib import Path import pytest -import sphinx - -pytest_plugins = 'sphinx.testing.fixtures' +pytest_plugins = ( + 'sphinx.testing.fixtures', +) @pytest.fixture(scope='session') -def rootdir(): - if sphinx.version_info[:2] < (7, 2): - from sphinx.testing.path import path - - return path(__file__).parent.abspath() / 'roots' - +def rootdir() -> Path: return Path(__file__).resolve().parent / 'roots' diff --git a/tests/test_serializinghtml.py b/tests/test_serializinghtml.py index b6f6380..480930b 100644 --- a/tests/test_serializinghtml.py +++ b/tests/test_serializinghtml.py @@ -1,13 +1,20 @@ """Test for serializinghtml extension.""" +from __future__ import annotations + +from typing import TYPE_CHECKING + import pytest +if TYPE_CHECKING: + from sphinx.application import Sphinx + @pytest.mark.sphinx('json', testroot='basic') -def test_json(app, status, warning): +def test_json(app: Sphinx) -> None: app.builder.build_all() @pytest.mark.sphinx('pickle', testroot='basic') -def test_pickle(app, status, warning): +def test_pickle(app: Sphinx) -> None: app.builder.build_all() diff --git a/tox.ini b/tox.ini index 9ad9f73..233022d 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ minversion = 2.4.0 envlist = py{39,310,311,312,313}, - flake8, + ruff, mypy isolated_build = True @@ -18,14 +18,14 @@ setenv = commands= pytest --durations 25 {posargs} -[testenv:flake8] +[testenv:ruff] description = Run style checks. extras = test lint commands= - flake8 + ruff check [testenv:mypy] description = From f2d1ab5fdae23df21fe1db3fc0918d98c3b1bef5 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 05:04:34 +0100 Subject: [PATCH 14/21] Enable GitHub's dependabot package update service --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..47a31bc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" From 3efe6adde58b86b772b35d62d561d2c3efa2a6f4 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 05:13:51 +0100 Subject: [PATCH 15/21] Use the latest GitHub actions versions --- .github/workflows/create-release.yml | 12 ++++++------ .github/workflows/test.yml | 14 +++++++------- .github/{ => workflows}/transifex.yml | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) rename .github/{ => workflows}/transifex.yml (92%) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 857607f..6d19bbb 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -17,9 +17,9 @@ jobs: permissions: id-token: write # for PyPI trusted publishing steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3 cache: pip @@ -35,7 +35,7 @@ jobs: - name: Mint PyPI API token id: mint-token - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: # language=JavaScript script: | @@ -75,15 +75,15 @@ jobs: permissions: contents: write # for softprops/action-gh-release to create GitHub release steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Get release version id: get_version - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: core.setOutput('version', context.ref.replace("refs/tags/", "")) - name: Create GitHub release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: name: "sphinxcontrib-serializinghtml ${{ steps.get_version.outputs.version }}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 856df5b..4586b92 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,14 +30,14 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 if: "!endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} - name: Set up Python ${{ matrix.python }} (deadsnakes) - uses: deadsnakes/action@v2.1.1 + uses: deadsnakes/action@v3.1.0 if: "endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} @@ -53,9 +53,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3" - name: Install dependencies @@ -76,9 +76,9 @@ jobs: - mypy steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3" diff --git a/.github/transifex.yml b/.github/workflows/transifex.yml similarity index 92% rename from .github/transifex.yml rename to .github/workflows/transifex.yml index b0427ac..fbfba9a 100644 --- a/.github/transifex.yml +++ b/.github/workflows/transifex.yml @@ -15,9 +15,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3 - name: Install transifex client @@ -44,9 +44,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3 - name: Install transifex client @@ -67,7 +67,7 @@ jobs: - name: Compile message catalogs run: python utils/babel_runner.py compile - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request@v6 with: commit-message: "[internationalisation] Update translations" branch: bot/pull-translations From 5762a0e58de31f71744e97f1b82c02d64e2cc14f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:31:09 +0100 Subject: [PATCH 16/21] Run mypy without command-line options --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 233022d..3198abf 100644 --- a/tox.ini +++ b/tox.ini @@ -34,4 +34,4 @@ extras = test lint commands= - mypy sphinxcontrib/ --explicit-package-bases + mypy From 85cbe329a7775c70631ca5a55f361e4d80bfb019 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:38:15 +0100 Subject: [PATCH 17/21] Run CI with Python 3.12 releases --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4586b92..e337f0f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: - "3.9" - "3.10" - "3.11" - - "3.12-dev" + - "3.12" - "3.13-dev" fail-fast: false @@ -44,7 +44,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install .[test,standalone] + python -m pip install .[standalone,test] - name: Test with pytest run: python -m pytest -vv --durations 25 From 4806eec58dc8868888b36486b8493cb3a2682a26 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:48:20 +0100 Subject: [PATCH 18/21] Rename CHANGES to CHANGES.rst --- CHANGES => CHANGES.rst | 0 pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename CHANGES => CHANGES.rst (100%) diff --git a/CHANGES b/CHANGES.rst similarity index 100% rename from CHANGES rename to CHANGES.rst diff --git a/pyproject.toml b/pyproject.toml index 27d3008..bbc7b49 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ name = "sphinxcontrib.serializinghtml" [tool.flit.sdist] include = [ - "CHANGES", + "CHANGES.rst", "LICENSE", # Tests "tests/", From a3d1b70c68edbad003a4f4156dde49f314c505b3 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:00:41 +0100 Subject: [PATCH 19/21] Rename LICENSE to LICENCE.rst --- LICENSE => LICENCE.rst | 0 pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename LICENSE => LICENCE.rst (100%) diff --git a/LICENSE b/LICENCE.rst similarity index 100% rename from LICENSE rename to LICENCE.rst diff --git a/pyproject.toml b/pyproject.toml index bbc7b49..e5f4447 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ name = "sphinxcontrib.serializinghtml" [tool.flit.sdist] include = [ "CHANGES.rst", - "LICENSE", + "LICENCE.rst", # Tests "tests/", "tox.ini", From b70697cd8825afe2f3a9ce9a8c207cc1b6037ee2 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Sun, 28 Jul 2024 19:32:58 +0100 Subject: [PATCH 20/21] Update CHANGES links --- .github/workflows/create-release.yml | 2 +- pyproject.toml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 6d19bbb..fa90c2b 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -87,4 +87,4 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: name: "sphinxcontrib-serializinghtml ${{ steps.get_version.outputs.version }}" - body: "Changelog: https://www.sphinx-doc.org/en/master/changes.html" + body: "Changelog: https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/blob/master/CHANGES.rst" diff --git a/pyproject.toml b/pyproject.toml index e5f4447..f14054e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,11 +8,11 @@ name = "sphinxcontrib-serializinghtml" description = """sphinxcontrib-serializinghtml is a sphinx extension which \ outputs "serialized" HTML files (json and pickle)""" readme = "README.rst" -urls.Changelog = "https://www.sphinx-doc.org/en/master/changes.html" -urls.Code = "https://github.com/sphinx-doc/sphinxcontrib-serializinghtml" +urls.Changelog = "https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/blob/master/CHANGES.rst" +urls.Code = "https://github.com/sphinx-doc/sphinxcontrib-serializinghtml/" urls.Download = "https://pypi.org/project/sphinxcontrib-serializinghtml/" urls.Homepage = "https://www.sphinx-doc.org/" -urls."Issue tracker" = "https://github.com/sphinx-doc/sphinx/issues" +urls."Issue tracker" = "https://github.com/sphinx-doc/sphinx/issues/" license.text = "BSD-2-Clause" requires-python = ">=3.9" From f0f3b15b2e6bb47570d605ebd5687643d7a85b9d Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 29 Jul 2024 01:52:17 +0100 Subject: [PATCH 21/21] Bump to 2.0.0 --- CHANGES.rst | 7 +++++++ sphinxcontrib/serializinghtml/__init__.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 98dbc74..6425c1e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +Release 2.0.0 (2024-07-28) +========================== + +* Adopt Ruff +* Tighten MyPy settings +* Update GitHub actions versions + Release 1.1.10 (2024-01-13) =========================== diff --git a/sphinxcontrib/serializinghtml/__init__.py b/sphinxcontrib/serializinghtml/__init__.py index ee41019..bdbeb6f 100644 --- a/sphinxcontrib/serializinghtml/__init__.py +++ b/sphinxcontrib/serializinghtml/__init__.py @@ -23,8 +23,8 @@ def dumps(self, obj: Any, *args: Any, **kwargs: Any) -> str | bytes: ... def load(self, file: Any, *args: Any, **kwargs: Any) -> Any: ... def loads(self, data: Any, *args: Any, **kwargs: Any) -> Any: ... -__version__ = '1.1.10' -__version_info__ = (1, 1, 10) +__version__ = '2.0.0' +__version_info__ = (2, 0, 0) package_dir = path.abspath(path.dirname(__file__))