From 7c2482ec2be558502cef576571174c6caa7b5123 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Fri, 8 Nov 2024 15:39:03 +0000 Subject: [PATCH] Fix "Failing to pass a value to the type_params parameter of typing._eval_type" (#3692) --- RELEASE.md | 11 +++++++++++ strawberry/utils/typing.py | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 RELEASE.md diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..6b6f7cecba --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,11 @@ +Release type: patch + +This release fixes the following deprecation warning: + +``` +Failing to pass a value to the 'type_params' parameter of 'typing._eval_type' is deprecated, +as it leads to incorrect behaviour when calling typing._eval_type on a stringified annotation +that references a PEP 695 type parameter. It will be disallowed in Python 3.15. +``` + +This was only trigger in Python 3.13 and above. diff --git a/strawberry/utils/typing.py b/strawberry/utils/typing.py index 1b050bbf4b..245f6542ab 100644 --- a/strawberry/utils/typing.py +++ b/strawberry/utils/typing.py @@ -350,7 +350,12 @@ def eval_type( assert ast_unparse type_ = ForwardRef(ast_unparse(ast_obj)) - return _eval_type(type_, globalns, localns) + extra: Dict[str, Any] = {} + + if sys.version_info >= (3, 13): + extra = {"type_params": None} + + return _eval_type(type_, globalns, localns, **extra) origin = get_origin(type_) if origin is not None: