We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1697f15 commit 95c0e4fCopy full SHA for 95c0e4f
dspy/signatures/signature.py
@@ -580,6 +580,18 @@ def resolve_name(type_name: str):
580
581
return base_type[arg_types]
582
583
+ if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
584
+ # Handle PEP 604: int | None, str | float, etc.
585
+ left = _parse_type_node(node.left, names)
586
+ right = _parse_type_node(node.right, names)
587
+
588
+ # Optional[X] is Union[X, NoneType]
589
+ if right is type(None):
590
+ return typing.Optional[left]
591
+ if left is type(None):
592
+ return typing.Optional[right]
593
+ return typing.Union[left, right]
594
595
if isinstance(node, ast.Tuple):
596
return tuple(_parse_type_node(elt, names) for elt in node.elts)
597
0 commit comments