⚡ 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