langchain/libs/core/tests/unit_tests/utils
Ivan 5b9290a449
Fix UnionType type var replacement (#25566)
[langchain_core] Fix UnionType type var replacement

- Added types.UnionType to typing.Union mapping

Type replacement cause `TypeError: 'type' object is not subscriptable`
if any of union type comes as function `_py_38_safe_origin` return
`types.UnionType` instead of `typing.Union`

```python
>>> from types import UnionType
>>> from typing import Union, get_origin
>>> type_ = get_origin(str | None)
>>> type_
<class 'types.UnionType'>
>>> UnionType[(str, None)]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'type' object is not subscriptable
>>> Union[(str, None)]
typing.Optional[str]
```

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
2024-08-22 14:22:09 -04:00
..
__init__.py Separate out langchain_core package (#13577) 2023-11-20 13:09:30 -08:00
test_aiter.py core[minor]: add upsert, streaming_upsert, aupsert, astreaming_upsert methods to the VectorStore abstraction (#23774) 2024-07-05 12:21:40 -04:00
test_env.py core[minor]: Support multiple keys in get_from_dict_or_env (#23086) 2024-06-18 14:13:28 -04:00
test_function_calling.py Fix UnionType type var replacement (#25566) 2024-08-22 14:22:09 -04:00
test_html.py core[patch]: Enhance link extraction with query parameters (#20259) 2024-04-27 02:22:36 +00:00
test_imports.py core[minor]: Add factory for looking up secrets from the env (#25198) 2024-08-08 16:41:58 -04:00
test_iter.py Separate out langchain_core package (#13577) 2023-11-20 13:09:30 -08:00
test_json_schema.py core[patch]: Fix utils.json_schema.dereference_refs (#24335 KeyError: 400 in JSON schema processing) (#24337) 2024-07-19 13:31:00 -04:00
test_pydantic.py core[patch]: Add pydantic get_fields adapter (#25187) 2024-08-08 17:47:42 +00:00
test_rm_titles.py core: update _rm_titles to account for title argument name bug (#19036) 2024-03-18 21:25:06 -07:00
test_utils.py community[patch],core[patch]: Update EdenaiTool root_validator and add unit test in core (#25233) 2024-08-09 15:59:27 +00:00