mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix Pydantic model_fields instance access deprecation warnings (#9278)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
parent
6aad23d35c
commit
5e5168ffd4
@ -51,7 +51,7 @@ def get_field_info(field: FieldInfo) -> dict[str, Any]:
|
||||
def model_defaults_to_dict(model: BaseModel) -> dict[str, Any]:
|
||||
"""Serialize field information in a dict for the frontend, including type hints, defaults, and whether it's optional."""
|
||||
result = {}
|
||||
for name, field in model.model_fields.items():
|
||||
for name, field in model.__class__.model_fields.items():
|
||||
field_value = getattr(model, name)
|
||||
|
||||
if isinstance(field_value, BaseModel):
|
||||
|
||||
@ -67,7 +67,7 @@ def load_from_env(
|
||||
# helper function to set attributes based on env vars
|
||||
def set_attr_from_env(sub_config: BaseModel, prefix: str = '') -> None:
|
||||
"""Set attributes of a config model based on environment variables."""
|
||||
for field_name, field_info in sub_config.model_fields.items():
|
||||
for field_name, field_info in sub_config.__class__.model_fields.items():
|
||||
field_value = getattr(sub_config, field_name)
|
||||
field_type = field_info.annotation
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user