Skip to content

[pre-commit.ci] pre-commit autoupdate #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.10
rev: v0.11.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 3 additions & 1 deletion src/scanpydoc/elegant_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def x() -> Tuple[int, float]:


def _init_vars(_app: Sphinx, config: Config) -> None:
cast(RoleMapping, qualname_overrides.maps[0]).update_user(config.qualname_overrides)
cast("RoleMapping", qualname_overrides.maps[0]).update_user(
config.qualname_overrides
)
if (
"sphinx_autodoc_typehints" in config.extensions
and config.typehints_defaults is None
Expand Down
6 changes: 4 additions & 2 deletions src/scanpydoc/elegant_typehints/_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import inspect
from types import GenericAlias
from typing import TYPE_CHECKING, Any, cast, get_args, get_origin
from typing import TYPE_CHECKING, cast, get_args, get_origin

from sphinx_autodoc_typehints import format_annotation

Expand All @@ -11,6 +11,8 @@


if TYPE_CHECKING:
from typing import Any

from sphinx.config import Config


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

if isinstance(annotation, GenericAlias | _GenericAlias):
args = get_args(annotation)
annotation = cast(type[Any], get_origin(annotation))
annotation = cast("type[Any]", get_origin(annotation))
else:
args = None
annotation_cls = annotation if inspect.isclass(annotation) else type(annotation)
Expand Down
2 changes: 1 addition & 1 deletion src/scanpydoc/rtd_github_links/_linkcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def linkcode_resolve(domain: Domain, info: DomainInfo) -> str | None:

if domain != "py":
return None
info = cast(PyInfo, info)
info = cast("PyInfo", info)
if not info["module"]:
return None
return github_url(f"{info['module']}.{info['fullname']}")
6 changes: 3 additions & 3 deletions tests/test_elegant_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import re
import inspect
from io import StringIO
from typing import TYPE_CHECKING, Any, AnyStr, NoReturn, NamedTuple, cast, get_origin
from pathlib import Path
from operator import attrgetter
Expand All @@ -31,6 +30,7 @@ class _InventoryItem(NamedTuple):


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

out = Path(app.outdir, "index.html").read_text()
buf = cast(StringIO, app._warning) # noqa: SLF001
buf = cast("StringIO", app._warning) # noqa: SLF001
warnings = [
w
for w in buf.getvalue().splitlines()
Expand Down