Skip to content

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

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 2 commits into from
Dec 10, 2024
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
6 changes: 3 additions & 3 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.29.4
rev: 0.30.0
hooks:
- id: check-github-workflows
args: ["--verbose"]
Expand All @@ -24,13 +24,13 @@ repos:
hooks:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.7.4"
rev: "v0.8.2"
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
rev: "v3.4.2" # Use the sha / tag you want to point at
hooks:
- id: prettier
additional_dependencies:
Expand Down
6 changes: 3 additions & 3 deletions src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,14 @@ def _is_dataclass(name: str, what: str, qualname: str) -> bool:


def _future_annotations_imported(obj: Any) -> bool:
_annotations = getattr(inspect.getmodule(obj), "annotations", None)
if _annotations is None:
annotations_ = getattr(inspect.getmodule(obj), "annotations", None)
if annotations_ is None:
return False

# Make sure that annotations is imported from __future__ - defined in cpython/Lib/__future__.py
# annotations become strings at runtime
future_annotations = 0x100000 if sys.version_info[0:2] == (3, 7) else 0x1000000
return bool(_annotations.compiler_flag == future_annotations)
return bool(annotations_.compiler_flag == future_annotations)


def get_all_type_hints(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration_autodoc_type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_integration(
if regexp:
msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}"
assert re.search(regexp, value), msg
elif not re.search("WARNING: Inline strong start-string without end-string.", value):
elif not re.search(r"WARNING: Inline strong start-string without end-string.", value):
assert not value

result = (Path(app.srcdir) / "_build/text/index.txt").read_text()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def test_format_annotation(inv: Inventory, annotation: Any, expected_result: str

# Test for the correct role (class vs data) using the official Sphinx inventory
if "typing" in expected_result:
m = re.match("^:py:(?P<role>class|data|func):`~(?P<name>[^`]+)`", result)
m = re.match(r"^:py:(?P<role>class|data|func):`~(?P<name>[^`]+)`", result)
assert m, "No match"
name = m.group("name")
expected_role = next((o.role for o in inv.objects if o.name == name), None)
Expand Down Expand Up @@ -905,7 +905,7 @@ def test_resolve_typing_guard_imports(app: SphinxTestApp, status: StringIO, warn
out = status.getvalue()
assert "build succeeded" in out
err = warning.getvalue()
r = re.compile("WARNING: Failed guarded type import")
r = re.compile(r"WARNING: Failed guarded type import")
assert len(r.findall(err)) == 1
pat = r'WARNING: Failed guarded type import with ImportError\("cannot import name \'missing\' from \'functools\''
assert re.search(pat, err)
Expand Down
Loading