Skip to content

Commit

Permalink
Fix generate_self_schema for Python 3.12+ (#1299)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed May 22, 2024
1 parent 0dcf82a commit a762041
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion generate_self_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ def all_literal_values(type_: type[core_schema.Literal]) -> list[any]:

def eval_forward_ref(type_: Any) -> Any:
try:
return type_._evaluate(core_schema.__dict__, None, set())
try:
# Python 3.12+
return type_._evaluate(core_schema.__dict__, None, type_params=set(), recursive_guard=set())
except TypeError:
# Python 3.9+
return type_._evaluate(core_schema.__dict__, None, set())
except TypeError:
# for Python 3.8
return type_._evaluate(core_schema.__dict__, None)
Expand Down

0 comments on commit a762041

Please sign in to comment.