From 1781a19a79b97fbdffc68ce1dde993d37d233910 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 6 Mar 2023 23:44:50 +0100 Subject: [PATCH] s/Entity.to_json/Entity.to_dict/g stuff --- platypush/entities/_base.py | 8 +++----- platypush/message/event/entities.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/platypush/entities/_base.py b/platypush/entities/_base.py index 0839082444..d39505851d 100644 --- a/platypush/entities/_base.py +++ b/platypush/entities/_base.py @@ -94,7 +94,7 @@ if 'entity' not in Base.metadata: 'polymorphic_on': type, } - @classmethod + @classmethod # type: ignore @property def columns(cls) -> Tuple[ColumnProperty]: inspector = schema_inspect(cls) @@ -106,8 +106,6 @@ if 'entity' not in Base.metadata: This method returns the "external" key of an entity. """ return (str(self.external_id or self.id), str(self.plugin)) - return (str(self.external_id), str(self.plugin)) - return (str(self.external_id or self.id), str(self.plugin)) def _serialize_value(self, col: ColumnProperty) -> Any: val = getattr(self, col.key) @@ -117,14 +115,14 @@ if 'entity' not in Base.metadata: return val - def to_json(self) -> dict: + def to_dict(self) -> dict: return {col.key: self._serialize_value(col) for col in self.columns} def __repr__(self): return str(self) def __str__(self): - return json.dumps(self.to_json()) + return json.dumps(self.to_dict()) def __setattr__(self, key, value): matching_columns = [c for c in self.columns if c.expression.name == key] diff --git a/platypush/message/event/entities.py b/platypush/message/event/entities.py index 58cc007297..7a4241c0b6 100644 --- a/platypush/message/event/entities.py +++ b/platypush/message/event/entities.py @@ -7,7 +7,7 @@ from platypush.message.event import Event class EntityEvent(Event): def __init__(self, entity: Union[Entity, dict], *args, **kwargs): if isinstance(entity, Entity): - entity = entity.to_json() + entity = entity.to_dict() super().__init__(entity=entity, *args, **kwargs)