Skip to content

Commit

Permalink
Use model_construct in a few already-validated contexts.
Browse files Browse the repository at this point in the history
This was by no means a comprehensive attempt to find cases like this,
just a few I happened to spot.
  • Loading branch information
TallJimbo committed Dec 21, 2023
1 parent 13d13a4 commit f2714e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/datastore/cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def from_file(cls, file: ResourcePath, root: ResourcePath) -> CacheEntry:
id_, component, _ = _parse_cache_name(file_in_cache)

stat = os.stat(file.ospath)
return cls(
return cls.model_construct(
name=file_in_cache,
size=stat.st_size,
ref=id_,
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def from_records(cls, records: Iterable[ButlerLogRecord]) -> "ButlerLogRecords":
records : iterable of `ButlerLogRecord`
The records to seed this class with.
"""
return cls(root=list(records))
return cls.model_construct(root=list(records))

@classmethod
def from_file(cls, filename: str) -> "ButlerLogRecords":
Expand Down Expand Up @@ -546,7 +546,7 @@ class ButlerLogRecordHandler(StreamHandler):

def __init__(self) -> None:
super().__init__()
self.records = ButlerLogRecords([])
self.records = ButlerLogRecords.model_construct(root=[])

def emit(self, record: LogRecord) -> None:
self.records.append(record)
Expand Down

0 comments on commit f2714e9

Please sign in to comment.