From baf4972551b18be837047db08e0b3ed2b8fb2eea Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 6 Nov 2023 07:55:48 +0100 Subject: [PATCH 1/2] Refactoring: using Optional type --- mocks/service-log/service_log.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mocks/service-log/service_log.py b/mocks/service-log/service_log.py index 5031a80e..4cef60c3 100644 --- a/mocks/service-log/service_log.py +++ b/mocks/service-log/service_log.py @@ -80,7 +80,7 @@ import string from datetime import datetime -from typing import Union +from typing import Optional from fastapi import FastAPI, Request, Response, status from fastapi.exceptions import RequestValidationError @@ -114,16 +114,16 @@ class Log(BaseModel): """Model for log structure received by Service Log.""" cluster_uuid: str - cluster_id: Union[str, None] = None - subscription_id: Union[str, None] = None + cluster_id: Optional[str] = None + subscription_id: Optional[str] = None summary: str - description: Union[str, None] = None + description: Optional[str] = None internal_only: Union[bool, None] = None service_name: str - severity: Union[str, None] = "Info" - timestamp: Union[str, None] = None # default will be current time - username: Union[str, None] = None - event_stream_id: Union[str, None] = None # default will be a random ksuid + severity: Optional[str] = "Info" + timestamp: Optional[str] = None # default will be current time + username: Optional[str] = None + event_stream_id: Optional[str] = None # default will be a random ksuid class ReturnLog(Log): From 4aa8d8ee5e8bf3e37021601b7b575fd9597e2a7f Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 6 Nov 2023 07:57:55 +0100 Subject: [PATCH 2/2] One more refactoring --- mocks/service-log/service_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mocks/service-log/service_log.py b/mocks/service-log/service_log.py index 4cef60c3..118ac317 100644 --- a/mocks/service-log/service_log.py +++ b/mocks/service-log/service_log.py @@ -118,7 +118,7 @@ class Log(BaseModel): subscription_id: Optional[str] = None summary: str description: Optional[str] = None - internal_only: Union[bool, None] = None + internal_only: Optional[bool] = None service_name: str severity: Optional[str] = "Info" timestamp: Optional[str] = None # default will be current time