diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4fc0e6a..2fdef1c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -20,6 +20,7 @@ jobs: fail-fast: false matrix: py: + - "3.13" - "3.12" - "3.11" - "3.10" @@ -38,20 +39,11 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} - - name: Pick environment to run - run: | - import os - import sys - from pathlib import Path - env = "TOXENV=py{}{}\n".format(*sys.version_info[0:2]) - print("Picked:\n{}for{}".format(env, sys.version)) - with Path(os.environ["GITHUB_ENV"]).open("a") as file_handler: - file_handler.write(env) - shell: python - - name: Setup test suite - run: tox -vv --notest - - name: Run test suite - run: tox --skip-pkg-install + allow-prereleases: true + - name: setup test suite + run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }} + - name: run test suite + run: tox run --skip-pkg-install -e ${{ matrix.py }} env: PYTEST_ADDOPTS: "-vv --durations=20" CI_RUN: "yes" @@ -118,7 +110,7 @@ jobs: with: python-version: "3.12" - name: Install tox - run: python -m pip install tox + run: python -m pip install tox-uv - name: Setup test suite run: tox -vv --notest -e ${{ matrix.tox_env }} - name: Run test suite diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 703693d..4b981c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,14 +8,14 @@ repos: rev: 0.29.2 hooks: - id: check-github-workflows - args: [ "--verbose" ] + args: ["--verbose"] - repo: https://github.com/codespell-project/codespell rev: v2.3.0 hooks: - id: codespell additional_dependencies: ["tomli>=2.0.1"] - repo: https://github.com/tox-dev/tox-ini-fmt - rev: "1.3.1" + rev: "1.3.2" hooks: - id: tox-ini-fmt args: ["-p", "fix"] @@ -23,13 +23,19 @@ repos: rev: "2.2.1" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.14.2"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.3" + rev: "v0.6.4" hooks: - id: ruff-format - id: ruff args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"] + - repo: https://github.com/rbubley/mirrors-prettier + rev: "v3.3.3" # Use the sha / tag you want to point at + hooks: + - id: prettier + additional_dependencies: + - prettier@3.3.3 + - "@prettier/plugin-xml@3.4.1" - repo: meta hooks: - id: check-hooks-apply diff --git a/README.md b/README.md index ff2ff49..745ece3 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ The following configuration options are accepted: - `always_document_param_types` (default: `False`): If `False`, do not add type info for undocumented parameters. If `True`, add stub documentation for undocumented parameters to be able to add type info. - `always_use_bars_union ` (default: `False`): If `True`, display Union's using the | operator described in PEP 604. - (e.g `X` | `Y` or `int` | `None`). If `False`, Unions will display with the typing in brackets. (e.g. `Union[X, Y]` - or `Optional[int]`) + (e.g `X` | `Y` or `int` | `None`). If `False`, Unions will display with the typing in brackets. (e.g. `Union[X, Y]` + or `Optional[int]`) - `typehints_document_rtype` (default: `True`): If `False`, never add an `:rtype:` directive. If `True`, add the `:rtype:` directive if no existing `:rtype:` is found. - `typehints_use_rtype` (default: `True`): Controls behavior when `typehints_document_rtype` is set to `True`. If diff --git a/pyproject.toml b/pyproject.toml index 945866c..24120a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ build-backend = "hatchling.build" requires = [ "hatch-vcs>=0.4", - "hatchling>=1.24", + "hatchling>=1.25", ] [project] @@ -35,29 +35,30 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Documentation :: Sphinx", ] dynamic = [ "version", ] dependencies = [ - "sphinx>=7.3.5", + "sphinx>=8.0.2", ] optional-dependencies.docs = [ - "furo>=2024.1.29", + "furo>=2024.8.6", ] optional-dependencies.numpy = [ "nptyping>=2.5", ] optional-dependencies.testing = [ "covdefaults>=2.3", - "coverage>=7.4.4", - "defusedxml>=0.7.1", # required by sphinx.testing - "diff-cover>=9", - "pytest>=8.1.1", + "coverage>=7.6.1", + "defusedxml>=0.7.1", # required by sphinx.testing + "diff-cover>=9.1.1", + "pytest>=8.3.2", "pytest-cov>=5", - "sphobjinv>=2.3.1", - "typing-extensions>=4.11", + "sphobjinv>=2.3.1.1", + "typing-extensions>=4.12.2", ] urls.Changelog = "https://github.com/tox-dev/sphinx-autodoc-typehints/blob/main/CHANGELOG.md" urls.Homepage = "https://github.com/tox-dev/sphinx-autodoc-typehints" @@ -68,9 +69,6 @@ urls.Tracker = "https://github.com/tox-dev/sphinx-autodoc-typehints/issues" build.hooks.vcs.version-file = "src/sphinx_autodoc_typehints/version.py" version.source = "vcs" -[tool.black] -line-length = 120 - [tool.ruff] target-version = "py39" line-length = 120 @@ -87,18 +85,19 @@ lint.ignore = [ "CPY", # No copyright statements "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible "D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible + "DOC", # no sphinx support "ISC001", # Conflict with formatter "S104", # Possible binding to all interface ] lint.per-file-ignores."tests/**/*.py" = [ "D", # don't care about documentation in tests - "FBT", # don"t care about booleans as positional arguments in tests + "FBT", # don't care about booleans as positional arguments in tests "INP001", # no implicit namespace "PLC2701", # private imports "PLR0913", # any number of arguments in tests "PLR0917", # any number of arguments in tests "PLR2004", # Magic value used in comparison, consider replacing with a constant variable - "S101", # asserts allowed in tests... + "S101", # asserts allowed in tests "S603", # `subprocess` call: check for execution of untrusted input ] lint.isort = { known-first-party = [ @@ -115,6 +114,9 @@ ignore-words = "ignore-words.txt" write-changes = true count = true +[tool.pyproject-fmt] +max_supported_python = "3.13" + [tool.pytest.ini_options] testpaths = [ "tests", diff --git a/src/sphinx_autodoc_typehints/__init__.py b/src/sphinx_autodoc_typehints/__init__.py index fbd57ce..3aaf5fe 100644 --- a/src/sphinx_autodoc_typehints/__init__.py +++ b/src/sphinx_autodoc_typehints/__init__.py @@ -20,7 +20,7 @@ from sphinx.util.inspect import TypeAliasForwardRef, TypeAliasNamespace, stringify_signature from sphinx.util.inspect import signature as sphinx_signature -from .parser import parse +from ._parser import parse from .patches import install_patches from .version import __version__ diff --git a/src/sphinx_autodoc_typehints/parser.py b/src/sphinx_autodoc_typehints/_parser.py similarity index 100% rename from src/sphinx_autodoc_typehints/parser.py rename to src/sphinx_autodoc_typehints/_parser.py diff --git a/src/sphinx_autodoc_typehints/attributes_patch.py b/src/sphinx_autodoc_typehints/attributes_patch.py index 6e4575d..d038eae 100644 --- a/src/sphinx_autodoc_typehints/attributes_patch.py +++ b/src/sphinx_autodoc_typehints/attributes_patch.py @@ -11,7 +11,7 @@ from sphinx.domains.python import PyAttribute from sphinx.ext.autodoc import AttributeDocumenter -from .parser import parse +from ._parser import parse if TYPE_CHECKING: from docutils.frontend import Values diff --git a/tests/roots/test-resolve-typing-guard/demo_typing_guard.py b/tests/roots/test-resolve-typing-guard/demo_typing_guard.py index 5c36943..0c42d6e 100644 --- a/tests/roots/test-resolve-typing-guard/demo_typing_guard.py +++ b/tests/roots/test-resolve-typing-guard/demo_typing_guard.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing -from builtins import ValueError # handle does not have __module__ +from builtins import ValueError # handle does not have __module__ # noqa: A004 from functools import cmp_to_key # has __module__ but cannot get module as is builtin from typing import TYPE_CHECKING diff --git a/tox.ini b/tox.ini index 0a98e19..e2460ba 100644 --- a/tox.ini +++ b/tox.ini @@ -3,13 +3,13 @@ requires = tox>=4.2 env_list = fix - py312 - py311 - py310 - py39 type coverage readme + 3.12 + 3.11 + 3.10 + 3.9 skip_missing_interpreters = true [testenv] @@ -37,22 +37,15 @@ commands = description = format the code base to adhere to our styles, and complain about what we cannot do automatically skip_install = true deps = - pre-commit>=3.6.2 + pre-commit-uv>=4.1 commands = pre-commit run --all-files --show-diff-on-failure -[testenv:py312] -extras = - testing - type-comment - [testenv:type] description = run type check on code base deps = - mypy==1.8 - types-docutils>=0.20.0.20240304 -set_env = - {tty:MYPY_FORCE_COLOR = 1} + mypy==1.11.2 + types-docutils>=0.21.0.20240907 commands = mypy src mypy tests @@ -62,8 +55,8 @@ description = combine coverage files and generate diff (against DIFF_AGAINST def skip_install = true deps = covdefaults>=2.3 - coverage>=7.4.3 - diff-cover>=8.0.3 + coverage>=7.6.1 + diff-cover>=9.1.1 extras = parallel_show_output = true pass_env = @@ -77,23 +70,27 @@ commands = coverage html -d {toxworkdir}/htmlcov diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml depends = - py312 - py311 - py310 - py39 - py38 + 3.12 + 3.11 + 3.10 + 3.9 [testenv:readme] description = check that the long description is valid (need for PyPI) skip_install = true deps = - build[virtualenv]>=1.1.1 - twine>=5 + build[virtualenv]>=1.2.2 + twine>=5.1.1 extras = commands = pyproject-build -o {envtmpdir} --wheel --sdist . twine check {envtmpdir}/* +[testenv:3.13] +extras = + testing + type-comment + [testenv:dev] description = generate a DEV environment package = editable