Skip to content

Commit

Permalink
Merge pull request #476 from lsst/tickets/DM-42340
Browse files Browse the repository at this point in the history
DM-42340: Use pydantic v2 APIs to remove deprecation warnings
  • Loading branch information
timj committed Jan 4, 2024
2 parents 9014bfe + 69b5205 commit ae481fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions python/lsst/obs/base/instrument_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

import abc
import dataclasses
import json
from collections.abc import Sequence
from functools import lru_cache
from typing import TYPE_CHECKING, Any, ClassVar
Expand Down Expand Up @@ -91,11 +90,11 @@ class CuratedCalibration(BaseModel):
def readText(cls, path: str) -> CuratedCalibration:
with open(path) as f:
data = f.read()
return cls.parse_obj(json.loads(data))
return cls.model_validate_json(data)

def writeText(self, path: str) -> None:
with open(path, "w") as f:
print(self.json(), file=f)
print(self.model_dump_json(), file=f)

def getMetadata(self) -> dict[str, Any]:
return self.metadata
Expand Down
3 changes: 2 additions & 1 deletion tests/test_defineVisits.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def setUp(self):
# Read the exposure records.
self.records: dict[int, DimensionRecord] = {}
for i in (347, 348, 349):
simple = SerializedDimensionRecord.parse_file(os.path.join(DATADIR, f"exp_{i}.json"))
with open(os.path.join(DATADIR, f"exp_{i}.json")) as fh:
simple = SerializedDimensionRecord.model_validate_json(fh.read())
self.records[i] = DimensionRecord.from_simple(simple, registry=self.butler.registry)

def tearDown(self):
Expand Down

0 comments on commit ae481fb

Please sign in to comment.