Skip to content

Commit f1ba7c6

Browse files
committed
deprecation wraning
1 parent 85076f9 commit f1ba7c6

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

packages/common-library/src/common_library/serialization.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ def model_dump_with_secrets(
1010
settings_obj: BaseModel, *, show_secrets: bool, **pydantic_export_options
1111
) -> dict[str, Any]:
1212
data = settings_obj.model_dump(**pydantic_export_options)
13+
settings_cls = settings_obj.__class__
1314

14-
for field_name in settings_obj.model_fields:
15+
for field_name in settings_cls.model_fields:
1516
if field_name not in data:
1617
continue
1718

@@ -29,7 +30,7 @@ def model_dump_with_secrets(
2930
data[field_name] = str(field_data)
3031

3132
elif isinstance(field_data, dict):
32-
possible_pydantic_model = settings_obj.model_fields[field_name].annotation
33+
possible_pydantic_model = settings_cls.model_fields[field_name].annotation
3334
# NOTE: data could be a dict which does not represent a pydantic model or a union of models
3435
with contextlib.suppress(AttributeError, ValidationError):
3536
data[field_name] = model_dump_with_secrets(

packages/models-library/src/models_library/service_settings_labels.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ def _not_allowed_in_both_specs(self):
570570
"containers_allowed_outgoing_internet",
571571
"containers_allowed_outgoing_permit_list",
572572
}
573-
if match_keys & set(self.model_fields) != match_keys:
574-
err_msg = f"Expected the following keys {match_keys} to be present {self.model_fields=}"
573+
cls = self.__class__
574+
if match_keys & set(cls.model_fields) != match_keys:
575+
err_msg = f"Expected the following keys {match_keys} to be present {cls.model_fields=}"
575576
raise ValueError(err_msg)
576577

577578
if (

packages/settings-library/src/settings_library/utils_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ def print_as_envfile(
2626
**pydantic_export_options,
2727
):
2828
exclude_unset = pydantic_export_options.get("exclude_unset", False)
29+
settings_cls = settings_obj.__class__
2930

30-
for name, field in settings_obj.model_fields.items():
31+
for name, field in settings_cls.model_fields.items():
3132
auto_default_from_env = (
3233
field.json_schema_extra is not None
3334
and field.json_schema_extra.get("auto_default_from_env", False)

0 commit comments

Comments
 (0)