Skip to content

Commit

Permalink
Fix and wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Nov 14, 2023
1 parent 9bf078d commit 8670792
Show file tree
Hide file tree
Showing 91 changed files with 33,479 additions and 35,392 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,36 @@ stripe.enable_telemetry = False
## Types
In [v7.1.0](https://github.com/stripe/stripe-python/releases/tag/v7.1.0), the
In [v7.1.0](https://github.com/stripe/stripe-python/releases/tag/v7.1.0) and
newer, the
library includes type annotations. See [the wiki](https://github.com/stripe/stripe-python/wiki/Inline-type-annotations)
for a detailed guide.
Please note that some annotations use features that were only fairly recently accepted, such as [`Unpack[TypedDict]`](https://peps.python.org/pep-0692/#specification) that was [accepted](https://discuss.python.org/t/pep-692-using-typeddict-for-more-precise-kwargs-typing/17314/81) in January 2023. We have tested that these types are recognized properly by [Pyright](https://github.com/microsoft/pyright). Support for `Unpack` in MyPy is still experimental, but appears to degrade gracefully. Please [report an issue](https://github.com/stripe/stripe-python/issues/new/choose) if there is anything we can do to improve the types for your type checker of choice.
Please note that some annotations use features that were only fairly recently accepted,
such as [`Unpack[TypedDict]`](https://peps.python.org/pep-0692/#specification) that was
[accepted](https://discuss.python.org/t/pep-692-using-typeddict-for-more-precise-kwargs-typing/17314/81)
in January 2023. We have tested that these types are recognized properly by [Pyright](https://github.com/microsoft/pyright).
Support for `Unpack` in MyPy is still experimental, but appears to degrade gracefully.
Please [report an issue](https://github.com/stripe/stripe-python/issues/new/choose) if there
is anything we can do to improve the types for your type checker of choice.
### Types and the Versioning Policy
We release type changes in minor releases. While stripe-python follows semantic versioning, our semantic versions describe the *runtime behavior* of the library alone. Our *type annotations are not reflected in the semantic version*. That is, upgrading to a new minor version of stripe-python might result in your type checker producing a type error that it didn't before. You can use a `~=x.x` or `x.x.*` [version specifier](https://peps.python.org/pep-0440/#examples) in your `requirements.txt` to constrain `pip` to a certain minor range of `stripe-python`.
We release type changes in minor releases. While stripe-python follows semantic
versioning, our semantic versions describe the *runtime behavior* of the
library alone. Our *type annotations are not reflected in the semantic
version*. That is, upgrading to a new minor version of stripe-python might
result in your type checker producing a type error that it didn't before. You
can use a `~=x.x` or `x.x.*` [version specifier](https://peps.python.org/pep-0440/#examples)
in your `requirements.txt` to constrain `pip` to a certain minor range of `stripe-python`.

### Types and API Versions

The types describe the [Stripe API version](https://stripe.com/docs/api/versioning) that was the latest at the time of
release. This is the version that your library sends by default. If you are
overriding `stripe.api_version`, or using a [webhook endpoint](https://stripe.com/docs/webhooks#api-versions) tied to an older version, be
aware that the data you see at runtime may not match the types.
The types describe the [Stripe API version](https://stripe.com/docs/api/versioning)
that was the latest at the time of release. This is the version that your library
sends by default. If you are overriding `stripe.api_version`, or using a
[webhook endpoint](https://stripe.com/docs/webhooks#api-versions) tied to an older version,
be aware that the data you see at runtime may not match the types.

## Beta SDKs

Expand Down
4,574 changes: 2,247 additions & 2,327 deletions stripe/api_resources/account.py

Large diffs are not rendered by default.

59 changes: 28 additions & 31 deletions stripe/api_resources/account_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# File generated from our OpenAPI spec
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.request_options import RequestOptions
from typing import ClassVar, List, Optional, cast
from typing_extensions import Literal, NotRequired, Unpack, TYPE_CHECKING
from typing import ClassVar, List, Optional
from typing_extensions import Literal, NotRequired, Unpack


class AccountLink(CreateableAPIResource["AccountLink"]):
Expand All @@ -15,33 +15,32 @@ class AccountLink(CreateableAPIResource["AccountLink"]):
"""

OBJECT_NAME: ClassVar[Literal["account_link"]] = "account_link"
if TYPE_CHECKING:

class CreateParams(RequestOptions):
account: str
"""
The identifier of the account to create an account link for.
"""
collect: NotRequired["Literal['currently_due', 'eventually_due']"]
"""
Which information the platform needs to collect from the user. One of `currently_due` or `eventually_due`. Default is `currently_due`.
"""
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""
refresh_url: NotRequired["str"]
"""
The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid. The URL you specify should attempt to generate a new account link with the same parameters used to create the original account link, then redirect the user to the new account link's URL so they can continue with Connect Onboarding. If a new account link cannot be generated or the redirect fails you should display a useful error to the user.
"""
return_url: NotRequired["str"]
"""
The URL that the user will be redirected to upon leaving or completing the linked flow.
"""
type: Literal["account_onboarding", "account_update"]
"""
The type of account link the user is requesting. Possible values are `account_onboarding` or `account_update`.
"""
class CreateParams(RequestOptions):
account: str
"""
The identifier of the account to create an account link for.
"""
collect: NotRequired["Literal['currently_due', 'eventually_due']"]
"""
Which information the platform needs to collect from the user. One of `currently_due` or `eventually_due`. Default is `currently_due`.
"""
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""
refresh_url: NotRequired["str"]
"""
The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid. The URL you specify should attempt to generate a new account link with the same parameters used to create the original account link, then redirect the user to the new account link's URL so they can continue with Connect Onboarding. If a new account link cannot be generated or the redirect fails you should display a useful error to the user.
"""
return_url: NotRequired["str"]
"""
The URL that the user will be redirected to upon leaving or completing the linked flow.
"""
type: Literal["account_onboarding", "account_update"]
"""
The type of account link the user is requesting. Possible values are `account_onboarding` or `account_update`.
"""

created: int
"""
Expand All @@ -67,9 +66,7 @@ def create(
idempotency_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack[
"AccountLink.CreateParams"
] # pyright: ignore[reportGeneralTypeIssues]
**params: Unpack["AccountLink.CreateParams"]
) -> "AccountLink":
"""
Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
Expand Down
66 changes: 28 additions & 38 deletions stripe/api_resources/account_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.request_options import RequestOptions
from stripe.stripe_object import StripeObject
from typing import ClassVar, List, Optional, cast
from typing_extensions import (
Literal,
NotRequired,
TypedDict,
Unpack,
TYPE_CHECKING,
)
from typing import ClassVar, List, Optional
from typing_extensions import Literal, NotRequired, TypedDict, Unpack


class AccountSession(CreateableAPIResource["AccountSession"]):
Expand All @@ -36,35 +30,33 @@ class AccountOnboarding(StripeObject):
account_onboarding: AccountOnboarding
_inner_class_types = {"account_onboarding": AccountOnboarding}

if TYPE_CHECKING:

class CreateParams(RequestOptions):
account: str
"""
The identifier of the account to create an Account Session for.
"""
components: "AccountSession.CreateParamsComponents"
"""
Each key of the dictionary represents an embedded component, and each embedded component maps to its configuration (e.g. whether it has been enabled or not).
"""
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""
class CreateParams(RequestOptions):
account: str
"""
The identifier of the account to create an Account Session for.
"""
components: "AccountSession.CreateParamsComponents"
"""
Each key of the dictionary represents an embedded component, and each embedded component maps to its configuration (e.g. whether it has been enabled or not).
"""
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""

class CreateParamsComponents(TypedDict):
account_onboarding: NotRequired[
"AccountSession.CreateParamsComponentsAccountOnboarding"
]
"""
Configuration for the account onboarding embedded component.
"""
class CreateParamsComponents(TypedDict):
account_onboarding: NotRequired[
"AccountSession.CreateParamsComponentsAccountOnboarding"
]
"""
Configuration for the account onboarding embedded component.
"""

class CreateParamsComponentsAccountOnboarding(TypedDict):
enabled: bool
"""
Whether the embedded component is enabled.
"""
class CreateParamsComponentsAccountOnboarding(TypedDict):
enabled: bool
"""
Whether the embedded component is enabled.
"""

account: str
"""
Expand Down Expand Up @@ -99,9 +91,7 @@ def create(
idempotency_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack[
"AccountSession.CreateParams"
] # pyright: ignore[reportGeneralTypeIssues]
**params: Unpack["AccountSession.CreateParams"]
) -> "AccountSession":
"""
Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access.
Expand Down
84 changes: 39 additions & 45 deletions stripe/api_resources/apple_pay_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
from stripe.api_resources.list_object import ListObject
from stripe.request_options import RequestOptions
from stripe.util import class_method_variant
from typing import ClassVar, List, Optional, cast, overload
from typing_extensions import Literal, NotRequired, Unpack, TYPE_CHECKING
from urllib.parse import quote_plus
from typing import ClassVar, List, Optional, overload
from typing_extensions import Literal, NotRequired, Unpack


class ApplePayDomain(
Expand All @@ -19,42 +18,41 @@ class ApplePayDomain(
ListableAPIResource["ApplePayDomain"],
):
OBJECT_NAME: ClassVar[Literal["apple_pay_domain"]] = "apple_pay_domain"
if TYPE_CHECKING:

class CreateParams(RequestOptions):
domain_name: str
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""

class DeleteParams(RequestOptions):
pass

class ListParams(RequestOptions):
domain_name: NotRequired["str"]
ending_before: NotRequired["str"]
"""
A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
"""
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""
limit: NotRequired["int"]
"""
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
"""
starting_after: NotRequired["str"]
"""
A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
"""

class RetrieveParams(RequestOptions):
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""

class CreateParams(RequestOptions):
domain_name: str
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""

class DeleteParams(RequestOptions):
pass

class ListParams(RequestOptions):
domain_name: NotRequired["str"]
ending_before: NotRequired["str"]
"""
A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
"""
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""
limit: NotRequired["int"]
"""
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
"""
starting_after: NotRequired["str"]
"""
A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
"""

class RetrieveParams(RequestOptions):
expand: NotRequired["List[str]"]
"""
Specifies which fields in the response should be expanded.
"""

created: int
"""
Expand Down Expand Up @@ -85,9 +83,7 @@ def create(
idempotency_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack[
"ApplePayDomain.CreateParams"
] # pyright: ignore[reportGeneralTypeIssues]
**params: Unpack["ApplePayDomain.CreateParams"]
) -> "ApplePayDomain":
"""
Create an apple pay domain.
Expand Down Expand Up @@ -156,9 +152,7 @@ def list(
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack[
"ApplePayDomain.ListParams"
] # pyright: ignore[reportGeneralTypeIssues]
**params: Unpack["ApplePayDomain.ListParams"]
) -> ListObject["ApplePayDomain"]:
"""
List apple pay domains.
Expand Down
Loading

0 comments on commit 8670792

Please sign in to comment.