Improved typing

This commit is contained in:
Profitroll 2024-05-30 23:18:33 +02:00 committed by Profitroll
parent 7293cafd2e
commit 0562521f0d
3 changed files with 6 additions and 6 deletions

View File

@ -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:

View File

@ -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"]
]

View File

@ -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: