Description
Describe the bug
As described in this issue we can use either python dot or dict notation for accessing API response values.
For the types included in the library, dot notation successfully returns the correct types:
whereas using dict notation results in everything you access being set to Any
This is fine, however there's an issue with using dot notation (also mentioned in the other issue) where calling subscription.items
results in a crash because it tries to access dict's items()
function instead.
This means the types can't be relied upon. It also means there's no way of using the types without people knowing they need to access items
in a different way.
Is there a workaround for this? Or a fix?
To Reproduce
- Use a python type checking system (we use pyright)
- Try and access the plan object from a subscription response using
plan = subscription.items.data[0].plan
. It will crash, but the plan type will be set correctly - Instead, try accessing using
plan = subscription['items']['data'][0]['plan']
. It will work, but the types will be wrong.
Expected behavior
At least one of the following should be happen (ideally both):
- The types should fail when accessing items using dot notation
- The types should return the correct value when using dict notation
Code snippets
No response
OS
macOS
Language version
python 3.8.10
Library version
stripe-python 7.14.0
API version
2023-10-16
Additional context
No response