From cb890cc99bc6ca9dcd6e4fca65c4b9ba9b70c173 Mon Sep 17 00:00:00 2001 From: slush Date: Mon, 16 Dec 2024 00:26:18 -0600 Subject: [PATCH 1/3] feat: pep-625 compliance and enabling python 3.13 --- .pre-commit-config.yaml | 11 ++++++----- pyproject.toml | 4 ++-- setup.cfg | 1 + setup.py | 15 +++++++++------ 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bccadf2..1e913c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-yaml @@ -10,23 +10,24 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.10.0 hooks: - id: black name: black - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 + additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 + rev: v1.13.0 hooks: - id: mypy - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.19 hooks: - id: mdformat additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject] diff --git a/pyproject.toml b/pyproject.toml index cb90f9f..3fac220 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0"] +requires = ["setuptools>=75.6.0", "wheel", "setuptools_scm[toml]>=5.0"] [tool.mypy] exclude = "build/" @@ -14,7 +14,7 @@ write_to = "sphinx_ape/version.py" [tool.black] line-length = 100 -target-version = ['py39', 'py310', 'py311', 'py312'] +target-version = ['py39', 'py310', 'py311', 'py312', 'py313'] include = '\.pyi?$' [tool.isort] diff --git a/setup.cfg b/setup.cfg index c362920..936e5ed 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,6 @@ [flake8] max-line-length = 100 +ignore = PYD002,TC003,TC006 exclude = venv* .eggs diff --git a/setup.py b/setup.py index 3be5b46..1579369 100644 --- a/setup.py +++ b/setup.py @@ -7,21 +7,23 @@ "pytest-mock>=3.14.0,<4", ], "lint": [ - "black>=24.4.2,<25", # Auto-formatter and linter - "mypy>=1.10.0,<2", # Static type analyzer + "black>=24.10.0,<25", # Auto-formatter and linter + "mypy>=1.13.0,<2", # Static type analyzer "types-setuptools", # Needed for mypy type shed "docutils-stubs", # Needed for mypy type shed - "flake8>=7.0.0,<8", # Style linter + "flake8>=7.1.1,<8", # Style linter "flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code "flake8-print>=5.0.0,<6", # Detect print statements left in code + "flake8-pydantic", # For detecting issues with Pydantic models + "flake8-type-checking", # Detect imports to move in/out of type-checking blocks "isort>=5.13.2,<6", # Import sorting linter - "mdformat>=0.7.17", # Auto-formatter for markdown + "mdformat>=0.7.19", # Auto-formatter for markdown "mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown "mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates - "mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml + "mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml ], "release": [ # `release` GitHub Action job uses this - "setuptools", # Installation tool + "setuptools>=75.6.0", # Installation tool "wheel", # Packaging tool "twine", # Package upload tool ], @@ -94,5 +96,6 @@ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ], ) From c08e234df98c17ca38ff9f3fd636105a555203f0 Mon Sep 17 00:00:00 2001 From: slush Date: Mon, 16 Dec 2024 00:51:26 -0600 Subject: [PATCH 2/3] chore: lint --- setup.cfg | 3 ++- sphinx_ape/__init__.py | 10 +++++++++- sphinx_ape/build.py | 8 +++++--- sphinx_ape/sphinx_ext/plugin.py | 7 +++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/setup.cfg b/setup.cfg index 936e5ed..4bc7af2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,8 @@ [flake8] max-line-length = 100 -ignore = PYD002,TC003,TC006 +ignore = W503,PYD002,TC003,TC006 exclude = + .venv* venv* .eggs docs diff --git a/sphinx_ape/__init__.py b/sphinx_ape/__init__.py index 11172fc..2d31339 100644 --- a/sphinx_ape/__init__.py +++ b/sphinx_ape/__init__.py @@ -1,4 +1,12 @@ -from .sphinx_ext.plugin import setup +def __getattr__(name: str): + if name == "setup": + from sphinx_ape.sphinx_ext.plugin import setup + + return setup + + else: + raise AttributeError(name) + __all__ = [ "setup", diff --git a/sphinx_ape/build.py b/sphinx_ape/build.py index a30fbc0..991f0cc 100644 --- a/sphinx_ape/build.py +++ b/sphinx_ape/build.py @@ -2,12 +2,14 @@ import shutil from enum import Enum from pathlib import Path -from typing import Optional, Union +from typing import Optional, TYPE_CHECKING, Union from sphinx_ape._base import Documentation from sphinx_ape._utils import extract_source_url, git, replace_tree, sphinx_build from sphinx_ape.exceptions import BuildError, PublishError -from sphinx_ape.types import TOCTreeSpec + +if TYPE_CHECKING: + from sphinx_ape.types import TOCTreeSpec REDIRECT_HTML = """ @@ -68,7 +70,7 @@ def __init__( base_path: Optional[Path] = None, name: Optional[str] = None, pages_branch_name: Optional[str] = None, - toc_tree_spec: Optional[TOCTreeSpec] = None, + toc_tree_spec: Optional["TOCTreeSpec"] = None, ) -> None: self.mode = BuildMode.LATEST if mode is None else mode super().__init__(base_path, name, toc_tree_spec=toc_tree_spec) diff --git a/sphinx_ape/sphinx_ext/plugin.py b/sphinx_ape/sphinx_ext/plugin.py index 32c52cb..6a66893 100644 --- a/sphinx_ape/sphinx_ext/plugin.py +++ b/sphinx_ape/sphinx_ext/plugin.py @@ -1,17 +1,20 @@ import os import sys from pathlib import Path +from typing import TYPE_CHECKING -from sphinx.application import Sphinx from sphinx.util import logging from sphinx_ape._utils import get_package_name from sphinx_ape.sphinx_ext.directives import DynamicTocTree +if TYPE_CHECKING: + from sphinx.application import Sphinx + logger = logging.getLogger(__name__) -def setup(app: Sphinx): +def setup(app: "Sphinx"): """Set default values for various Sphinx configurations.""" # For building and serving multiple projects at once, From 1678f92478acf0523a55ac5a6a1aab8443713c92 Mon Sep 17 00:00:00 2001 From: slush Date: Mon, 16 Dec 2024 00:53:01 -0600 Subject: [PATCH 3/3] chore: linting --- sphinx_ape/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_ape/build.py b/sphinx_ape/build.py index 991f0cc..f9ed8a6 100644 --- a/sphinx_ape/build.py +++ b/sphinx_ape/build.py @@ -2,7 +2,7 @@ import shutil from enum import Enum from pathlib import Path -from typing import Optional, TYPE_CHECKING, Union +from typing import TYPE_CHECKING, Optional, Union from sphinx_ape._base import Documentation from sphinx_ape._utils import extract_source_url, git, replace_tree, sphinx_build