From 89688a8d954c18de93288ffbff5a862209851754 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:53:06 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/python-jsonschema/check-jsonschema: 0.29.4 → 0.30.0](https://github.com/python-jsonschema/check-jsonschema/compare/0.29.4...0.30.0) - [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.4...v0.8.2) - [github.com/rbubley/mirrors-prettier: v3.3.3 → v3.4.2](https://github.com/rbubley/mirrors-prettier/compare/v3.3.3...v3.4.2) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b88f80d..282e453 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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"] @@ -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: From d2ba7cd5606814995c00f3e2d643afb8320892cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:53:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/sphinx_autodoc_typehints/__init__.py | 6 +++--- tests/test_integration_autodoc_type_aliases.py | 2 +- tests/test_sphinx_autodoc_typehints.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sphinx_autodoc_typehints/__init__.py b/src/sphinx_autodoc_typehints/__init__.py index ce41602..fd5db7a 100644 --- a/src/sphinx_autodoc_typehints/__init__.py +++ b/src/sphinx_autodoc_typehints/__init__.py @@ -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( diff --git a/tests/test_integration_autodoc_type_aliases.py b/tests/test_integration_autodoc_type_aliases.py index b3063fe..9d5a951 100644 --- a/tests/test_integration_autodoc_type_aliases.py +++ b/tests/test_integration_autodoc_type_aliases.py @@ -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() diff --git a/tests/test_sphinx_autodoc_typehints.py b/tests/test_sphinx_autodoc_typehints.py index 4e8041f..acc5aca 100644 --- a/tests/test_sphinx_autodoc_typehints.py +++ b/tests/test_sphinx_autodoc_typehints.py @@ -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:(?Pclass|data|func):`~(?P[^`]+)`", result) + m = re.match(r"^:py:(?Pclass|data|func):`~(?P[^`]+)`", result) assert m, "No match" name = m.group("name") expected_role = next((o.role for o in inv.objects if o.name == name), None) @@ -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)