Skip to content

Commit

Permalink
Merge e80ad90 into 287c85d
Browse files Browse the repository at this point in the history
  • Loading branch information
xavdid-stripe committed May 10, 2024
2 parents 287c85d + e80ad90 commit e347d8c
Show file tree
Hide file tree
Showing 135 changed files with 581 additions and 712 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
# length, but can go over in some cases.
# W503 goes against PEP8 rules. It's disabled by default, but must be disabled
# explicitly when using `ignore`.
ignore = E501, W503
# E704 is disabled in the default configuration, but by specifying `ignore`, we wipe that out.
# ruff formatting creates code that violates it, so we have to disable it manually
ignore = E501, W503, E704
per-file-ignores =
*/__init__.py: IMP100, E402, F401
# we test various import patterns
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .git-blame-ignore-revs
# mass formatted w/ ruff (2024-05-10)
c46b4b950ea77e9d18ab98885cda721b3de247c0
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"ms-python.python",
"EditorConfig.editorconfig",
"ms-python.flake8",
"charliermarsh.ruff"
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Run the linter with:
make lint
```

The library uses [Black][black] for code formatting. Code must be formatted
The library uses [Ruff][ruff] for code formatting. Code must be formatted
with Black before PRs are submitted, otherwise CI will fail. Run the formatter
with:

Expand All @@ -378,7 +378,7 @@ make fmt
```

[api-keys]: https://dashboard.stripe.com/account/apikeys
[black]: https://github.com/ambv/black
[ruff]: https://github.com/astral-sh/ruff
[connect]: https://stripe.com/connect
[poetry]: https://github.com/sdispater/poetry
[stripe-mock]: https://github.com/stripe/stripe-mock
Expand Down
8 changes: 2 additions & 6 deletions examples/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def callback():
<p>Success! Account <code>{stripe_user_id}</code> is connected.</p>
<p>Click <a href="/deauthorize?stripe_user_id={stripe_user_id}">here</a> to
disconnect the account.</p>
""".format(
stripe_user_id=resp["stripe_user_id"]
)
""".format(stripe_user_id=resp["stripe_user_id"])


@app.route("/deauthorize")
Expand All @@ -49,9 +47,7 @@ def deauthorize():
return """
<p>Success! Account <code>{stripe_user_id}</code> is disconnected.</p>
<p>Click <a href="/">here</a> to restart the OAuth flow.</p>
""".format(
stripe_user_id=stripe_user_id
)
""".format(stripe_user_id=stripe_user_id)


if __name__ == "__main__":
Expand Down
33 changes: 9 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
[tool.black]
[tool.ruff]
# same as our black config
line-length = 79
target-version = [
"py35",
"py36",
"py37",
"py38",
"py39",
"py310",
# "py311", # black 21.12b0 doesn't
# "py312", # support these targets
]
exclude = '''
/(
\.eggs/
| \.git/
| \.tox/
| \.venv/
| _build/
| build/
| dist/
| venv/
)
'''
extend-exclude = ["build"]

[tool.ruff.format]
# currently the default value, but opt-out in the future
docstring-code-format = false

[tool.pyright]
include = [
"stripe",
"tests/test_generated_examples.py",
"tests/test_exports.py",
"tests/test_http_client.py"
"tests/test_http_client.py",
]
exclude = ["build", "**/__pycache__"]
reportMissingTypeArgument = true
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tox == 4.5.0
#Virtualenv 20.22.0 dropped support for all Python versions smaller or equal to Python 3.6.
virtualenv<20.22.0
pyright == 1.1.336
black == 22.8.0
ruff == 0.4.4
flake8
mypy == 1.7.0

Expand Down
42 changes: 20 additions & 22 deletions stripe/_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,6 @@ def list(
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
Expand All @@ -4025,7 +4024,6 @@ async def list_async(
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
Expand Down Expand Up @@ -4322,7 +4320,7 @@ def retrieve_capability(
cls,
account: str,
capability: str,
**params: Unpack["Account.RetrieveCapabilityParams"]
**params: Unpack["Account.RetrieveCapabilityParams"],
) -> "Capability":
"""
Retrieves information about the specified Account Capability.
Expand All @@ -4344,7 +4342,7 @@ async def retrieve_capability_async(
cls,
account: str,
capability: str,
**params: Unpack["Account.RetrieveCapabilityParams"]
**params: Unpack["Account.RetrieveCapabilityParams"],
) -> "Capability":
"""
Retrieves information about the specified Account Capability.
Expand All @@ -4366,7 +4364,7 @@ def modify_capability(
cls,
account: str,
capability: str,
**params: Unpack["Account.ModifyCapabilityParams"]
**params: Unpack["Account.ModifyCapabilityParams"],
) -> "Capability":
"""
Updates an existing Account Capability. Request or remove a capability by updating its requested parameter.
Expand All @@ -4388,7 +4386,7 @@ async def modify_capability_async(
cls,
account: str,
capability: str,
**params: Unpack["Account.ModifyCapabilityParams"]
**params: Unpack["Account.ModifyCapabilityParams"],
) -> "Capability":
"""
Updates an existing Account Capability. Request or remove a capability by updating its requested parameter.
Expand Down Expand Up @@ -4445,7 +4443,7 @@ async def list_capabilities_async(
def create_external_account(
cls,
account: str,
**params: Unpack["Account.CreateExternalAccountParams"]
**params: Unpack["Account.CreateExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Create an external account for a given account.
Expand All @@ -4465,7 +4463,7 @@ def create_external_account(
async def create_external_account_async(
cls,
account: str,
**params: Unpack["Account.CreateExternalAccountParams"]
**params: Unpack["Account.CreateExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Create an external account for a given account.
Expand All @@ -4486,7 +4484,7 @@ def retrieve_external_account(
cls,
account: str,
id: str,
**params: Unpack["Account.RetrieveExternalAccountParams"]
**params: Unpack["Account.RetrieveExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Retrieve a specified external account for a given account.
Expand All @@ -4507,7 +4505,7 @@ async def retrieve_external_account_async(
cls,
account: str,
id: str,
**params: Unpack["Account.RetrieveExternalAccountParams"]
**params: Unpack["Account.RetrieveExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Retrieve a specified external account for a given account.
Expand All @@ -4528,7 +4526,7 @@ def modify_external_account(
cls,
account: str,
id: str,
**params: Unpack["Account.ModifyExternalAccountParams"]
**params: Unpack["Account.ModifyExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Updates the metadata, account holder name, account holder type of a bank account belonging to
Expand Down Expand Up @@ -4556,7 +4554,7 @@ async def modify_external_account_async(
cls,
account: str,
id: str,
**params: Unpack["Account.ModifyExternalAccountParams"]
**params: Unpack["Account.ModifyExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Updates the metadata, account holder name, account holder type of a bank account belonging to
Expand Down Expand Up @@ -4584,7 +4582,7 @@ def delete_external_account(
cls,
account: str,
id: str,
**params: Unpack["Account.DeleteExternalAccountParams"]
**params: Unpack["Account.DeleteExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Delete a specified external account for a given account.
Expand All @@ -4605,7 +4603,7 @@ async def delete_external_account_async(
cls,
account: str,
id: str,
**params: Unpack["Account.DeleteExternalAccountParams"]
**params: Unpack["Account.DeleteExternalAccountParams"],
) -> Union["BankAccount", "Card"]:
"""
Delete a specified external account for a given account.
Expand All @@ -4625,7 +4623,7 @@ async def delete_external_account_async(
def list_external_accounts(
cls,
account: str,
**params: Unpack["Account.ListExternalAccountsParams"]
**params: Unpack["Account.ListExternalAccountsParams"],
) -> ListObject[Union["BankAccount", "Card"]]:
"""
List external accounts for an account.
Expand All @@ -4645,7 +4643,7 @@ def list_external_accounts(
async def list_external_accounts_async(
cls,
account: str,
**params: Unpack["Account.ListExternalAccountsParams"]
**params: Unpack["Account.ListExternalAccountsParams"],
) -> ListObject[Union["BankAccount", "Card"]]:
"""
List external accounts for an account.
Expand Down Expand Up @@ -4742,7 +4740,7 @@ def retrieve_person(
cls,
account: str,
person: str,
**params: Unpack["Account.RetrievePersonParams"]
**params: Unpack["Account.RetrievePersonParams"],
) -> "Person":
"""
Retrieves an existing person.
Expand All @@ -4763,7 +4761,7 @@ async def retrieve_person_async(
cls,
account: str,
person: str,
**params: Unpack["Account.RetrievePersonParams"]
**params: Unpack["Account.RetrievePersonParams"],
) -> "Person":
"""
Retrieves an existing person.
Expand All @@ -4784,7 +4782,7 @@ def modify_person(
cls,
account: str,
person: str,
**params: Unpack["Account.ModifyPersonParams"]
**params: Unpack["Account.ModifyPersonParams"],
) -> "Person":
"""
Updates an existing person.
Expand All @@ -4805,7 +4803,7 @@ async def modify_person_async(
cls,
account: str,
person: str,
**params: Unpack["Account.ModifyPersonParams"]
**params: Unpack["Account.ModifyPersonParams"],
) -> "Person":
"""
Updates an existing person.
Expand All @@ -4826,7 +4824,7 @@ def delete_person(
cls,
account: str,
person: str,
**params: Unpack["Account.DeletePersonParams"]
**params: Unpack["Account.DeletePersonParams"],
) -> "Person":
"""
Deletes an existing person's relationship to the account's legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file.
Expand All @@ -4847,7 +4845,7 @@ async def delete_person_async(
cls,
account: str,
person: str,
**params: Unpack["Account.DeletePersonParams"]
**params: Unpack["Account.DeletePersonParams"],
) -> "Person":
"""
Deletes an existing person's relationship to the account's legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file.
Expand Down
6 changes: 3 additions & 3 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ def _args_for_request_with_retries(
generator = MultipartDataGenerator()
generator.add_params(params or {})
post_data = generator.get_post_data()
headers[
"Content-Type"
] = "multipart/form-data; boundary=%s" % (generator.boundary,)
headers["Content-Type"] = (
"multipart/form-data; boundary=%s" % (generator.boundary,)
)
else:
post_data = encoded_body
else:
Expand Down
2 changes: 0 additions & 2 deletions stripe/_apple_pay_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def list(
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
Expand All @@ -238,7 +237,6 @@ async def list_async(
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
Expand Down
10 changes: 4 additions & 6 deletions stripe/_application_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ def list(
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
Expand All @@ -230,7 +229,6 @@ async def list_async(
params=params,
)
if not isinstance(result, ListObject):

raise TypeError(
"Expected list object from API, got %s"
% (type(result).__name__)
Expand Down Expand Up @@ -483,7 +481,7 @@ def retrieve_refund(
cls,
fee: str,
id: str,
**params: Unpack["ApplicationFee.RetrieveRefundParams"]
**params: Unpack["ApplicationFee.RetrieveRefundParams"],
) -> "ApplicationFeeRefund":
"""
By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee.
Expand All @@ -504,7 +502,7 @@ async def retrieve_refund_async(
cls,
fee: str,
id: str,
**params: Unpack["ApplicationFee.RetrieveRefundParams"]
**params: Unpack["ApplicationFee.RetrieveRefundParams"],
) -> "ApplicationFeeRefund":
"""
By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee.
Expand All @@ -525,7 +523,7 @@ def modify_refund(
cls,
fee: str,
id: str,
**params: Unpack["ApplicationFee.ModifyRefundParams"]
**params: Unpack["ApplicationFee.ModifyRefundParams"],
) -> "ApplicationFeeRefund":
"""
Updates the specified application fee refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
Expand All @@ -548,7 +546,7 @@ async def modify_refund_async(
cls,
fee: str,
id: str,
**params: Unpack["ApplicationFee.ModifyRefundParams"]
**params: Unpack["ApplicationFee.ModifyRefundParams"],
) -> "ApplicationFeeRefund":
"""
Updates the specified application fee refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
Expand Down
Loading

0 comments on commit e347d8c

Please sign in to comment.