From b63eb0c8682ac9a377338fc4c2f9e116801d0445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Du=C3=A9=C3=B1ez-Guzm=C3=A1n?= Date: Sun, 7 Jul 2024 08:46:27 -0700 Subject: [PATCH] Improve typing and return value of `get_last_log` in `EntityComponent`. PiperOrigin-RevId: 650018400 Change-Id: I473a7a2b76186089a9c87c355ce4ef0465fcc915 --- concordia/typing/component_v2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/concordia/typing/component_v2.py b/concordia/typing/component_v2.py index 6bb923b..b98abff 100644 --- a/concordia/typing/component_v2.py +++ b/concordia/typing/component_v2.py @@ -17,6 +17,8 @@ import abc from collections.abc import Mapping import enum +import types +from typing import Any from concordia.typing import entity as entity_lib @@ -24,6 +26,8 @@ ComponentContext = str ComponentContextMapping = Mapping[ComponentName, ComponentContext] +_EMPTY_MAPPING = types.MappingProxyType({}) + class Phase(enum.Enum): """Phases of a component entity lifecycle. @@ -180,9 +184,9 @@ def update( def get_last_log( self, - ): + ) -> Mapping[str, Any]: """Returns a dictionary with latest log of activity.""" - return None + return _EMPTY_MAPPING class ActingComponent(BaseComponent, metaclass=abc.ABCMeta):