Skip to content

Commit 80cfef3

Browse files
committed
Fixes pydantic.warnings.PydanticDeprecatedSince211
pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0
1 parent eff219f commit 80cfef3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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 (

services/api-server/tests/unit/test_services_solver_job_models_converters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ def fake_url_for(*args, **kwargs) -> HttpUrl:
225225

226226
assert job.id == project.uuid
227227

228+
field_names = Job.model_fields.keys()
229+
228230
non_propagated_fields = {
229-
name for name in job.model_fields if name.endswith("url")
231+
name for name in field_names if name.endswith("url")
230232
}.union({"name"})
231233
assert all(getattr(job, _) for _ in non_propagated_fields)
232234

0 commit comments

Comments
 (0)