Skip to content

Commit

Permalink
Improve types in _http_client.py (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe authored Feb 13, 2024
1 parent 982da30 commit 6b0d81e
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 55 deletions.
2 changes: 1 addition & 1 deletion flake8_stripe/flake8_stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TypingImportsChecker:
"Mapping",
"Tuple",
"Iterator",
"Mapping",
"MutableMapping",
"Set",
"Callable",
"Generator",
Expand Down
17 changes: 10 additions & 7 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,24 +345,27 @@ def request_headers(self, method, options: RequestOptions):
if stripe.app_info:
ua["application"] = stripe.app_info

headers: Dict[str, Optional[str]] = {
headers: Dict[str, str] = {
"X-Stripe-Client-User-Agent": json.dumps(ua),
"User-Agent": user_agent,
"Authorization": "Bearer %s" % (options.get("api_key"),),
}

if options.get("stripe_account"):
headers["Stripe-Account"] = options.get("stripe_account")
stripe_account = options.get("stripe_account")
if stripe_account:
headers["Stripe-Account"] = stripe_account

if options.get("idempotency_key"):
headers["Idempotency-Key"] = options.get("idempotency_key")
idempotency_key = options.get("idempotency_key")
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key

if method == "post":
headers.setdefault("Idempotency-Key", str(uuid.uuid4()))
headers["Content-Type"] = "application/x-www-form-urlencoded"

if options.get("stripe_version"):
headers["Stripe-Version"] = options.get("stripe_version")
stripe_version = options.get("stripe_version")
if stripe_version:
headers["Stripe-Version"] = stripe_version

return headers

Expand Down
Loading

0 comments on commit 6b0d81e

Please sign in to comment.