refactor: Update Log message field to allow list type

Update the Log class in schema.py to allow the message field to accept a list type in addition to str, dict, and StreamURL. This change enhances the flexibility of the Log class and accommodates scenarios where multiple messages need to be stored.
This commit is contained in:
ogabrielluiz 2024-06-12 17:35:30 -03:00
commit dc37f279e0

View file

@ -1,5 +1,5 @@
from collections import defaultdict
from typing import Literal
from typing import Any, Literal
from typing_extensions import TypedDict
@ -14,7 +14,7 @@ class StreamURL(TypedDict):
class Log(TypedDict):
message: str | dict | StreamURL
message: str | dict | StreamURL | list
type: str
@ -33,5 +33,8 @@ def build_logs_from_artifacts(artifacts: dict) -> dict:
log = Log(message=message, type=message["type"])
logs[key].append(log)
return logs
def build_log_from_raw_and_type(raw: Any, log_type: str) -> Log:
return Log(message=raw, type=log_type)