Skip to content

Commit b94facc

Browse files
Merge pull request #1766 from stripe/xavdid/merge-python-private-preview
Merge to private-preview
2 parents cc44095 + 94f3b6f commit b94facc

73 files changed

Lines changed: 1204 additions & 528 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,12 @@ jobs:
8888
python_version:
8989
# The last ~5 versions, once we're on schedule
9090
# https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy
91-
- "3.7"
92-
- "3.8"
9391
- "3.9"
9492
- "3.10"
9593
- "3.11"
9694
- "3.12"
9795
- "3.13"
9896
- "3.14"
99-
- "pypy-3.7"
100-
- "pypy-3.8"
10197
- "pypy-3.9"
10298
- "pypy-3.10"
10399
- "pypy-3.11"
@@ -118,8 +114,7 @@ jobs:
118114
name: Publish
119115
if: >-
120116
((github.event_name == 'workflow_dispatch') || (github.event_name == 'push')) &&
121-
startsWith(github.ref, 'refs/tags/v') &&
122-
endsWith(github.actor, '-stripe')
117+
startsWith(github.ref, 'refs/tags/v')
123118
needs: [build, test, lint]
124119
runs-on: "ubuntu-24.04"
125120
permissions:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ python -m pip install .
3232

3333
### Requirements
3434

35-
Per our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy), we currently support **Python 3.7+**.
35+
Per our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy), we currently support **Python 3.9+**.
3636

37-
Support for Python 3.7 and 3.8 is deprecated and will be removed in an upcoming major version. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy
37+
Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy
3838

3939
#### Extended Support
4040

flake8_stripe/flake8_stripe.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ class TypingImportsChecker:
1010
version = "0.1.0"
1111

1212
# Rules:
13-
# * typing_extensions v4.1.1 is the latest that supports Python 3.6
14-
# so don't depend on anything from a more recent version than that.
15-
#
16-
# If we need something newer, maybe we can provide it for users on
17-
# newer versions with a conditional import, but we'll cross that
18-
# bridge when we come to it.
19-
2013
# If a symbol exists in both `typing` and `typing_extensions`, which
2114
# should you use? Prefer `typing_extensions` if the symbol available there.
2215
# in 4.1.1. In typing_extensions 4.7.0, `typing_extensions` started re-exporting
2316
# EVERYTHING from `typing` but this is not the case in v4.1.1.
17+
18+
# now that we're into modern typing_extensions versions, we should probably prefer that over built-in typing _unless_ all of our `typing `needs are present in all supported Python versions. In that case, we could drop `typing_extensions`. See: https://go/j/DEVSDK-3046
2419
allowed_typing_extensions_imports = [
2520
"Literal",
2621
"NoReturn",
@@ -36,6 +31,7 @@ class TypingImportsChecker:
3631
"Awaitable",
3732
"Never",
3833
"override",
34+
"deprecated",
3935
]
4036

4137
allowed_typing_imports = [

pyproject.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description = "Python bindings for the Stripe API"
66
authors = [{ name = "Stripe", email = "support@stripe.com" }]
77
license-files = ["LICENSE"]
88
keywords = ["stripe", "api", "payments"]
9-
requires-python = ">=3.7"
9+
requires-python = ">=3.9"
1010
classifiers = [
1111
"Development Status :: 5 - Production/Stable",
1212
"Intended Audience :: Developers",
@@ -27,11 +27,9 @@ classifiers = [
2727
]
2828

2929
dependencies = [
30-
"typing_extensions <= 4.2.0, > 3.7.2; python_version < '3.7'",
31-
# The best typing support comes from 4.5.0+ but we can support down to
32-
# 3.7.2 without throwing exceptions.
33-
"typing_extensions >= 4.5.0; python_version >= '3.7'",
34-
"requests >= 2.20; python_version >= '3.0'",
30+
# this is the version where everything started getting re-exported, so it's a convenient backstop
31+
"typing_extensions >= 4.7.0",
32+
"requests >= 2.20",
3533
]
3634

3735
[project.optional-dependencies]

stripe/_account.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ def persons( # pyright: ignore[reportGeneralTypeIssues]
19861986
self._request(
19871987
"get",
19881988
"/v1/accounts/{account}/persons".format(
1989-
account=sanitize_id(self.get("id"))
1989+
account=sanitize_id(self._data.get("id"))
19901990
),
19911991
params=params,
19921992
),
@@ -2041,7 +2041,7 @@ async def persons_async( # pyright: ignore[reportGeneralTypeIssues]
20412041
await self._request_async(
20422042
"get",
20432043
"/v1/accounts/{account}/persons".format(
2044-
account=sanitize_id(self.get("id"))
2044+
account=sanitize_id(self._data.get("id"))
20452045
),
20462046
params=params,
20472047
),
@@ -2102,7 +2102,7 @@ def reject( # pyright: ignore[reportGeneralTypeIssues]
21022102
self._request(
21032103
"post",
21042104
"/v1/accounts/{account}/reject".format(
2105-
account=sanitize_id(self.get("id"))
2105+
account=sanitize_id(self._data.get("id"))
21062106
),
21072107
params=params,
21082108
),
@@ -2165,7 +2165,7 @@ async def reject_async( # pyright: ignore[reportGeneralTypeIssues]
21652165
await self._request_async(
21662166
"post",
21672167
"/v1/accounts/{account}/reject".format(
2168-
account=sanitize_id(self.get("id"))
2168+
account=sanitize_id(self._data.get("id"))
21692169
),
21702170
params=params,
21712171
),
@@ -2205,7 +2205,7 @@ def _build_instance_url(cls, sid):
22052205
return "%s/%s" % (base, extn)
22062206

22072207
def instance_url(self):
2208-
return self._build_instance_url(self.get("id"))
2208+
return self._build_instance_url(self._data.get("id"))
22092209

22102210
def deauthorize(self, **params):
22112211
params["stripe_user_id"] = self.id
@@ -2215,7 +2215,7 @@ def serialize(self, previous):
22152215
params = super(Account, self).serialize(previous)
22162216
previous = previous or self._previous or {}
22172217

2218-
for k, v in iter(self.items()):
2218+
for k, v in iter(self._data.items()):
22192219
if k == "individual" and isinstance(v, Person) and k not in params:
22202220
params[k] = v.serialize(previous.get(k, None))
22212221

stripe/_api_resource.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from typing_extensions import Literal, Self
1+
from typing_extensions import Literal, Self, deprecated
22

33
from stripe._error import InvalidRequestError
44
from stripe._stripe_object import StripeObject
55
from stripe._request_options import extract_options_from_dict
66
from stripe._api_mode import ApiMode
77
from stripe._base_address import BaseAddress
88
from stripe._api_requestor import _APIRequestor
9-
from stripe import _util
109
from urllib.parse import quote_plus
1110
from typing import (
1211
Any,
@@ -26,7 +25,7 @@ class APIResource(StripeObject, Generic[T]):
2625
OBJECT_NAME: ClassVar[str]
2726

2827
@classmethod
29-
@_util.deprecated(
28+
@deprecated(
3029
"This method is deprecated and will be removed in a future version of stripe-python. Child classes of APIResource should define their own `retrieve` and use APIResource._request directly."
3130
)
3231
def retrieve(cls, id, **params) -> T:
@@ -55,7 +54,7 @@ def class_url(cls) -> str:
5554
return "/v1/%ss" % (base,)
5655

5756
def instance_url(self) -> str:
58-
id = self.get("id")
57+
id = self._data.get("id")
5958

6059
if not isinstance(id, str):
6160
raise InvalidRequestError(

stripe/_application_fee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def refund( # pyright: ignore[reportGeneralTypeIssues]
258258
self._request(
259259
"post",
260260
"/v1/application_fees/{id}/refunds".format(
261-
id=sanitize_id(self.get("id"))
261+
id=sanitize_id(self._data.get("id"))
262262
),
263263
params=params,
264264
),
@@ -343,7 +343,7 @@ async def refund_async( # pyright: ignore[reportGeneralTypeIssues]
343343
await self._request_async(
344344
"post",
345345
"/v1/application_fees/{id}/refunds".format(
346-
id=sanitize_id(self.get("id"))
346+
id=sanitize_id(self._data.get("id"))
347347
),
348348
params=params,
349349
),

stripe/_charge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,7 +2677,7 @@ def capture( # pyright: ignore[reportGeneralTypeIssues]
26772677
self._request(
26782678
"post",
26792679
"/v1/charges/{charge}/capture".format(
2680-
charge=sanitize_id(self.get("id"))
2680+
charge=sanitize_id(self._data.get("id"))
26812681
),
26822682
params=params,
26832683
),
@@ -2748,7 +2748,7 @@ async def capture_async( # pyright: ignore[reportGeneralTypeIssues]
27482748
await self._request_async(
27492749
"post",
27502750
"/v1/charges/{charge}/capture".format(
2751-
charge=sanitize_id(self.get("id"))
2751+
charge=sanitize_id(self._data.get("id"))
27522752
),
27532753
params=params,
27542754
),

stripe/_credit_note.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def void_credit_note( # pyright: ignore[reportGeneralTypeIssues]
633633
self._request(
634634
"post",
635635
"/v1/credit_notes/{id}/void".format(
636-
id=sanitize_id(self.get("id"))
636+
id=sanitize_id(self._data.get("id"))
637637
),
638638
params=params,
639639
),
@@ -686,7 +686,7 @@ async def void_credit_note_async( # pyright: ignore[reportGeneralTypeIssues]
686686
await self._request_async(
687687
"post",
688688
"/v1/credit_notes/{id}/void".format(
689-
id=sanitize_id(self.get("id"))
689+
id=sanitize_id(self._data.get("id"))
690690
),
691691
params=params,
692692
),

stripe/_custom_method.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from typing import Optional
22
from stripe import _util
33
from urllib.parse import quote_plus
4+
from typing_extensions import deprecated
45

56

67
# TODO(major): 1704.
7-
@_util.deprecated(
8+
@deprecated(
89
"the custom_method class decorator will be removed in a future version of stripe-python. Define custom methods directly and use StripeObject._static_request within."
910
)
1011
def custom_method(

0 commit comments

Comments
 (0)