refactor: Update Data class to simplify attribute retrieval

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-20 09:20:51 -03:00
commit 8c90d68a03

View file

@ -154,8 +154,7 @@ class Data(BaseModel):
return self.__getattribute__(key)
if key in {"data", "text_key"} or key.startswith("_"):
return super().__getattr__(key)
return self.data.get(key, self.default_value)
return self.data[key]
except KeyError:
# Fallback to default behavior to raise AttributeError for undefined attributes
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{key}'")