From a5c38d9df098b4732fcc86acea8ef25519e3408b Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Fri, 8 Nov 2024 13:16:26 +0000 Subject: [PATCH 1/2] Fix "Failing to pass a value to the type_params parameter of typing._eval_type" --- strawberry/utils/typing.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/strawberry/utils/typing.py b/strawberry/utils/typing.py index 1b050bbf4b..5c53bbbc50 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 = {} + + 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: From e03b32c0e8d7e44ca5b894ff1325b4f2bedcbf95 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Fri, 8 Nov 2024 13:23:28 +0000 Subject: [PATCH 2/2] Add release notes --- RELEASE.md | 11 +++++++++++ strawberry/utils/typing.py | 2 +- 2 files changed, 12 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 5c53bbbc50..245f6542ab 100644 --- a/strawberry/utils/typing.py +++ b/strawberry/utils/typing.py @@ -350,7 +350,7 @@ def eval_type( assert ast_unparse type_ = ForwardRef(ast_unparse(ast_obj)) - extra = {} + extra: Dict[str, Any] = {} if sys.version_info >= (3, 13): extra = {"type_params": None}