Skip to content

Commit

Permalink
[fix] fixing issues with datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Animenosekai committed Aug 15, 2023
1 parent 0312ad5 commit 1a9df5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cain/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ def __repr__(cls) -> str:
try:
return cls().__repr__()
except Exception:
return str(cls)
try:
return str(cls)
except Exception:
try:
return cls.__name__
except Exception:
return "Datatype(N/A)"

def __eq__(cls, value: "DatatypeMeta") -> bool:
if hasattr(cls, "__name__") or hasattr(value, "__name__"):
Expand Down Expand Up @@ -253,6 +259,8 @@ def __str__(self) -> str:
return str(self._cain_value)

def __getattr__(self, key: str):
if key == "_cain_value":
return super().__getattribute__("_cain_value")
return getattr(self._cain_value, key)

def __getitem__(self, key: str):
Expand Down
3 changes: 3 additions & 0 deletions cain/types/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def __init__(self, value: typing.Optional[dict] = None, *args, **kwargs) -> None
super().__init__(value, *args)

def __getattr__(self, key: str):
if key == "_cain_value":
return super().__getattribute__("_cain_value")

try:
return super().__getattr__(key)
except AttributeError as err:
Expand Down

0 comments on commit 1a9df5d

Please sign in to comment.