Skip to content

Commit

Permalink
Fix fallback model_fields class property
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jul 19, 2023
1 parent eba136b commit 594b379
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/lsst/daf/butler/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def model_rebuild(
return None

else:
from astropy.utils.decorators import classproperty

class _BaseModelCompat(BaseModel): # type:ignore[no-redef]
"""Methods from pydantic v2 that can be used in pydantic v1."""
Expand Down Expand Up @@ -177,9 +178,10 @@ def model_dump_json(
def model_construct(cls, _fields_set: set[str] | None = None, **values: Any) -> Self:
return cls.construct(_fields_set=_fields_set, **values)

@property
def model_fields(self) -> dict[str, FieldInfo]: # type: ignore
return self.__fields__ # type: ignore
@classmethod
@classproperty
def model_fields(cls) -> dict[str, FieldInfo]: # type: ignore
return cls.__fields__ # type: ignore

@classmethod
def model_rebuild(
Expand Down

0 comments on commit 594b379

Please sign in to comment.