Skip to content

Commit

Permalink
Support Sphinx 7.3 and drop 3.8 support
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 Apr 17, 2024
1 parent a79c4c1 commit 37023fe
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 121 deletions.
1 change: 0 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
steps:
- name: Setup python for tox
uses: actions/setup-python@v5
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.1
rev: 0.28.2
hooks:
- id: check-github-workflows
args: [ "--verbose" ]
Expand All @@ -20,12 +20,12 @@ repos:
- id: tox-ini-fmt
args: ["-p", "fix"]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.7.0"
rev: "1.8.0"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.13"]
additional_dependencies: ["tox>=4.14.2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.5"
rev: "v0.3.7"
hooks:
- id: ruff-format
- id: ruff
Expand Down
20 changes: 10 additions & 10 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.21.1",
"hatchling>=1.24",
]

[project]
Expand All @@ -19,15 +19,14 @@ keywords = [
license = "MIT"
maintainers = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }]
authors = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }]
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: Sphinx :: Extension",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -38,7 +37,7 @@ dynamic = [
"version",
]
dependencies = [
"Sphinx>=7.1.2",
"Sphinx>=7.3.5",
]
optional-dependencies.docs = [
"furo>=2024.1.29",
Expand All @@ -48,12 +47,13 @@ optional-dependencies.numpy = [
]
optional-dependencies.testing = [
"covdefaults>=2.3",
"coverage>=7.4.2",
"diff-cover>=8.0.3",
"pytest>=8.0.1",
"pytest-cov>=4.1",
"coverage>=7.4.4",
"defusedxml>=0.7.1", # required by sphinx.testing
"diff-cover>=9",
"pytest>=8.1.1",
"pytest-cov>=5",
"sphobjinv>=2.3.1",
"typing-extensions>=4.9",
"typing-extensions>=4.11",
]
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 @@ -69,7 +69,7 @@ line-length = 120

[tool.ruff]
line-length = 120
target-version = "py38"
target-version = "py39"
lint.select = ["ALL"]
lint.isort = { known-first-party = [
"sphinx_autodoc_typehints",
Expand Down
5 changes: 2 additions & 3 deletions src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,9 @@ def format_annotation(annotation: Any, config: Config) -> str: # noqa: C901, PL
else:
fmt = [format_annotation(arg, config) for arg in args]
formatted_args = args_format.format(", ".join(fmt))
if formatted_args:
formatted_args = "\\ " + formatted_args

return f":py:{role}:`{prefix}{full_name}`{formatted_args}"
escape = "\\ " if formatted_args else ""
return f":py:{role}:`{prefix}{full_name}`{escape}{formatted_args}"


# reference: https://github.com/pytorch/pytorch/pull/46548/files
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_autodoc_typehints/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def napoleon_numpy_docstring_return_type_processor( # noqa: PLR0913, PLR0917
# Napoleon allows the underline to consist of a bunch of weirder things...
if len(chars) != 1 or next(iter(chars)) not in "=-~_*+#":
continue
pos = pos + 2 # noqa: PLW2901
pos += 2 # noqa: PLW2901
break
else:
return
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 @@ -11,7 +11,7 @@

if TYPE_CHECKING:
from decimal import Decimal
from typing import Sequence
from typing import Sequence # noqa: UP035

from demo_typing_guard_dummy import Literal # guarded by another `if TYPE_CHECKING` in demo_typing_guard_dummy

Expand Down

0 comments on commit 37023fe

Please sign in to comment.