⚡ Solution Summary

  • Use bracket notation to access items: `sub['items']`
  • Avoid using dot notation for `items` due to method conflict
  • This is a known limitation in stripe-python.
### Describe the bug So my code is: ```python client = StripeClient(settings.STRIPE_SECRET_KEY) current_subscriptions = await client.subscriptions.list_async( params={'customer': customer, 'status': 'active', 'limit': 1} ) if not current_subscriptions.data: await client.subscriptions.create_async( params={ 'customer': customer, 'items': [{'price': new_plan.stripe_id}], 'proration_behavior': 'always_invoice', } ) else: sub = current_subscriptions.data[0] print(sub, sub.items) print(sub.items.data) await client.subscriptions.update_async( sub.id, params={ 'items': [{'id': sub.items.data[0].id, 'price': new_plan.stripe_id}], 'proration_behavior': 'always_invoice', }, ) ``` When I print, I get dictionary of correct values. However, line: `print(sub.items)` returns: `<built-in method items of Subscription object at 0x7f3aa44d7050>` And because of this for `sub.items.data[0].id` I get error: `Error occurred 'builtin_function_or_method' object has no attribute 'data'` ### To Reproduce 1. Get list of subscriptions 2. Try to access one item of any subscription (in my case I max have 1) ### Expected behavior Normal data access ### Code snippets ```Python ``` ### OS Windows 11 ### Language version Python 3.11 ### Library version 11.6.0 ### API version 14.0.0 ### Additional context _No response_

Discussion & Fixes

remi-stripe 2025-12-03
@mmzeynalli It's unfortunately a limitation of stripe-python because all Stripe objects inherit from `dict` today. You have to do `sub['items']` specifically because `items` is a built-in method on `dict`. It's something we've wanted to fix for a while but it'd be a big change to not inherit from `dict` and we haven't really made the decision to move forward yet. We're tracking this in https://github.com/stripe/stripe-python/issues/1454
mmzeynalli 2025-12-03
Would it work as params after sub['items']? like sub['items'].data['items'][0]?
remi-stripe 2025-12-03
yep exactly! And you only need the bracket notation for the `items` property today. So if you did `sub.created` it works, same for `sub['items'].data[0].created`. My team helps developers in real time on our Discord server if you are interested you can just join and ask integration questions there: https://stripe.com/go/developer-chat

Get updates

We publish verified fixes weekly. No spam.

Subscribe