Skip to content

Commit 0ac3096

Browse files
[pre-commit.ci] pre-commit autoupdate (#203)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.10 → v0.11.0](astral-sh/ruff-pre-commit@v0.9.10...v0.11.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Philipp A. <flying-sheep@web.de>
1 parent b38a73f commit 0ac3096

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: trailing-whitespace
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.9.10
7+
rev: v0.11.0
88
hooks:
99
- id: ruff
1010
args: [--fix, --exit-non-zero-on-fix]

src/scanpydoc/elegant_typehints/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def x() -> Tuple[int, float]:
104104

105105

106106
def _init_vars(_app: Sphinx, config: Config) -> None:
107-
cast(RoleMapping, qualname_overrides.maps[0]).update_user(config.qualname_overrides)
107+
cast("RoleMapping", qualname_overrides.maps[0]).update_user(
108+
config.qualname_overrides
109+
)
108110
if (
109111
"sphinx_autodoc_typehints" in config.extensions
110112
and config.typehints_defaults is None

src/scanpydoc/elegant_typehints/_formatting.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import inspect
44
from types import GenericAlias
5-
from typing import TYPE_CHECKING, Any, cast, get_args, get_origin
5+
from typing import TYPE_CHECKING, cast, get_args, get_origin
66

77
from sphinx_autodoc_typehints import format_annotation
88

@@ -11,6 +11,8 @@
1111

1212

1313
if TYPE_CHECKING:
14+
from typing import Any
15+
1416
from sphinx.config import Config
1517

1618

@@ -38,7 +40,7 @@ def typehints_formatter(annotation: type[Any], config: Config) -> str | None:
3840

3941
if isinstance(annotation, GenericAlias | _GenericAlias):
4042
args = get_args(annotation)
41-
annotation = cast(type[Any], get_origin(annotation))
43+
annotation = cast("type[Any]", get_origin(annotation))
4244
else:
4345
args = None
4446
annotation_cls = annotation if inspect.isclass(annotation) else type(annotation)

src/scanpydoc/rtd_github_links/_linkcode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def linkcode_resolve(domain: Domain, info: DomainInfo) -> str | None:
5252

5353
if domain != "py":
5454
return None
55-
info = cast(PyInfo, info)
55+
info = cast("PyInfo", info)
5656
if not info["module"]:
5757
return None
5858
return github_url(f"{info['module']}.{info['fullname']}")

tests/test_elegant_typehints.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import re
66
import inspect
7-
from io import StringIO
87
from typing import TYPE_CHECKING, Any, AnyStr, NoReturn, NamedTuple, cast, get_origin
98
from pathlib import Path
109
from operator import attrgetter
@@ -31,6 +30,7 @@ class _InventoryItem(NamedTuple):
3130

3231

3332
if TYPE_CHECKING:
33+
from io import StringIO
3434
from types import ModuleType
3535
from typing import Protocol
3636
from collections.abc import Generator
@@ -363,7 +363,7 @@ def test_autodoc(
363363
)
364364
app.build()
365365
out = Path(app.outdir, "index.html").read_text()
366-
assert not (ws := cast(StringIO, app._warning).getvalue()), ws # noqa: SLF001
366+
assert not (ws := cast("StringIO", app._warning).getvalue()), ws # noqa: SLF001
367367
assert re.search(
368368
r'<(code|span)?[^>]*><span class="pre">test\.</span></(code|span)>'
369369
f'<(code|span)?[^>]*><span class="pre">{sub}</span></(code|span)>',
@@ -401,7 +401,7 @@ class B:
401401
app.build()
402402

403403
out = Path(app.outdir, "index.html").read_text()
404-
buf = cast(StringIO, app._warning) # noqa: SLF001
404+
buf = cast("StringIO", app._warning) # noqa: SLF001
405405
warnings = [
406406
w
407407
for w in buf.getvalue().splitlines()

0 commit comments

Comments
 (0)