Skip to content

Commit dc9da7a

Browse files
authored
Fix PEP 604 union types breaking when using Class Signatures for ChainOfThought (#8465)
1 parent 64881c7 commit dc9da7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dspy/signatures/signature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class MyType:
430430
# program of thought and teleprompters, so we just silently default to string.
431431
if type_ is None:
432432
type_ = str
433-
if not isinstance(type_, (type, typing._GenericAlias, types.GenericAlias, typing._SpecialForm)):
433+
if not isinstance(type_, (type, typing._GenericAlias, types.GenericAlias, typing._SpecialForm, types.UnionType)):
434434
raise ValueError(f"Field types must be types, but received: {type_} of type {type(type_)}.")
435435
if not isinstance(field, FieldInfo):
436436
raise ValueError(f"Field values must be Field instances, but received: {field}.")

0 commit comments

Comments
 (0)