From 48bb3cc4a3de8a83ecda08afb5b9e0fa72fdb730 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 30 May 2024 23:18:33 +0200 Subject: [PATCH] Improved typing --- classes/callbacks.py | 2 +- classes/garbage_entry.py | 4 ++-- classes/location.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/callbacks.py b/classes/callbacks.py index 0093c9b..4b111be 100644 --- a/classes/callbacks.py +++ b/classes/callbacks.py @@ -10,7 +10,7 @@ class CallbackLanguage: language: str @classmethod - def from_callback(cls, callback: CallbackQuery): + def from_callback(cls, callback: CallbackQuery) -> "CallbackLanguage": """Parse callback query and extract language data from it. ### Args: diff --git a/classes/garbage_entry.py b/classes/garbage_entry.py index 7c97b60..644c305 100644 --- a/classes/garbage_entry.py +++ b/classes/garbage_entry.py @@ -23,7 +23,7 @@ class GarbageEntry: date: datetime @classmethod - async def from_dict(cls, data: Mapping[str, Any]): + async def from_dict(cls, data: Mapping[str, Any]) -> "GarbageEntry": """Generate GarbageEntry object from the mapping provided ### Args: @@ -60,7 +60,7 @@ class GarbageEntry: ) @classmethod - async def from_record(cls, data: Mapping[str, Any]): + async def from_record(cls, data: Mapping[str, Any]) -> "GarbageEntry": locations = [ await Location.get(location_id) for location_id in data["locations"] ] diff --git a/classes/location.py b/classes/location.py index 5a29557..57497a3 100644 --- a/classes/location.py +++ b/classes/location.py @@ -28,7 +28,7 @@ class Location: timezone: Union[BaseTzInfo, DstTzInfo] @classmethod - async def get(cls, id: int): + async def get(cls, id: int) -> "Location": db_entry = await col_locations.find_one({"id": id}) if db_entry is None: @@ -40,7 +40,7 @@ class Location: return cls(**db_entry) @classmethod - async def find(cls, name: str): + async def find(cls, name: str) -> "Location": db_entry = await col_locations.find_one({"name": {"$regex": name}}) if db_entry is None: @@ -52,7 +52,7 @@ class Location: return cls(**db_entry) @classmethod - async def nearby(cls, lat: float, lon: float): + async def nearby(cls, lat: float, lon: float) -> "Location": db_entry = await col_locations.find_one({"location": {"$near": [lon, lat]}}) if db_entry is None: