mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-16 08:06:14 +00:00
[chore]: Move from inspect.siganture to model_fields.items() in get_all_basemodel_annotations
This commit is contained in:
parent
7fe753436e
commit
979b81864e
@ -1078,7 +1078,7 @@ def get_all_basemodel_annotations(
|
|||||||
# cls has no subscript: cls = FooBar
|
# cls has no subscript: cls = FooBar
|
||||||
if isinstance(cls, type):
|
if isinstance(cls, type):
|
||||||
annotations: dict[str, type] = {}
|
annotations: dict[str, type] = {}
|
||||||
for name, param in inspect.signature(cls).parameters.items():
|
for name, param in cls.model_fields.items():
|
||||||
# Exclude hidden init args added by pydantic Config. For example if
|
# Exclude hidden init args added by pydantic Config. For example if
|
||||||
# BaseModel(extra="allow") then "extra_data" will part of init sig.
|
# BaseModel(extra="allow") then "extra_data" will part of init sig.
|
||||||
if (
|
if (
|
||||||
@ -1094,7 +1094,6 @@ def get_all_basemodel_annotations(
|
|||||||
get_origin(cls), default_to_bound=False
|
get_origin(cls), default_to_bound=False
|
||||||
)
|
)
|
||||||
orig_bases = (cls,)
|
orig_bases = (cls,)
|
||||||
|
|
||||||
# Pydantic v2 automatically resolves inherited generics, Pydantic v1 does not.
|
# Pydantic v2 automatically resolves inherited generics, Pydantic v1 does not.
|
||||||
if not (isinstance(cls, type) and is_pydantic_v2_subclass(cls)):
|
if not (isinstance(cls, type) and is_pydantic_v2_subclass(cls)):
|
||||||
# if cls = FooBar inherits from Baz[str], orig_bases will contain Baz[str]
|
# if cls = FooBar inherits from Baz[str], orig_bases will contain Baz[str]
|
||||||
|
Loading…
Reference in New Issue
Block a user