Skip to content

Commit

Permalink
fix: remove Store.__missing__ and change __getitem__ so it calls it o…
Browse files Browse the repository at this point in the history
…nly if it exists. To not obfuscate errors under KeyError.
  • Loading branch information
thorwhalen committed Jun 12, 2024
1 parent 0cc2101 commit cce455c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions dol/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ def __reduce__(self):
for attr in attrs:
wrapped_attr = getattr(wrapped, attr)
delegated_attribute = update_wrapper(
wrapper=DelegatedAttribute(delegation_attr, attr), wrapped=wrapped_attr,
wrapper=DelegatedAttribute(delegation_attr, attr),
wrapped=wrapped_attr,
)
setattr(Wrap, attr, delegated_attribute)

Expand Down Expand Up @@ -610,13 +611,13 @@ def __getitem__(self, k: Key) -> Val:
_id = self._id_of_key(k)
try:
data = self.store[_id]
except self._errors_that_trigger_missing:
data = self.__missing__(k)
except self._errors_that_trigger_missing as error:
if hasattr(self, '__missing__'):
data = self.__missing__(k)
else:
raise error
return self._obj_of_data(data)

def __missing__(self, k):
raise KeyError(k)

def get(self, k: Key, default=None) -> Val:
try:
return self[k]
Expand Down

0 comments on commit cce455c

Please sign in to comment.