https://github.com/python/cpython/commit/4ae1a260c7dbada6db099d3335a784b5aae91723
commit: 4ae1a260c7dbada6db099d3335a784b5aae91723
branch: main
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-05-08T07:48:15+03:00
summary:
gh-149528: Remove `annotationlib.ForwardRef._evaluate` for 3.16 (#149529)
files:
A Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst
M Doc/whatsnew/3.16.rst
M Lib/annotationlib.py
M Lib/typing.py
diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst
index cc88a694608233..98a8644884a8d7 100644
--- a/Doc/whatsnew/3.16.rst
+++ b/Doc/whatsnew/3.16.rst
@@ -106,6 +106,14 @@ module_name
Removed
=======
+annotationlib
+-------------
+
+* The :meth:`!annotationlib.ForwardRef._evaluate` method
+ which has been deprecated since Python 3.14.
+ Use :meth:`annotationlib.ForwardRef.evaluate`
+ or :func:`typing.evaluate_forward_ref` instead.
+
sysconfig
---------
diff --git a/Lib/annotationlib.py b/Lib/annotationlib.py
index 5c9a0812646f81..8204c762cce8a2 100644
--- a/Lib/annotationlib.py
+++ b/Lib/annotationlib.py
@@ -226,29 +226,6 @@ def evaluate(
new_locals.transmogrify(self.__cell__)
return result
- def _evaluate(self, globalns, localns, type_params=_sentinel, *,
recursive_guard):
- import typing
- import warnings
-
- if type_params is _sentinel:
- typing._deprecation_warning_for_no_type_params_passed(
- "typing.ForwardRef._evaluate"
- )
- type_params = ()
- warnings._deprecated(
- "ForwardRef._evaluate",
- "{name} is a private API and is retained for compatibility, but
will be removed"
- " in Python 3.16. Use ForwardRef.evaluate() or
typing.evaluate_forward_ref() instead.",
- remove=(3, 16),
- )
- return typing.evaluate_forward_ref(
- self,
- globals=globalns,
- locals=localns,
- type_params=type_params,
- _recursive_guard=recursive_guard,
- )
-
@property
def __forward_arg__(self):
if self.__arg__ is not None:
diff --git a/Lib/typing.py b/Lib/typing.py
index 5b1e223d59641e..130e09be4b9127 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -434,19 +434,6 @@ def _rebuild_generic_alias(alias: GenericAlias, args:
tuple[object, ...]) -> Gen
return t
-def _deprecation_warning_for_no_type_params_passed(funcname: str) -> None:
- import warnings
-
- depr_message = (
- f"Failing to pass a value to the 'type_params' parameter "
- f"of {funcname!r} is deprecated, as it leads to incorrect behaviour "
- f"when calling {funcname} on a stringified annotation "
- f"that references a PEP 695 type parameter. "
- f"It will be disallowed in Python 3.15."
- )
- warnings.warn(depr_message, category=DeprecationWarning, stacklevel=3)
-
-
def _eval_type(t, globalns, localns, type_params, *,
recursive_guard=frozenset(),
format=None, owner=None, parent_fwdref=None,
prefer_fwd_module=False):
"""Evaluate all forward references in the given type t.
diff --git
a/Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst
b/Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst
new file mode 100644
index 00000000000000..b2c6e427a1c592
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst
@@ -0,0 +1 @@
+Remove ``annotationlib.ForwardRef._evaludate`` deprecated method.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]