]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149528: Remove `annotationlib.ForwardRef._evaluate` for 3.16 (#149529)
authorsobolevn <mail@sobolevn.me>
Fri, 8 May 2026 04:48:15 +0000 (07:48 +0300)
committerGitHub <noreply@github.com>
Fri, 8 May 2026 04:48:15 +0000 (07:48 +0300)
Doc/whatsnew/3.16.rst
Lib/annotationlib.py
Lib/typing.py
Misc/NEWS.d/next/Library/2026-05-08-06-12-26.gh-issue-149528.AxdDxa.rst [new file with mode: 0644]

index cc88a694608233eee7001f5117a3a353ed5b4b8f..98a8644884a8d7e84d9cd310eaa0a2dae54b80a3 100644 (file)
@@ -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
 ---------
 
index 5c9a0812646f8149eb4afa4da1fdaafeb5422bf3..8204c762cce8a2b7c448ebacd2cbdcba54fdec09 100644 (file)
@@ -226,29 +226,6 @@ class ForwardRef:
                 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:
index 5b1e223d59641e18f2a4b8a33d137309ed5720a6..130e09be4b91275b722bd4d9c85ef0dee7fb6308 100644 (file)
@@ -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 (file)
index 0000000..b2c6e42
--- /dev/null
@@ -0,0 +1 @@
+Remove ``annotationlib.ForwardRef._evaludate`` deprecated method.