mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-28 23:07:11 +00:00
[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>