Problem
API.send_request returns a bare dict/list normally, but a wrapped {"data": ..., "limit_usage": ..., "header": ...} when show_limit_usage/show_header is enabled. The shape of the return value depends on a constructor flag, so callers can't write stable code against it (and resource methods special-case res["data"]).
Proposal
Make the return shape consistent. Options to weigh:
- Always return a small typed envelope (e.g.
Response(data=..., limit_usage=..., headers=...)), limit_usage/headers populated only when requested.
- Keep returning
data by default but expose metadata via a side channel (e.g. client.last_response) instead of changing the return type.
Prefer (1) for explicitness; needs a deprecation path since it changes today's default return for flag users.
Acceptance
- Return type no longer branches on
show_limit_usage/show_header.
- Resource methods stop guarding on
res["data"] is None.
Problem
API.send_requestreturns a baredict/listnormally, but a wrapped{"data": ..., "limit_usage": ..., "header": ...}whenshow_limit_usage/show_headeris enabled. The shape of the return value depends on a constructor flag, so callers can't write stable code against it (and resource methods special-caseres["data"]).Proposal
Make the return shape consistent. Options to weigh:
Response(data=..., limit_usage=..., headers=...)),limit_usage/headerspopulated only when requested.databy default but expose metadata via a side channel (e.g.client.last_response) instead of changing the return type.Prefer (1) for explicitness; needs a deprecation path since it changes today's default return for flag users.
Acceptance
show_limit_usage/show_header.res["data"] is None.