Skip to content

update_event() returns cached events list instead of the API update response #239

@Olen

Description

@Olen

Caught during the pdoc/docstring audit in #237.

`Spond.update_event()` is annotated `-> list[JSONDict] | None` and the docstring says it returns "json results of post command". But the implementation at `spond/spond.py:451-455`:

```python
async with self.clientsession.post(
url, json=base_event, headers=self.auth_headers
) as r:
self.events_update = await r.json()
return self.events
```

The API response is saved to `self.events_update` but the method returns `self.events` — the unrelated cached events list (potentially `None` if `get_events()` was never called). So callers asking "did my update succeed, and what did the server return?" get the wrong thing back.

Looks like a typo from a long-ago refactor: assigning the result to `self.events_update` reads like an intentional "don't trample the cache", but then returning `self.events` instead of `self.events_update` (or just `await r.json()`) is almost certainly unintended.

Suggested fix

Pick one of:

```python

Option A: just return the response directly, drop the side-effect attribute

return await r.json()

Option B: keep the attribute, return it

self.events_update = await r.json()
return self.events_update
```

Option A is cleaner — `self.events_update` isn't referenced anywhere else in the codebase, so keeping it just creates an extra attribute on the class.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions