mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-118418: Deprecate failing to pass a value to the *type_params* parameter of some private typing
APIs (#118695)
This commit is contained in:
parent
6f768b71ba
commit
0f8a07d158
3 changed files with 61 additions and 11 deletions
|
@ -6308,6 +6308,31 @@ class ForwardRefTests(BaseTestCase):
|
|||
self.assertEqual(X | "x", Union[X, "x"])
|
||||
self.assertEqual("x" | X, Union["x", X])
|
||||
|
||||
def test_deprecation_for_no_type_params_passed_to__evaluate(self):
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
(
|
||||
"Failing to pass a value to the 'type_params' parameter "
|
||||
"of 'typing._eval_type' is deprecated"
|
||||
)
|
||||
) as cm:
|
||||
self.assertEqual(typing._eval_type(list["int"], globals(), {}), list[int])
|
||||
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
f = ForwardRef("int")
|
||||
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
(
|
||||
"Failing to pass a value to the 'type_params' parameter "
|
||||
"of 'typing.ForwardRef._evaluate' is deprecated"
|
||||
)
|
||||
) as cm:
|
||||
self.assertIs(f._evaluate(globals(), {}, recursive_guard=frozenset()), int)
|
||||
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def cached_func(x, y):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue