Skip to content

Commit a51faa8

Browse files
committed
Support Sphinx 9+
Signed-off-by: Bernát Gábor <[email protected]>
1 parent e8ac659 commit a51faa8

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
rev: v2.4.1
1414
hooks:
1515
- id: codespell
16-
additional_dependencies: ["tomli>=2.2.1"]
16+
additional_dependencies: ["tomli>=2.3"]
1717
- repo: https://github.com/tox-dev/tox-ini-fmt
1818
rev: "1.7.0"
1919
hooks:
@@ -34,7 +34,7 @@ repos:
3434
hooks:
3535
- id: prettier
3636
additional_dependencies:
37-
- prettier@3.6.2
37+
- prettier@3.7.4
3838
- "@prettier/[email protected]"
3939
- repo: meta
4040
hooks:

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.5",
5-
"hatchling>=1.27",
5+
"hatchling>=1.28",
66
]
77

88
[project]
@@ -41,17 +41,17 @@ dynamic = [
4141
"version",
4242
]
4343
dependencies = [
44-
"sphinx>=8.2.3",
44+
"sphinx>=9.0.4",
4545
]
4646
optional-dependencies.docs = [
4747
"furo>=2025.9.25",
4848
]
4949
optional-dependencies.testing = [
5050
"covdefaults>=2.3",
51-
"coverage>=7.10.7",
51+
"coverage>=7.13",
5252
"defusedxml>=0.7.1", # required by sphinx.testing
53-
"diff-cover>=9.7.1",
54-
"pytest>=8.4.2",
53+
"diff-cover>=9.7.2",
54+
"pytest>=9.0.2",
5555
"pytest-cov>=7",
5656
"sphobjinv>=2.3.1.3",
5757
"typing-extensions>=4.15",

src/sphinx_autodoc_typehints/patches.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ def fix_autodoc_typehints_for_overloaded_methods() -> None:
2525
Normally, `FunctionDocumenter.format_signature` and `MethodDocumenter.format_signature` call
2626
`super().format_signature` which ends up going to `Documenter.format_signature`, and this last method emits the
2727
`autodoc-process-signature` event. However, if there are overloads, `FunctionDocumenter.format_signature` does
28-
something else and the event never occurs. Here we remove this alternative code path by brute force.
28+
something else and the event never occurs.
29+
30+
We delete the format_signature methods to force using the parent implementation, which emits the event.
2931
3032
See https://github.com/tox-dev/sphinx-autodoc-typehints/issues/296
3133
"""
3234
from sphinx.ext.autodoc import FunctionDocumenter, MethodDocumenter # noqa: PLC0415
3335

36+
# Delete the format_signature methods that add overloads
37+
# This forces everything to use Documenter.format_signature which emits the event
3438
del FunctionDocumenter.format_signature
3539
del MethodDocumenter.format_signature
3640

tests/roots/test-integration/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
"sphinx.ext.napoleon",
1515
"sphinx_autodoc_typehints",
1616
]
17+
18+
autodoc_use_legacy_class_based = True

tests/test_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ class mod.TestClassAttributeDocs
746746
747747
A class
748748
749-
code: "CodeType" | "None"
749+
code: CodeType | None
750750
751751
An attribute
752752
""",
@@ -1013,7 +1013,7 @@ class mod.ParamAndAttributeHaveSameName(blah)
10131013
Parameters:
10141014
**blah** ("CodeType") -- Description of parameter blah
10151015
1016-
blah: "ModuleType"
1016+
blah: ModuleType
10171017
10181018
Description of attribute blah
10191019

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
requires =
3-
tox>=4.30.2
4-
tox-uv>=1.28
3+
tox>=4.32
4+
tox-uv>=1.29
55
env_list =
66
fix
77
3.14
@@ -39,15 +39,15 @@ commands =
3939
description = format the code base to adhere to our styles, and complain about what we cannot do automatically
4040
skip_install = true
4141
deps =
42-
pre-commit-uv>=4.1.5
42+
pre-commit-uv>=4.2
4343
commands =
4444
pre-commit run --all-files --show-diff-on-failure
4545

4646
[testenv:type]
4747
description = run type check on code base
4848
deps =
49-
mypy==1.18.2
50-
types-docutils>=0.22.2.20250924
49+
mypy==1.19
50+
types-docutils>=0.22.3.20251115
5151
commands =
5252
mypy src
5353
mypy tests
@@ -58,7 +58,7 @@ skip_install = true
5858
deps =
5959
check-wheel-contents>=0.6.3
6060
twine>=6.2
61-
uv>=0.8.22
61+
uv>=0.9.16
6262
commands =
6363
uv build --sdist --wheel --out-dir {env_tmp_dir} .
6464
twine check {env_tmp_dir}{/}*

0 commit comments

Comments
 (0)