From 18ade57ffe39f82838abb044cab07303e1a11484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:17:40 +0200 Subject: [PATCH 1/3] fix interaction with PEP 695 --- sphinx/util/inspect.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index da487a05a59..5229d115e11 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -718,6 +718,12 @@ def _evaluate_forwardref( localns: dict[str, Any] | None, ) -> Any: """Evaluate a forward reference.""" + if sys.version_info[:2] >= (3, 13): + # ``type_params`` were added in 3.13 and the signature of _evaluate() + # is not backward-compatible, so we will just suppress NameError's. + # + # See: https://github.com/python/cpython/pull/118104. + return ref._evaluate(globalns, localns, {}, recursive_guard=frozenset()) return ref._evaluate(globalns, localns, frozenset()) From 135a2c4c4b6d05deea168fc366afa8ceb40d50cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:23:28 +0200 Subject: [PATCH 2/3] fix interaction with PEP 695 --- sphinx/util/inspect.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 5229d115e11..96c141aebf3 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -718,9 +718,10 @@ def _evaluate_forwardref( localns: dict[str, Any] | None, ) -> Any: """Evaluate a forward reference.""" - if sys.version_info[:2] >= (3, 13): + if sys.version_info >= (3, 12, 4): # ``type_params`` were added in 3.13 and the signature of _evaluate() - # is not backward-compatible, so we will just suppress NameError's. + # is not backward-compatible (it was backported to 3.12.4, so anything + # before 3.12.4 still has the old signature). # # See: https://github.com/python/cpython/pull/118104. return ref._evaluate(globalns, localns, {}, recursive_guard=frozenset()) From eee7fe18a5e3f46f8f8cedc5e321fb3318a62b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:29:37 +0200 Subject: [PATCH 3/3] mypy! --- sphinx/util/inspect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 96c141aebf3..ee27b37d2b5 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -724,7 +724,7 @@ def _evaluate_forwardref( # before 3.12.4 still has the old signature). # # See: https://github.com/python/cpython/pull/118104. - return ref._evaluate(globalns, localns, {}, recursive_guard=frozenset()) + return ref._evaluate(globalns, localns, {}, recursive_guard=frozenset()) # type: ignore[arg-type, misc] return ref._evaluate(globalns, localns, frozenset())