Improved typing
This commit is contained in:
parent
97141be93e
commit
48bb3cc4a3
@ -10,7 +10,7 @@ class CallbackLanguage:
|
|||||||
language: str
|
language: str
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_callback(cls, callback: CallbackQuery):
|
def from_callback(cls, callback: CallbackQuery) -> "CallbackLanguage":
|
||||||
"""Parse callback query and extract language data from it.
|
"""Parse callback query and extract language data from it.
|
||||||
|
|
||||||
### Args:
|
### Args:
|
||||||
|
@ -23,7 +23,7 @@ class GarbageEntry:
|
|||||||
date: datetime
|
date: datetime
|
||||||
|
|
||||||
@classmethod
|
@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
|
"""Generate GarbageEntry object from the mapping provided
|
||||||
|
|
||||||
### Args:
|
### Args:
|
||||||
@ -60,7 +60,7 @@ class GarbageEntry:
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def from_record(cls, data: Mapping[str, Any]):
|
async def from_record(cls, data: Mapping[str, Any]) -> "GarbageEntry":
|
||||||
locations = [
|
locations = [
|
||||||
await Location.get(location_id) for location_id in data["locations"]
|
await Location.get(location_id) for location_id in data["locations"]
|
||||||
]
|
]
|
||||||
|
@ -28,7 +28,7 @@ class Location:
|
|||||||
timezone: Union[BaseTzInfo, DstTzInfo]
|
timezone: Union[BaseTzInfo, DstTzInfo]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get(cls, id: int):
|
async def get(cls, id: int) -> "Location":
|
||||||
db_entry = await col_locations.find_one({"id": id})
|
db_entry = await col_locations.find_one({"id": id})
|
||||||
|
|
||||||
if db_entry is None:
|
if db_entry is None:
|
||||||
@ -40,7 +40,7 @@ class Location:
|
|||||||
return cls(**db_entry)
|
return cls(**db_entry)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def find(cls, name: str):
|
async def find(cls, name: str) -> "Location":
|
||||||
db_entry = await col_locations.find_one({"name": {"$regex": name}})
|
db_entry = await col_locations.find_one({"name": {"$regex": name}})
|
||||||
|
|
||||||
if db_entry is None:
|
if db_entry is None:
|
||||||
@ -52,7 +52,7 @@ class Location:
|
|||||||
return cls(**db_entry)
|
return cls(**db_entry)
|
||||||
|
|
||||||
@classmethod
|
@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]}})
|
db_entry = await col_locations.find_one({"location": {"$near": [lon, lat]}})
|
||||||
|
|
||||||
if db_entry is None:
|
if db_entry is None:
|
||||||
|
Reference in New Issue
Block a user