Skip to content

Consistent return shape regardless of show_limit_usage/show_header #140

Description

@martinkersner

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:

  1. Always return a small typed envelope (e.g. Response(data=..., limit_usage=..., headers=...)), limit_usage/headers populated only when requested.
  2. 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.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions