From 23f2690c54558c48e77b3653792674837ec67207 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 26 Jan 2023 17:51:15 +0100 Subject: [PATCH] convert StatusResult to a dataclass This gives us nice str() functions. --- nominatim/api/status.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nominatim/api/status.py b/nominatim/api/status.py index a992460c..c8ebbefa 100644 --- a/nominatim/api/status.py +++ b/nominatim/api/status.py @@ -9,6 +9,7 @@ Classes and function releated to status call. """ from typing import Optional, cast import datetime as dt +import dataclasses import sqlalchemy as sa import asyncpg @@ -16,16 +17,15 @@ import asyncpg from nominatim.api.connection import SearchConnection from nominatim import version +@dataclasses.dataclass class StatusResult: """ Result of a call to the status API. """ - - def __init__(self, status: int, msg: str): - self.status = status - self.message = msg - self.software_version = version.NOMINATIM_VERSION - self.data_updated: Optional[dt.datetime] = None - self.database_version: Optional[version.NominatimVersion] = None + status: int + message: str + software_version = version.NOMINATIM_VERSION + data_updated: Optional[dt.datetime] = None + database_version: Optional[version.NominatimVersion] = None async def _get_database_date(conn: SearchConnection) -> Optional[dt.datetime]: -- 2.39.5