refactor: Update Data class to simplify attribute retrieval
This commit is contained in:
parent
ae3170101b
commit
8c90d68a03
1 changed files with 1 additions and 2 deletions
|
|
@ -154,8 +154,7 @@ class Data(BaseModel):
|
||||||
return self.__getattribute__(key)
|
return self.__getattribute__(key)
|
||||||
if key in {"data", "text_key"} or key.startswith("_"):
|
if key in {"data", "text_key"} or key.startswith("_"):
|
||||||
return super().__getattr__(key)
|
return super().__getattr__(key)
|
||||||
|
return self.data[key]
|
||||||
return self.data.get(key, self.default_value)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Fallback to default behavior to raise AttributeError for undefined attributes
|
# Fallback to default behavior to raise AttributeError for undefined attributes
|
||||||
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{key}'")
|
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{key}'")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue