Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix class method variant types #1100

Merged
merged 5 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions stripe/api_resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from stripe.api_resources.list_object import ListObject
from stripe.request_options import RequestOptions
from stripe.stripe_object import StripeObject
from typing import ClassVar, Dict, List, Optional, Union, cast
from stripe.util import class_method_variant
from typing import ClassVar, Dict, List, Optional, Union, cast, overload
from typing_extensions import (
Literal,
NotRequired,
Expand Down Expand Up @@ -1056,8 +1057,21 @@ def _cls_delete(
cls._static_request("delete", url, params=params),
)

@util.class_method_variant("_cls_delete")
@overload
@classmethod
def delete(
cls, sid: str, **params: Unpack["Account.DeleteParams"]
) -> "Account":
...

@overload
def delete(self, **params: Unpack["Account.DeleteParams"]) -> "Account":
...

@class_method_variant("_cls_delete")
def delete( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["Account.DeleteParams"]
) -> "Account":
return self._request_and_refresh(
"delete",
self.instance_url(),
Expand Down Expand Up @@ -1112,11 +1126,31 @@ def _cls_persons(
),
)

@util.class_method_variant("_cls_persons")
@overload
@classmethod
def persons(
cls,
account: str,
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack["Account.PersonsParams"]
) -> ListObject["Person"]:
...

@overload
def persons(
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Account.PersonsParams"]
) -> ListObject["Person"]:
...

@class_method_variant("_cls_persons")
def persons( # pyright: ignore[reportGeneralTypeIssues]
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Account.PersonsParams"]
) -> ListObject["Person"]:
return cast(
ListObject["Person"],
Expand Down Expand Up @@ -1153,11 +1187,31 @@ def _cls_reject(
),
)

@util.class_method_variant("_cls_reject")
@overload
@classmethod
def reject(
cls,
account: str,
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack["Account.RejectParams"]
) -> "Account":
...

@overload
def reject(
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Account.RejectParams"]
) -> "Account":
...

@class_method_variant("_cls_reject")
def reject( # pyright: ignore[reportGeneralTypeIssues]
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Account.RejectParams"]
) -> "Account":
return cast(
"Account",
Expand Down
19 changes: 16 additions & 3 deletions stripe/api_resources/apple_pay_domain.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe import util
from stripe.api_resources.abstract import (
CreateableAPIResource,
DeletableAPIResource,
ListableAPIResource,
)
from stripe.api_resources.list_object import ListObject
from stripe.request_options import RequestOptions
from typing import ClassVar, List, Optional, cast
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

Expand Down Expand Up @@ -77,9 +77,22 @@ def _cls_delete(
cls._static_request("delete", url, params=params),
)

@util.class_method_variant("_cls_delete")
@overload
@classmethod
def delete(
cls, sid: str, **params: Unpack["ApplePayDomain.DeleteParams"]
) -> "ApplePayDomain":
...

@overload
def delete(
self, **params: Unpack["ApplePayDomain.DeleteParams"]
) -> "ApplePayDomain":
...

@class_method_variant("_cls_delete")
def delete( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["ApplePayDomain.DeleteParams"]
) -> "ApplePayDomain":
return self._request_and_refresh(
"delete",
Expand Down
25 changes: 23 additions & 2 deletions stripe/api_resources/application_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from stripe.api_resources.expandable_field import ExpandableField
from stripe.api_resources.list_object import ListObject
from stripe.request_options import RequestOptions
from typing import ClassVar, Dict, List, Optional, cast
from stripe.util import class_method_variant
from typing import ClassVar, Dict, List, Optional, cast, overload
from typing_extensions import (
Literal,
NotRequired,
Expand Down Expand Up @@ -135,8 +136,28 @@ def _cls_refund(
),
)

@util.class_method_variant("_cls_refund")
@overload
@classmethod
def refund(
cls,
id: str,
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack["ApplicationFee.RefundParams"]
) -> "ApplicationFeeRefund":
...

@overload
def refund(
self,
idempotency_key: Optional[str] = None,
**params: Unpack["ApplicationFee.RefundParams"]
) -> "ApplicationFeeRefund":
...

@class_method_variant("_cls_refund")
def refund( # pyright: ignore[reportGeneralTypeIssues]
self,
idempotency_key: Optional[str] = None,
**params: Unpack["ApplicationFee.RefundParams"]
Expand Down
20 changes: 17 additions & 3 deletions stripe/api_resources/bank_account.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe import error, util
from stripe import error
from stripe.api_resources.abstract import (
DeletableAPIResource,
UpdateableAPIResource,
Expand All @@ -11,7 +11,8 @@
from stripe.api_resources.expandable_field import ExpandableField
from stripe.request_options import RequestOptions
from stripe.stripe_object import StripeObject
from typing import ClassVar, Dict, List, Optional, Union, cast
from stripe.util import class_method_variant
from typing import ClassVar, Dict, List, Optional, Union, cast, overload
from typing_extensions import Literal, Unpack, TYPE_CHECKING
from urllib.parse import quote_plus

Expand Down Expand Up @@ -71,9 +72,22 @@ def _cls_delete(
cls._static_request("delete", url, params=params),
)

@util.class_method_variant("_cls_delete")
@overload
@classmethod
def delete(
cls, sid: str, **params: Unpack["BankAccount.DeleteParams"]
) -> Union["BankAccount", "Card"]:
...

@overload
def delete(
self, **params: Unpack["BankAccount.DeleteParams"]
) -> Union["BankAccount", "Card"]:
...

@class_method_variant("_cls_delete")
def delete( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["BankAccount.DeleteParams"]
) -> Union["BankAccount", "Card"]:
return self._request_and_refresh(
"delete",
Expand Down
20 changes: 17 additions & 3 deletions stripe/api_resources/card.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from stripe import error, util
from stripe import error
from stripe.api_resources.abstract import (
DeletableAPIResource,
UpdateableAPIResource,
Expand All @@ -9,7 +9,8 @@
from stripe.api_resources.customer import Customer
from stripe.api_resources.expandable_field import ExpandableField
from stripe.request_options import RequestOptions
from typing import ClassVar, Dict, List, Optional, Union, cast
from stripe.util import class_method_variant
from typing import ClassVar, Dict, List, Optional, Union, cast, overload
from typing_extensions import Literal, Unpack, TYPE_CHECKING
from urllib.parse import quote_plus

Expand Down Expand Up @@ -75,9 +76,22 @@ def _cls_delete(
cls._static_request("delete", url, params=params),
)

@util.class_method_variant("_cls_delete")
@overload
@classmethod
def delete(
cls, sid: str, **params: Unpack["Card.DeleteParams"]
) -> Union["BankAccount", "Card"]:
...

@overload
def delete(
self, **params: Unpack["Card.DeleteParams"]
) -> Union["BankAccount", "Card"]:
...

@class_method_variant("_cls_delete")
def delete( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["Card.DeleteParams"]
) -> Union["BankAccount", "Card"]:
return self._request_and_refresh(
"delete",
Expand Down
34 changes: 32 additions & 2 deletions stripe/api_resources/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
from stripe.api_resources.search_result_object import SearchResultObject
from stripe.request_options import RequestOptions
from stripe.stripe_object import StripeObject
from typing import ClassVar, Dict, Iterator, List, Optional, Union, cast
from stripe.util import class_method_variant
from typing import (
ClassVar,
Dict,
Iterator,
List,
Optional,
Union,
cast,
overload,
)
from typing_extensions import (
Literal,
NotRequired,
Expand Down Expand Up @@ -242,11 +252,31 @@ def _cls_capture(
),
)

@util.class_method_variant("_cls_capture")
@overload
@classmethod
def capture(
cls,
charge: str,
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack["Charge.CaptureParams"]
) -> "Charge":
...

@overload
def capture(
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Charge.CaptureParams"]
) -> "Charge":
...

@class_method_variant("_cls_capture")
def capture( # pyright: ignore[reportGeneralTypeIssues]
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Charge.CaptureParams"]
) -> "Charge":
return cast(
"Charge",
Expand Down
47 changes: 44 additions & 3 deletions stripe/api_resources/checkout/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from stripe.api_resources.list_object import ListObject
from stripe.request_options import RequestOptions
from stripe.stripe_object import StripeObject
from typing import ClassVar, Dict, List, Optional, cast
from stripe.util import class_method_variant
from typing import ClassVar, Dict, List, Optional, cast, overload
from typing_extensions import (
Literal,
NotRequired,
Expand Down Expand Up @@ -1106,8 +1107,28 @@ def _cls_expire(
),
)

@util.class_method_variant("_cls_expire")
@overload
@classmethod
def expire(
cls,
session: str,
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack["Session.ExpireParams"]
) -> "Session":
...

@overload
def expire(
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Session.ExpireParams"]
) -> "Session":
...

@class_method_variant("_cls_expire")
def expire( # pyright: ignore[reportGeneralTypeIssues]
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Session.ExpireParams"]
Expand Down Expand Up @@ -1172,8 +1193,28 @@ def _cls_list_line_items(
),
)

@util.class_method_variant("_cls_list_line_items")
@overload
@classmethod
def list_line_items(
cls,
session: str,
api_key: Optional[str] = None,
stripe_version: Optional[str] = None,
stripe_account: Optional[str] = None,
**params: Unpack["Session.ListLineItemsParams"]
) -> ListObject["LineItem"]:
...

@overload
def list_line_items(
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Session.ListLineItemsParams"]
) -> ListObject["LineItem"]:
...

@class_method_variant("_cls_list_line_items")
def list_line_items( # pyright: ignore[reportGeneralTypeIssues]
self,
idempotency_key: Optional[str] = None,
**params: Unpack["Session.ListLineItemsParams"]
Expand Down
Loading