Skip to content

Commit

Permalink
Stop ignoring unrecognized kwargs in DimensionRecord.__init__.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Nov 15, 2023
1 parent 60ed60f commit ef7f0b3
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions python/lsst/daf/butler/dimensions/_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,6 @@ def __init__(self, **kwargs: Any):
"Multiple inconsistent values for "
f"{self.definition.name}.{self.definition.primaryKey.name}: {v!r} != {v2!r}."
)
for name in self.__slots__:
object.__setattr__(self, name, kwargs.get(name))
if self.definition.temporal is not None and self.timespan is None and "datetime_begin" in kwargs:
object.__setattr__(
self,
"timespan",
Timespan(
kwargs["datetime_begin"],
kwargs["datetime_end"],
),
)

from ._coordinate import DataCoordinate

Expand All @@ -299,6 +288,26 @@ def __init__(self, **kwargs: Any):
tuple(kwargs[dimension] for dimension in self.definition.required.names),
),
)
# Don't need the primary key value aliased to the dimension name
# anymore.
kwargs.pop(self.definition.name, None)

for name in self.__slots__:
# Note that we remove from kwargs as we go, to make sure there's
# nothing left at the end.
object.__setattr__(self, name, kwargs.pop(name, None))
if self.definition.temporal is not None and self.timespan is None and "datetime_begin" in kwargs:
object.__setattr__(
self,
"timespan",
Timespan(
kwargs.pop("datetime_begin"),
kwargs.pop("datetime_end"),
),
)

if kwargs:
raise TypeError(f"Invalid fields for {self.definition} dimension record: {set(kwargs.keys())}.")

def __eq__(self, other: Any) -> bool:
if type(other) != type(self):
Expand Down

0 comments on commit ef7f0b3

Please sign in to comment.