Split out from #61 as a pre-existing warning that predates PR #96 and is out-of-scope for the coverage work.
Symptom
Observed in the test_coverage CI run (e.g. https://github.com/ChengLabResearch/ouroboros/actions/runs/28622389980):
test/helpers/test_models.py::test_model_with_json
.../python/ouroboros/helpers/models.py:117: 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.
for field in self.model_fields.keys():
Cause
copy_values_from_other (models.py:117) accesses self.model_fields.keys() on a BaseModel instance. Pydantic V2.11 deprecated instance-level model_fields; V3.0 will remove it entirely.
def copy_values_from_other(self: BaseModel, other: BaseModel):
for field in self.model_fields.keys(): # <-- deprecated
setattr(self, field, getattr(other, field))
Fix
Access model_fields off the class instead:
def copy_values_from_other(self: BaseModel, other: BaseModel):
for field in type(self).model_fields.keys():
setattr(self, field, getattr(other, field))
Or explicitly self.__class__.model_fields. Either satisfies Pydantic V3.0 while keeping subclass polymorphism.
Acceptance
Verification
cd python
poetry run pytest test/helpers/test_models.py -W error::pydantic.PydanticDeprecatedSince211
Should exit 0 after the fix (currently errors on the deprecation).
Out of scope
Split out from #61 as a pre-existing warning that predates PR #96 and is out-of-scope for the coverage work.
Symptom
Observed in the
test_coverageCI run (e.g. https://github.com/ChengLabResearch/ouroboros/actions/runs/28622389980):Cause
copy_values_from_other(models.py:117) accessesself.model_fields.keys()on aBaseModelinstance. Pydantic V2.11 deprecated instance-levelmodel_fields; V3.0 will remove it entirely.Fix
Access
model_fieldsoff the class instead:Or explicitly
self.__class__.model_fields. Either satisfies Pydantic V3.0 while keeping subclass polymorphism.Acceptance
models.py:117uses class-levelmodel_fieldsaccess.test_coverageworkflow run for the branch shows thePydanticDeprecatedSince211warning gone.model_fields/model_fields_set/model_computed_fieldsaccess remains inpython/ouroboros/.Verification
cd python poetry run pytest test/helpers/test_models.py -W error::pydantic.PydanticDeprecatedSince211Should exit 0 after the fix (currently errors on the deprecation).
Out of scope
SharedNPArray.__del__AttributeErrorwarning — tracked separately in SharedNPArray.__del__ AttributeError on partially-constructed instance (mem.py:76) #97 (or whatever number gets assigned).