Skip to content

Commit

Permalink
Fix "Failing to pass a value to the type_params parameter of typing._…
Browse files Browse the repository at this point in the history
…eval_type" (#3692)
  • Loading branch information
patrick91 authored Nov 8, 2024
1 parent 04936fd commit 7c2482e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 6 additions & 1 deletion strawberry/utils/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7c2482e

Please sign in to comment.