langchain/libs/core/langchain_core/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 core[minor]: Add factory for looking up secrets from the env (#25198) 2024-08-08 16:41:58 -04:00
_merge.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
aiter.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
env.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
formatting.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
function_calling.py Fix UnionType type var replacement (#25566) 2024-08-22 14:22:09 -04:00
html.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
image.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
input.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
interactive_env.py core[patch]: simple prompt pretty printing (#15968) 2024-01-12 21:08:51 -05:00
iter.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
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
json.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
loading.py multiple: update removal targets (#25361) 2024-08-14 09:50:39 -04:00
mustache.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
pydantic.py core[patch]: fix deprecation pydantic bug (#25204) 2024-08-08 16:39:38 -07:00
strings.py core: docstrings utils update (#24213) 2024-07-15 11:36:00 -04:00
utils.py core[minor], anthropic[patch]: Upgrade @root_validator usage to be consistent with pydantic 2 (#25457) 2024-08-15 20:09:34 +00:00