Skip to content

bug: Client.rate_limit returns dict instead of RateLimit object, breaking documented attribute access #129

@ausbernard

Description

@ausbernard

Bug

Client.rate_limit returns a plain dict but the README documents attribute access (.limit, .remaining, .reset).

The existing tests all pass green — but they test ApiClient directly, the internal layer:

from gocardless_pro import api_client
client = api_client.ApiClient('http://example.com', access_token)

Nobody tests Client (the public one users import). You can prove it breaks immediately:

❯ python -c "import gocardless_pro; c = gocardless_pro.Client(access_token='secret', base_url='http://example.com');
print(c.rate_limit.limit)"
AttributeError: 'dict' object has no attribute 'limit'

Fix

Added a test against the public Client — watched it fail:

FAILED tests/client_rate_limit_test.py::test_client_rate_limit_exposes_attributes
AttributeError: 'dict' object has no attribute 'limit'

Nothing in the codebase uses the dict keys ("ratelimit-limit", etc.) — every usage of client.rate_limit already expects
attribute access. The dict was dead code. One-line fix in client.py:

@property
def rate_limit(self):
    return self._api_client.rate_limit

Tests green after:

PASSED tests/client_rate_limit_test.py::test_client_rate_limit_exposes_attributes

PR Ready

Branch with the fix and new test is at ausbernard/gocardless-pro-pythonchore/recon-austin-bernard. Happy to open a PR but this repo requires collaborator access — let me know how you'd like contributions submitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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