Read a key from a Stripe object. stripe.StripeObject implements __getitem__ but not .get() — calling .get() on one raises AttributeError rather than returning a default. This works for both StripeObject and plain dicts.
(obj, key, default=None)
| 99 | # --- Helpers ---------------------------------------------------------------- |
| 100 | |
| 101 | def sget(obj, key, default=None): |
| 102 | """ |
| 103 | Read a key from a Stripe object. |
| 104 | |
| 105 | stripe.StripeObject implements __getitem__ but not .get() — calling .get() |
| 106 | on one raises AttributeError rather than returning a default. This works for |
| 107 | both StripeObject and plain dicts. |
| 108 | """ |
| 109 | if obj is None: |
| 110 | return default |
| 111 | try: |
| 112 | return obj[key] |
| 113 | except (KeyError, TypeError, AttributeError, IndexError): |
| 114 | return default |
| 115 | |
| 116 | |
| 117 | def _now_iso() -> str: |
no outgoing calls
no test coverage detected