mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix sphinx.util.inspect_evaluate_forwardref for Python 3.12.4 (#12317)
Python has recently [1] changed the signature of `_evaluate` for forward references because of type parameters. The change affects 3.13, and was backported to 3.12.4. [1]: https://github.com/python/cpython/pull/118104
This commit is contained in:
@@ -718,6 +718,13 @@ def _evaluate_forwardref(
|
||||
localns: dict[str, Any] | None,
|
||||
) -> Any:
|
||||
"""Evaluate a forward reference."""
|
||||
if sys.version_info >= (3, 12, 4):
|
||||
# ``type_params`` were added in 3.13 and the signature of _evaluate()
|
||||
# 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()) # type: ignore[arg-type, misc]
|
||||
return ref._evaluate(globalns, localns, frozenset())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user