The Fix
pip install stripe==14.4.0a2
Based on closed stripe/stripe-python issue #1427 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -19,6 +19,7 @@
from stripe import StripeClient
from stripe.events import UnknownEventNotification
+from stripe.events import ALL_EVENT_NOTIFICATIONS
from flask import Flask, request, jsonify
from __future__ import annotations
from typing import TYPE_CHECKING, Protocol, Type
from django.conf import settings
if TYPE_CHECKING:
import stripe
class StripeTestHelpers(Protocol):
TestClock: Type[stripe.test_helpers.TestClock]
class StripeBilling(Protocol):
Session: Type[stripe.billing_portal.Session]
class StripeModule(Protocol):
billing_portal: StripeBilling
test_helpers: StripeTestHelpers
Customer: Type[stripe.Customer]
Invoice: Type[stripe.Invoice]
CardError: Type[stripe.CardError]
InvalidRequestError: Type[stripe.InvalidRequestError]
AuthenticationError: Type[stripe.AuthenticationError]
APIConnectionError: Type[stripe.APIConnectionError]
StripeError: Type[stripe.StripeError]
Subscription: Type[stripe.Subscription]
Token: Type[stripe.Token]
Price: Type[stripe.Price]
BalanceTransaction: Type[stripe.BalanceTransaction]
PaymentMethod: Type[stripe.PaymentMethod]
def get_stripe_client() -> StripeModule:
import stripe
stripe.api_key = settings.STRIPE_SECRET_KEY
stripe.api_version = "2019-12-03"
return stripe
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install stripe==14.4.0a2\nWhen NOT to use: This fix is not suitable for environments where import speed is not critical.\n\n
Why This Fix Works in Production
- Trigger: from __future__ import annotations
- Mechanism: The library's import process was inefficient, causing significant delays during startup
- Why the fix works: Dramatically improves import speeds and memory usage by lazily loading most imports, addressing the performance issues raised in issue #1427. (first fixed release: 14.4.0a2).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Shows up under Python 3.13 in real deployments (not just unit tests).
- The library's import process was inefficient, causing significant delays during startup
- Surfaces as: from __future__ import annotations
Proof / Evidence
- GitHub issue: #1427
- Fix PR: https://github.com/stripe/stripe-python/pull/1645
- First fixed release: 14.4.0a2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.32
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Amazing! The only reason it's not ready for review yet is that i'm actually making it even faster 😅 Glad to hear it's working as…”
“We released a bunch of performance improvements in v13.1.0 which came out this week”
“Over 50% of start time for our app is by the stripe SDK, and like others have observed, RAM usage has crept up as the…”
“Upgraded from an old version and got a major increase of memory usage. Tried several versions from major 9 to 12. None seemed to be…”
Failure Signature (Search String)
- from __future__ import annotations
Error Message
Stack trace
Error Message
-------------
from __future__ import annotations
from typing import TYPE_CHECKING, Protocol, Type
from django.conf import settings
if TYPE_CHECKING:
import stripe
class StripeTestHelpers(Protocol):
TestClock: Type[stripe.test_helpers.TestClock]
class StripeBilling(Protocol):
Session: Type[stripe.billing_portal.Session]
class StripeModule(Protocol):
billing_portal: StripeBilling
test_helpers: StripeTestHelpers
Customer: Type[stripe.Customer]
Invoice: Type[stripe.Invoice]
CardError: Type[stripe.CardError]
InvalidRequestError: Type[stripe.InvalidRequestError]
AuthenticationError: Type[stripe.AuthenticationError]
APIConnectionError: Type[stripe.APIConnectionError]
StripeError: Type[stripe.StripeError]
Subscription: Type[stripe.Subscription]
Token: Type[stripe.Token]
Price: Type[stripe.Price]
BalanceTransaction: Type[stripe.BalanceTransaction]
PaymentMethod: Type[stripe.PaymentMethod]
def get_stripe_client() -> StripeModule:
import stripe
stripe.api_key = settings.STRIPE_SECRET_KEY
stripe.api_version = "2019-12-03"
return stripe
Minimal Reproduction
from __future__ import annotations
from typing import TYPE_CHECKING, Protocol, Type
from django.conf import settings
if TYPE_CHECKING:
import stripe
class StripeTestHelpers(Protocol):
TestClock: Type[stripe.test_helpers.TestClock]
class StripeBilling(Protocol):
Session: Type[stripe.billing_portal.Session]
class StripeModule(Protocol):
billing_portal: StripeBilling
test_helpers: StripeTestHelpers
Customer: Type[stripe.Customer]
Invoice: Type[stripe.Invoice]
CardError: Type[stripe.CardError]
InvalidRequestError: Type[stripe.InvalidRequestError]
AuthenticationError: Type[stripe.AuthenticationError]
APIConnectionError: Type[stripe.APIConnectionError]
StripeError: Type[stripe.StripeError]
Subscription: Type[stripe.Subscription]
Token: Type[stripe.Token]
Price: Type[stripe.Price]
BalanceTransaction: Type[stripe.BalanceTransaction]
PaymentMethod: Type[stripe.PaymentMethod]
def get_stripe_client() -> StripeModule:
import stripe
stripe.api_key = settings.STRIPE_SECRET_KEY
stripe.api_version = "2019-12-03"
return stripe
Environment
- Python: 3.13
What Broke
Importing the library resulted in a 500ms delay, impacting serverless cold start performance.
Why It Broke
The library's import process was inefficient, causing significant delays during startup
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install stripe==14.4.0a2
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/stripe/stripe-python/pull/1645
First fixed release: 14.4.0a2
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable for environments where import speed is not critical.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 14.4.0a2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.