Skip to content

Commit f132248

Browse files
committed
docs: address Copilot review on #241
Four fixes raised in Copilot's review of #241: - Spond class example: guard `await s.get_groups()` with `or []` so iterating the result is safe when the account has no groups (the return type is documented as `list[JSONDict] | None`). - `get_events()` docstring: removed the forward-looking claim that `get_event(uid)` "queries the singular endpoint directly" — that's only true after #236 lands. Replaced with current behavior plus reference to #236 as the planned change. - `get_events()` `subgroup_id` parameter: docstring said `subgroupId` API parameter, but the code sends `subGroupId` (capital G, line 387). Aligned the docstring with the actual API param. - `update_event()` Returns section: was declared `JSONDict` but the method (due to known bug #239) currently returns `self.events`, a `list[JSONDict] | None`. Updated the Returns type to match the current contract, with the bug and workaround called out in Notes.
1 parent 2622a1a commit f132248

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

spond/spond.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Spond(_SpondBase):
5252
5353
async def main():
5454
s = spond.Spond(username="me@example.invalid", password="secret")
55-
groups = await s.get_groups()
55+
groups = await s.get_groups() or []
5656
for g in groups:
5757
print(g["name"])
5858
await s.clientsession.close()
@@ -452,17 +452,21 @@ async def get_events(
452452
and by visibility (scheduled, hidden). The full response is cached on
453453
`self.events`.
454454
455-
Note: when looking up a single event by id, prefer `get_event(uid)` —
456-
it queries the singular endpoint directly and isn't bound by
457-
`max_events` or `include_scheduled` defaults.
455+
Note: `get_event(uid)` is a wrapper around this method via the cache,
456+
so it inherits these defaults — an event that doesn't appear in the
457+
first `max_events` results or is excluded by `include_scheduled=False`
458+
is unreachable through `get_event()` on current main. PR #236 changes
459+
`get_event()` to fetch the singular `sponds/{uid}` endpoint directly,
460+
removing that coupling; until it lands, pass appropriate filters here
461+
when you need broader visibility.
458462
459463
Parameters
460464
----------
461465
group_id : str, optional
462466
Restrict to events belonging to this group. Uses `groupId` API
463467
parameter.
464468
subgroup_id : str, optional
465-
Restrict to events within this subgroup. Uses `subgroupId` API
469+
Restrict to events within this subgroup. Uses `subGroupId` API
466470
parameter.
467471
include_scheduled : bool, optional
468472
Include scheduled events (events whose invitations are queued to be
@@ -588,15 +592,22 @@ async def update_event(self, uid: str, updates: JSONDict) -> list[JSONDict] | No
588592
589593
Returns
590594
-------
591-
JSONDict
592-
Intended to be the Spond API response from the POST. **Known
593-
bug**: due to #239 the method currently returns `self.events`
594-
(the cached events list) rather than the update response.
595+
list[JSONDict] or None
596+
Currently returns `self.events` (the cached events list, or
597+
`None` if no `get_events()` call has populated it). This is a
598+
bug — see Notes.
595599
596600
Notes
597601
-----
598-
See also issue #239 for the return-value bug. The API response is
599-
still stored on `self.events_update` for inspection in the meantime.
602+
Known bug #239: the return value should be the Spond API response
603+
from the POST, not the cached events list. The API response *is*
604+
captured on `self.events_update`, so the data is still accessible
605+
as a workaround until #239 is fixed:
606+
607+
```python
608+
await s.update_event(uid, {"description": "..."})
609+
result = s.events_update # the actual API response
610+
```
600611
"""
601612
event = await self._get_entity(self._EVENT, uid)
602613
url = f"{self.api_url}sponds/{uid}"

0 commit comments

Comments
 (0)