Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pep-625 compliance, enabling python 3.13, and import perfs #23

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 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/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml

Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand All @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[flake8]
max-line-length = 100
ignore = W503,PYD002,TC003,TC006
exclude =
.venv*
venv*
.eggs
docs
Expand Down
15 changes: 9 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down Expand Up @@ -94,5 +96,6 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
)
10 changes: 9 additions & 1 deletion sphinx_ape/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 5 additions & 3 deletions sphinx_ape/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
import shutil
from enum import Enum
from pathlib import Path
from typing import Optional, 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
from sphinx_ape.exceptions import BuildError, PublishError
from sphinx_ape.types import TOCTreeSpec

if TYPE_CHECKING:
from sphinx_ape.types import TOCTreeSpec

REDIRECT_HTML = """
<!DOCTYPE html>
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions sphinx_ape/sphinx_ext/plugin.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Loading