Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions unsloth_zoo/temporary_patches/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ def _canonicalize_annotation(annotation: Any) -> Any:
if origin is not None:
args = t.get_args(annotation)
args = tuple(canonicalize_annotation(arg) for arg in args)
# Map origin to canonical form (e.g., types.UnionType -> typing.Union)
# so that `int | str` and `Union[int, str]` are equivalent
origin = TYPE_MAPPINGS.get(origin, origin)
return (origin, args)
return TYPE_MAPPINGS.get(annotation, annotation)
pass
Expand Down