File tree Expand file tree Collapse file tree
src/uipath_langchain/agent/react Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ def _unwrap_optional(annotation: Any) -> Any:
184184 The unwrapped type, or the original if not Optional/Union
185185 """
186186 origin = get_origin (annotation )
187- if origin is Union or isinstance ( annotation , types .UnionType ) :
187+ if origin is Union or origin is types .UnionType :
188188 args = get_args (annotation )
189189 non_none_args = [arg for arg in args if arg is not type (None )]
190190 if non_none_args :
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ class WithOptional(BaseModel):
2727 target : Optional [Target ] = None
2828
2929
30+ class WithPipeUnion (BaseModel ):
31+ target : Target | None = None
32+
33+
3034class WithNestedList (BaseModel ):
3135 matrix : list [list [Target ]]
3236
@@ -54,6 +58,10 @@ def test_optional_field(self):
5458 paths = get_json_paths_by_type (WithOptional , "Target" )
5559 assert paths == ["$.target" ]
5660
61+ def test_pipe_union_field (self ):
62+ paths = get_json_paths_by_type (WithPipeUnion , "Target" )
63+ assert paths == ["$.target" ]
64+
5765 def test_nested_list_of_lists (self ):
5866 paths = get_json_paths_by_type (WithNestedList , "Target" )
5967 assert paths == ["$.matrix[*][*]" ]
You can’t perform that action at this time.
0 commit comments