Serialize Python types to their __name__ attribute

This commit is contained in:
miruka 2019-12-01 12:21:37 -04:00
parent 3e214dc26b
commit 08694388dd
2 changed files with 7 additions and 4 deletions

View File

@ -106,7 +106,7 @@ class UploadStatus(AutoStrEnum):
Caching = auto() Caching = auto()
UploadingThumbnail = auto() UploadingThumbnail = auto()
CachingThumbnail = auto() CachingThumbnail = auto()
Failure = auto() # TODO Failure = auto()
@dataclass @dataclass
@ -182,11 +182,11 @@ class Event(ModelItem):
return self.date > other.date return self.date > other.date
@property @property
def event_type(self) -> str: def event_type(self) -> Type:
if self.local_event_type: if self.local_event_type:
return self.local_event_type.__name__ return self.local_event_type
return type(self.source).__name__ return type(self.source)
@property @property
def links(self) -> List[str]: def links(self) -> List[str]:

View File

@ -136,6 +136,9 @@ def serialize_value_for_qml(value: Any) -> Any:
if isinstance(value, Path): if isinstance(value, Path):
return f"file://{value!s}" return f"file://{value!s}"
if inspect.isclass(value):
return value.__name__
return value return value