Skip to content

Commit

Permalink
fix: evaluate unstringified annotation before caching
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed Oct 15, 2023
1 parent 913b5c8 commit f158d81
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions disnake/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,13 +1134,14 @@ def evaluate_annotation(
if implicit_str and isinstance(tp, str):
if tp in cache:
return cache[tp]
evaluated = (
eval( # noqa: PGH001, S307 # this is how annotations are supposed to be unstringifed
tp, globals, locals
)
)

# this is how annotations are supposed to be unstringifed
evaluated = eval(tp, globals, locals) # noqa: PGH001, S307
# recurse to resolve nested args further
evaluated = evaluate_annotation(evaluated, globals, locals, cache)

cache[tp] = evaluated
return evaluate_annotation(evaluated, globals, locals, cache)
return evaluated

if hasattr(tp, "__args__"):
implicit_str = True
Expand Down

0 comments on commit f158d81

Please sign in to comment.