Skip to content

Commit

Permalink
Fix CI and add 3.13 as target with dep/tool upgrades
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Sep 7, 2024
1 parent d0fa2bb commit 8522396
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 61 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
fail-fast: false
matrix:
py:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,34 @@ 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"]
- repo: https://github.com/tox-dev/pyproject-fmt
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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.4",
"hatchling>=1.24",
"hatchling>=1.25",
]

[project]
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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 = [
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/sphinx_autodoc_typehints/attributes_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/roots/test-resolve-typing-guard/demo_typing_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
43 changes: 20 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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 =
Expand All @@ -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
Expand Down

0 comments on commit 8522396

Please sign in to comment.