From d9440398976ad305697527fb5e27d8c3b5869fb7 Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Thu, 3 Apr 2025 13:52:07 +0200 Subject: [PATCH 1/3] Annotate the list of strings correctly for Sphinx 8.2+ This also works with an older Sphinx, tested on 8.1.3. --- sphinxcontrib/apidoc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinxcontrib/apidoc/__init__.py b/sphinxcontrib/apidoc/__init__.py index a91570a..1e7c260 100644 --- a/sphinxcontrib/apidoc/__init__.py +++ b/sphinxcontrib/apidoc/__init__.py @@ -24,7 +24,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: app.add_config_value('apidoc_module_dir', None, 'env', [str]) app.add_config_value('apidoc_output_dir', 'api', 'env', [str]) app.add_config_value('apidoc_template_dir', 'templates', 'env', [str]) - app.add_config_value('apidoc_excluded_paths', [], 'env', [[str]]) + app.add_config_value('apidoc_excluded_paths', [], 'env', list[str]) app.add_config_value('apidoc_separate_modules', False, 'env', [bool]) app.add_config_value('apidoc_toc_file', None, 'env', [str, bool]) app.add_config_value('apidoc_module_first', False, 'env', [bool]) From e6b3e720e4ce5d721411b75c3a65c26aa254e2d5 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 8 May 2025 13:36:55 +0100 Subject: [PATCH 2/3] Drop Python < 3.9 support Signed-off-by: Stephen Finucane --- .github/workflows/ci.yaml | 10 +++++----- pyproject.toml | 2 +- setup.cfg | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8ff15ed..c33bd20 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,10 +10,10 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v3 - - name: Set up Python 3.11 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.13" - name: Install dependencies run: python -m pip install tox - name: Run tox @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout source code uses: actions/checkout@v3 @@ -52,10 +52,10 @@ jobs: # We need history to build the package with: fetch-depth: 0 - - name: Set up Python 3.11 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: "3.11" + python-version: "3.13" - name: Install dependencies run: python -m pip install build - name: Build a binary wheel and a source tarball diff --git a/pyproject.toml b/pyproject.toml index ceb090e..6be945b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 88 -target-version = ['py38'] +target-version = ['py39'] skip-string-normalization = true exclude = ''' ( diff --git a/setup.cfg b/setup.cfg index 115a992..8b4ea91 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,7 +24,7 @@ classifiers = Topic :: Documentation Topic :: Documentation :: Sphinx Topic :: Utilities -python_requires = >=3.8 +python_requires = >=3.9 keywords = sphinx [files] From c264fa93726eb6894283225902839d8bd0f4aeff Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 8 May 2025 13:38:07 +0100 Subject: [PATCH 3/3] pre-commit: Bump versions, migrate to ruff Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 19 +++++++------------ pyproject.toml | 21 ++++++--------------- sphinxcontrib/__init__.py | 12 ++++++------ sphinxcontrib/apidoc/__init__.py | 10 +++++----- sphinxcontrib/apidoc/ext.py | 14 ++++++-------- tests/conftest.py | 8 ++++---- tests/test_ext.py | 10 +++++----- 7 files changed, 39 insertions(+), 55 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4502ab3..20b1031 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,9 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks --- -default_language_version: - # force all unspecified python hooks to run python3 - python: python3 repos: - - repo: https://github.com/ambv/black - rev: 23.7.0 - hooks: - - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: mixed-line-ending @@ -23,12 +16,14 @@ repos: - id: check-yaml files: .*\.(yaml|yml)$ - id: check-added-large-files - - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.8 hooks: - - id: flake8 + - id: ruff + args: ['--fix', '--unsafe-fixes'] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.15.0 hooks: - id: mypy additional_dependencies: diff --git a/pyproject.toml b/pyproject.toml index 6be945b..d60159d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,7 @@ -[tool.black] +[tool.ruff] line-length = 88 -target-version = ['py39'] -skip-string-normalization = true -exclude = ''' -( - /( - \.eggs - | \.git - | \.tox - | \.venv - | build - | dist - ) -) -''' +target-version = 'py39' + +[tool.ruff.format] +quote-style = "preserve" +docstring-code-format = true diff --git a/sphinxcontrib/__init__.py b/sphinxcontrib/__init__.py index ae0f862..f063f5d 100644 --- a/sphinxcontrib/__init__.py +++ b/sphinxcontrib/__init__.py @@ -1,12 +1,12 @@ """ - sphinxcontrib - ~~~~~~~~~~~~~ +sphinxcontrib +~~~~~~~~~~~~~ - This package is a namespace package that contains all extensions - distributed in the ``sphinx-contrib`` distribution. +This package is a namespace package that contains all extensions +distributed in the ``sphinx-contrib`` distribution. - :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. +:copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. +:license: BSD, see LICENSE for details. """ __import__('pkg_resources').declare_namespace(__name__) diff --git a/sphinxcontrib/apidoc/__init__.py b/sphinxcontrib/apidoc/__init__.py index 1e7c260..68a7130 100644 --- a/sphinxcontrib/apidoc/__init__.py +++ b/sphinxcontrib/apidoc/__init__.py @@ -1,11 +1,11 @@ """ - sphinxcontrib.apidoc - ~~~~~~~~~~~~~~~~~~~~ +sphinxcontrib.apidoc +~~~~~~~~~~~~~~~~~~~~ - A Sphinx extension for running 'sphinx-apidoc' on each build. +A Sphinx extension for running 'sphinx-apidoc' on each build. - :copyright: Copyright 2018-present by Stephen Finucane - :license: BSD, see LICENSE for details. +:copyright: Copyright 2018-present by Stephen Finucane +:license: BSD, see LICENSE for details. """ import pbr.version diff --git a/sphinxcontrib/apidoc/ext.py b/sphinxcontrib/apidoc/ext.py index cb720ed..508aa38 100644 --- a/sphinxcontrib/apidoc/ext.py +++ b/sphinxcontrib/apidoc/ext.py @@ -1,11 +1,11 @@ """ - sphinxcontrib.apidoc.ext - ~~~~~~~~~~~~~~~~~~~~~~~~ +sphinxcontrib.apidoc.ext +~~~~~~~~~~~~~~~~~~~~~~~~ - A Sphinx extension for running 'sphinx-apidoc' on each build. +A Sphinx extension for running 'sphinx-apidoc' on each build. - :copyright: Copyright 2018-present by Stephen Finucane - :license: BSD, see LICENSE for details. +:copyright: Copyright 2018-present by Stephen Finucane +:license: BSD, see LICENSE for details. """ from os import path @@ -28,9 +28,7 @@ def builder_inited(app: Sphinx) -> None: extra_args = app.config.apidoc_extra_args if not module_dir: - logger.warning( - "No 'apidoc_module_dir' specified; skipping API doc " "generation" - ) + logger.warning("No 'apidoc_module_dir' specified; skipping API doc generation") return # if the path is relative, make it relative to the 'conf.py' directory diff --git a/tests/conftest.py b/tests/conftest.py index 88d69de..5d753fe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,9 @@ """ - pytest config for sphinxcontrib/apidoc/tests - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +pytest config for sphinxcontrib/apidoc/tests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :copyright: Copyright 2018-present by Stephen Finucane - :license: BSD, see LICENSE for details. +:copyright: Copyright 2018-present by Stephen Finucane +:license: BSD, see LICENSE for details. """ import os diff --git a/tests/test_ext.py b/tests/test_ext.py index df5c1e0..bf57bb3 100644 --- a/tests/test_ext.py +++ b/tests/test_ext.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- """ - test_apidoc - ~~~~~~~~~~~ +test_apidoc +~~~~~~~~~~~ - Test the sphinxcontrib.apidoc module. +Test the sphinxcontrib.apidoc module. - :copyright: Copyright 2018-present by Stephen Finucane - :license: BSD, see LICENSE for details. +:copyright: Copyright 2018-present by Stephen Finucane +:license: BSD, see LICENSE for details. """ import pytest