Skip to content

Commit

Permalink
Add optional types to non-required fields (#1057)
Browse files Browse the repository at this point in the history
* Deleted fields

* Optional[...] for non-required properties
  • Loading branch information
richardm-stripe authored Sep 21, 2023
1 parent 1ed5ad8 commit c264fd9
Show file tree
Hide file tree
Showing 60 changed files with 308 additions and 294 deletions.
34 changes: 17 additions & 17 deletions stripe/api_resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@ class Account(
"""

OBJECT_NAME = "account"
deleted: bool
business_profile: Optional[StripeObject]
business_type: Optional[
Literal["company", "government_entity", "individual", "non_profit"]
]
capabilities: StripeObject
charges_enabled: bool
company: StripeObject
controller: StripeObject
country: str
created: int
default_currency: str
details_submitted: bool
capabilities: Optional[StripeObject]
charges_enabled: Optional[bool]
company: Optional[StripeObject]
controller: Optional[StripeObject]
country: Optional[str]
created: Optional[int]
default_currency: Optional[str]
details_submitted: Optional[bool]
email: Optional[str]
external_accounts: ListObject[Any]
future_requirements: StripeObject
external_accounts: Optional[ListObject[Any]]
future_requirements: Optional[StripeObject]
id: str
individual: "Person"
metadata: Dict[str, str]
individual: Optional["Person"]
metadata: Optional[Dict[str, str]]
object: Literal["account"]
payouts_enabled: bool
requirements: StripeObject
payouts_enabled: Optional[bool]
requirements: Optional[StripeObject]
settings: Optional[StripeObject]
tos_acceptance: StripeObject
type: Literal["custom", "express", "standard"]
tos_acceptance: Optional[StripeObject]
type: Optional[Literal["custom", "express", "standard"]]
deleted: Optional[Literal[True]]

@classmethod
def create(
Expand Down
4 changes: 2 additions & 2 deletions stripe/api_resources/apple_pay_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ListableAPIResource,
)
from stripe.api_resources.list_object import ListObject
from typing import cast
from typing import Optional, cast
from typing_extensions import Literal
from urllib.parse import quote_plus

Expand All @@ -20,12 +20,12 @@ class ApplePayDomain(
ListableAPIResource["ApplePayDomain"],
):
OBJECT_NAME = "apple_pay_domain"
deleted: bool
created: int
domain_name: str
id: str
livemode: bool
object: Literal["apple_pay_domain"]
deleted: Optional[Literal[True]]

@classmethod
def create(
Expand Down
2 changes: 1 addition & 1 deletion stripe/api_resources/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Application(StripeObject):
OBJECT_NAME = "application"
deleted: bool
id: str
name: Optional[str]
object: Literal["application"]
deleted: Optional[Literal[True]]
2 changes: 1 addition & 1 deletion stripe/api_resources/apps/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Secret(CreateableAPIResource["Secret"], ListableAPIResource["Secret"]):

OBJECT_NAME = "apps.secret"
created: int
deleted: bool
deleted: Optional[bool]
expires_at: Optional[int]
id: str
livemode: bool
Expand Down
8 changes: 4 additions & 4 deletions stripe/api_resources/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from stripe.api_resources.abstract import SingletonAPIResource
from stripe.stripe_object import StripeObject
from typing import List
from typing import List, Optional
from typing_extensions import Literal


Expand All @@ -25,9 +25,9 @@ class Balance(SingletonAPIResource["Balance"]):

OBJECT_NAME = "balance"
available: List[StripeObject]
connect_reserved: List[StripeObject]
instant_available: List[StripeObject]
issuing: StripeObject
connect_reserved: Optional[List[StripeObject]]
instant_available: Optional[List[StripeObject]]
issuing: Optional[StripeObject]
livemode: bool
object: Literal["balance"]
pending: List[StripeObject]
Expand Down
2 changes: 1 addition & 1 deletion stripe/api_resources/bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BankAccount(
"""

OBJECT_NAME = "bank_account"
deleted: bool
account: Optional[ExpandableField["Account"]]
account_holder_name: Optional[str]
account_holder_type: Optional[str]
Expand All @@ -53,6 +52,7 @@ class BankAccount(
requirements: Optional[StripeObject]
routing_number: Optional[str]
status: str
deleted: Optional[Literal[True]]

@classmethod
def _cls_delete(cls, sid, **params) -> Any:
Expand Down
4 changes: 2 additions & 2 deletions stripe/api_resources/capability.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Capability(UpdateableAPIResource["Capability"]):

OBJECT_NAME = "capability"
account: ExpandableField["Account"]
future_requirements: StripeObject
future_requirements: Optional[StripeObject]
id: str
object: Literal["capability"]
requested: bool
requested_at: Optional[int]
requirements: StripeObject
requirements: Optional[StripeObject]
status: Literal["active", "disabled", "inactive", "pending", "unrequested"]

def instance_url(self):
Expand Down
8 changes: 4 additions & 4 deletions stripe/api_resources/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Card(DeletableAPIResource["Card"], UpdateableAPIResource["Card"]):
"""

OBJECT_NAME = "card"
deleted: bool
account: Optional[ExpandableField["Account"]]
address_city: Optional[str]
address_country: Optional[str]
Expand All @@ -42,21 +41,22 @@ class Card(DeletableAPIResource["Card"], UpdateableAPIResource["Card"]):
customer: Optional[ExpandableField[Any]]
cvc_check: Optional[str]
default_for_currency: Optional[bool]
description: str
description: Optional[str]
dynamic_last4: Optional[str]
exp_month: int
exp_year: int
fingerprint: Optional[str]
funding: str
id: str
iin: str
issuer: str
iin: Optional[str]
issuer: Optional[str]
last4: str
metadata: Optional[Dict[str, str]]
name: Optional[str]
object: Literal["card"]
status: Optional[str]
tokenization_method: Optional[str]
deleted: Optional[Literal[True]]

@classmethod
def _cls_delete(cls, sid, **params) -> Any:
Expand Down
8 changes: 4 additions & 4 deletions stripe/api_resources/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Charge(
application: Optional[ExpandableField["Application"]]
application_fee: Optional[ExpandableField["ApplicationFee"]]
application_fee_amount: Optional[int]
authorization_code: str
authorization_code: Optional[str]
balance_transaction: Optional[ExpandableField["BalanceTransaction"]]
billing_details: StripeObject
calculated_statement_descriptor: Optional[str]
Expand All @@ -68,7 +68,7 @@ class Charge(
fraud_details: Optional[StripeObject]
id: str
invoice: Optional[ExpandableField["Invoice"]]
level3: StripeObject
level3: Optional[StripeObject]
livemode: bool
metadata: Dict[str, str]
object: Literal["charge"]
Expand All @@ -78,7 +78,7 @@ class Charge(
payment_intent: Optional[ExpandableField["PaymentIntent"]]
payment_method: Optional[str]
payment_method_details: Optional[StripeObject]
radar_options: StripeObject
radar_options: Optional[StripeObject]
receipt_email: Optional[str]
receipt_number: Optional[str]
receipt_url: Optional[str]
Expand All @@ -91,7 +91,7 @@ class Charge(
statement_descriptor: Optional[str]
statement_descriptor_suffix: Optional[str]
status: Literal["failed", "pending", "succeeded"]
transfer: ExpandableField["Transfer"]
transfer: Optional[ExpandableField["Transfer"]]
transfer_data: Optional[StripeObject]
transfer_group: Optional[str]

Expand Down
6 changes: 3 additions & 3 deletions stripe/api_resources/checkout/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Session(
id: str
invoice: Optional[ExpandableField["Invoice"]]
invoice_creation: Optional[StripeObject]
line_items: ListObject["LineItem"]
line_items: Optional[ListObject["LineItem"]]
livemode: bool
locale: Optional[
Literal[
Expand Down Expand Up @@ -125,7 +125,7 @@ class Session(
payment_method_options: Optional[StripeObject]
payment_method_types: List[str]
payment_status: Literal["no_payment_required", "paid", "unpaid"]
phone_number_collection: StripeObject
phone_number_collection: Optional[StripeObject]
recovered_from: Optional[str]
setup_intent: Optional[ExpandableField["SetupIntent"]]
shipping_address_collection: Optional[StripeObject]
Expand All @@ -136,7 +136,7 @@ class Session(
submit_type: Optional[Literal["auto", "book", "donate", "pay"]]
subscription: Optional[ExpandableField["Subscription"]]
success_url: Optional[str]
tax_id_collection: StripeObject
tax_id_collection: Optional[StripeObject]
total_details: Optional[StripeObject]
url: Optional[str]

Expand Down
6 changes: 3 additions & 3 deletions stripe/api_resources/coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ class Coupon(
"""

OBJECT_NAME = "coupon"
deleted: bool
amount_off: Optional[int]
applies_to: StripeObject
applies_to: Optional[StripeObject]
created: int
currency: Optional[str]
currency_options: Dict[str, StripeObject]
currency_options: Optional[Dict[str, StripeObject]]
duration: Literal["forever", "once", "repeating"]
duration_in_months: Optional[int]
id: str
Expand All @@ -47,6 +46,7 @@ class Coupon(
redeem_by: Optional[int]
times_redeemed: int
valid: bool
deleted: Optional[Literal[True]]

@classmethod
def create(
Expand Down
2 changes: 1 addition & 1 deletion stripe/api_resources/credit_note_line_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CreditNoteLineItem(ListableAPIResource["CreditNoteLineItem"]):
discount_amount: int
discount_amounts: List[StripeObject]
id: str
invoice_line_item: str
invoice_line_item: Optional[str]
livemode: bool
object: Literal["credit_note_line_item"]
quantity: Optional[int]
Expand Down
20 changes: 10 additions & 10 deletions stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ class Customer(
"""

OBJECT_NAME = "customer"
deleted: bool
address: Optional[StripeObject]
balance: int
balance: Optional[int]
cash_balance: Optional["CashBalance"]
created: int
currency: Optional[str]
Expand All @@ -59,23 +58,24 @@ class Customer(
discount: Optional["Discount"]
email: Optional[str]
id: str
invoice_credit_balance: Dict[str, int]
invoice_credit_balance: Optional[Dict[str, int]]
invoice_prefix: Optional[str]
invoice_settings: StripeObject
invoice_settings: Optional[StripeObject]
livemode: bool
metadata: Dict[str, str]
metadata: Optional[Dict[str, str]]
name: Optional[str]
next_invoice_sequence: int
next_invoice_sequence: Optional[int]
object: Literal["customer"]
phone: Optional[str]
preferred_locales: Optional[List[str]]
shipping: Optional[StripeObject]
sources: ListObject[Any]
subscriptions: ListObject["Subscription"]
tax: StripeObject
sources: Optional[ListObject[Any]]
subscriptions: Optional[ListObject["Subscription"]]
tax: Optional[StripeObject]
tax_exempt: Optional[Literal["exempt", "none", "reverse"]]
tax_ids: ListObject["TaxId"]
tax_ids: Optional[ListObject["TaxId"]]
test_clock: Optional[ExpandableField["TestClock"]]
deleted: Optional[Literal[True]]

@classmethod
def create(
Expand Down
11 changes: 6 additions & 5 deletions stripe/api_resources/customer_cash_balance_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from stripe.api_resources.expandable_field import ExpandableField
from stripe.api_resources.list_object import ListObject
from stripe.stripe_object import StripeObject
from typing import Optional
from typing_extensions import Literal

from typing_extensions import TYPE_CHECKING
Expand All @@ -25,18 +26,18 @@ class CustomerCashBalanceTransaction(
"""

OBJECT_NAME = "customer_cash_balance_transaction"
adjusted_for_overdraft: StripeObject
applied_to_payment: StripeObject
adjusted_for_overdraft: Optional[StripeObject]
applied_to_payment: Optional[StripeObject]
created: int
currency: str
customer: ExpandableField["Customer"]
ending_balance: int
funded: StripeObject
funded: Optional[StripeObject]
id: str
livemode: bool
net_amount: int
object: Literal["customer_cash_balance_transaction"]
refunded_from_payment: StripeObject
refunded_from_payment: Optional[StripeObject]
type: Literal[
"adjusted_for_overdraft",
"applied_to_payment",
Expand All @@ -47,7 +48,7 @@ class CustomerCashBalanceTransaction(
"return_initiated",
"unapplied_from_payment",
]
unapplied_from_payment: StripeObject
unapplied_from_payment: Optional[StripeObject]

@classmethod
def list(
Expand Down
2 changes: 1 addition & 1 deletion stripe/api_resources/discount.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Discount(StripeObject):
"""

OBJECT_NAME = "discount"
deleted: bool
checkout_session: Optional[str]
coupon: "Coupon"
customer: Optional[ExpandableField[Any]]
Expand All @@ -35,3 +34,4 @@ class Discount(StripeObject):
promotion_code: Optional[ExpandableField["PromotionCode"]]
start: int
subscription: Optional[str]
deleted: Optional[Literal[True]]
2 changes: 1 addition & 1 deletion stripe/api_resources/dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Dispute(
network_reason_code: Optional[str]
object: Literal["dispute"]
payment_intent: Optional[ExpandableField["PaymentIntent"]]
payment_method_details: StripeObject
payment_method_details: Optional[StripeObject]
reason: str
status: Literal[
"lost",
Expand Down
4 changes: 2 additions & 2 deletions stripe/api_resources/ephemeral_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from stripe import api_requestor, util
from stripe.api_resources.abstract import DeletableAPIResource
from typing import cast
from typing import Optional, cast
from typing_extensions import Literal
from urllib.parse import quote_plus

Expand All @@ -16,7 +16,7 @@ class EphemeralKey(DeletableAPIResource["EphemeralKey"]):
id: str
livemode: bool
object: Literal["ephemeral_key"]
secret: str
secret: Optional[str]

@classmethod
def _cls_delete(cls, sid, **params) -> "EphemeralKey":
Expand Down
Loading

0 comments on commit c264fd9

Please sign in to comment.