Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: fix documentation and type hints where functions may return None #148

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ async def login_chat(self) -> None:
self.auth = result["auth"]

@_SpondBase.require_authentication
async def get_groups(self) -> list[dict]:
async def get_groups(self) -> Optional[list[dict]]:
"""
Get all groups.
Subject to authenticated user's access.
Retrieve all groups, subject to authenticated user's access.

Returns
-------
list of dict
Groups; each group is a dict.
list[dict] or None
A list of groups, each represented as a dictionary, or None if no groups
are available.

"""
url = f"{self.api_url}groups/"
async with self.clientsession.get(url, headers=self.auth_headers) as r:
Expand Down Expand Up @@ -116,7 +117,17 @@ async def get_person(self, user: str) -> dict:
raise KeyError(errmsg)

@_SpondBase.require_authentication
async def get_messages(self) -> list[dict]:
async def get_messages(self) -> Optional[list[dict]]:
"""
Retrieve messages (chats).

Returns
-------
list[dict] or None
A list of chats, each represented as a dictionary, or None if no chats
are available.

"""
if not self.auth:
await self.login_chat()
url = f"{self.chat_url}/chats/?max=10"
Expand Down Expand Up @@ -216,10 +227,9 @@ async def get_events(
max_start: Optional[datetime] = None,
min_start: Optional[datetime] = None,
max_events: int = 100,
) -> list[dict]:
) -> Optional[list[dict]]:
"""
Get events.
Subject to authenticated user's access.
Retrieve events.

Parameters
----------
Expand Down Expand Up @@ -255,8 +265,10 @@ async def get_events(

Returns
-------
list of dict
Events; each event is a dict.
list[dict] or None
A list of events, each represented as a dictionary, or None if no events
are available.

"""
url = f"{self.api_url}sponds/"
params = {
Expand Down