Skip to content

Commit

Permalink
Mypy happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Jan 19, 2024
1 parent 24d3864 commit c24238c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/ribasim/ribasim/input_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,10 @@ def set_modeld(
def set_sort_keys(cls, v: Any, info: ValidationInfo) -> Any:
"""Set sort keys for all TableModels if present in FieldInfo."""
if isinstance(v, (TableModel,)):
field = cls.model_fields[info.field_name]
if getattr(field, "json_schema_extra", None) is not None:
v.sort_keys = field.json_schema_extra.get("sort_keys", [])
field = cls.model_fields[getattr(info, "field_name")]
extra = field.json_schema_extra
if extra is not None and isinstance(extra, dict):
v.sort_keys = extra.get("sort_keys", []) # type: ignore
return v

@classmethod
Expand Down

0 comments on commit c24238c

Please sign in to comment.