Skip to content

Commit

Permalink
- changed: on lookups by ID, raise Error if no match; added return ty…
Browse files Browse the repository at this point in the history
…pe hints; removed redundant type hints in docstrings
  • Loading branch information
elliot-100 committed Jul 28, 2023
1 parent f543e0e commit c8d031d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import List, Optional


import aiohttp


Expand Down Expand Up @@ -49,7 +48,7 @@ async def get_groups(self):
self.groups = await r.json()
return self.groups

async def get_group(self, uid):
async def get_group(self, uid) -> dict:
"""
Get a group by unique ID.
Subject to authenticated user's access.
Expand All @@ -61,8 +60,7 @@ async def get_group(self, uid):
Returns
-------
dict
Details of the group.
Details of the group.
"""
if not self.cookie:
await self.login()
Expand All @@ -71,8 +69,9 @@ async def get_group(self, uid):
for group in self.groups:
if group["id"] == uid:
return group
raise IndexError

async def get_person(self, user):
async def get_person(self, user) -> dict:
"""
Get a member or guardian by matching various identifiers.
Subject to authenticated user's access.
Expand All @@ -85,8 +84,7 @@ async def get_person(self, user):
Returns
-------
dict
Member or guardian's details.
Member or guardian's details.
"""
if not self.cookie:
await self.login()
Expand Down Expand Up @@ -114,6 +112,7 @@ async def get_person(self, user):
)
):
return guardian
raise IndexError

async def get_messages(self):
if not self.cookie:
Expand Down Expand Up @@ -267,7 +266,7 @@ async def get_events(
self.events = await r.json()
return self.events

async def get_event(self, uid):
async def get_event(self, uid) -> dict:
"""
Get an event by unique ID.
Subject to authenticated user's access.
Expand All @@ -279,8 +278,7 @@ async def get_event(self, uid):
Returns
-------
dict
Details of the event.
Details of the event.
"""
if not self.cookie:
await self.login()
Expand All @@ -289,6 +287,7 @@ async def get_event(self, uid):
for event in self.events:
if event["id"] == uid:
return event
raise IndexError

async def update_event(self, uid, updates: dict):
"""
Expand Down

0 comments on commit c8d031d

Please sign in to comment.