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

Update generated code for beta #1128

Merged
merged 31 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2e0d6cf
Update generated code for v655
stripe-openapi[bot] Nov 10, 2023
111323f
Suppress type errors from latest pyright (#1126)
richardm-stripe Nov 10, 2023
0236cb7
Merge upstream and update generated code for v655
stripe-openapi[bot] Nov 10, 2023
97c7d22
Update generated code for v655
stripe-openapi[bot] Nov 10, 2023
bf1c0bc
Update generated code for v656
stripe-openapi[bot] Nov 13, 2023
7face7b
Update generated code for v657
stripe-openapi[bot] Nov 14, 2023
4cb9f57
Update generated code for v658
stripe-openapi[bot] Nov 14, 2023
a2870d9
Update generated code for v659
stripe-openapi[bot] Nov 14, 2023
e97258e
Update generated code for v659
stripe-openapi[bot] Nov 14, 2023
7c20b30
Update generated code for v661
stripe-openapi[bot] Nov 15, 2023
07476e1
Fix unnecessary casts from pyright 1.1.336 (#1132)
richardm-stripe Nov 15, 2023
d039456
Upgrade black dependency (#1131)
pakrym-stripe Nov 15, 2023
36fcbd1
Merge remote-tracking branch 'origin/master' into latest-codegen-beta
anniel-stripe Nov 15, 2023
46f523e
Update generated code for v662
stripe-openapi[bot] Nov 15, 2023
4f7e1b8
lint
anniel-stripe Nov 15, 2023
088faa0
Run pyright via tox (#1134)
pakrym-stripe Nov 15, 2023
57dc344
Update generated code for v663
stripe-openapi[bot] Nov 15, 2023
902aee5
Merge upstream and update generated code for v664
stripe-openapi[bot] Nov 15, 2023
6071486
Update generated code for v664
stripe-openapi[bot] Nov 15, 2023
6063bb9
Update generated code for v665
stripe-openapi[bot] Nov 15, 2023
d23daef
Update generated code for v666
stripe-openapi[bot] Nov 16, 2023
8607f1e
Add types to README.md (#1130)
richardm-stripe Nov 16, 2023
581a02f
Merge upstream and update generated code for v667
stripe-openapi[bot] Nov 16, 2023
755e947
Update generated code for v667
stripe-openapi[bot] Nov 16, 2023
4443062
Update generated code for v668
stripe-openapi[bot] Nov 16, 2023
bfa03ed
Update generated code for v669
stripe-openapi[bot] Nov 16, 2023
e22152c
Add initial tests for exports and run them in mypy and pyright (#1135)
pakrym-stripe Nov 16, 2023
11d6615
Merge upstream and update generated code for v669
stripe-openapi[bot] Nov 16, 2023
48cd628
Update generated code (#1127)
stripe-openapi[bot] Nov 16, 2023
59eb6c4
Bump version to 7.5.0
anniel-stripe Nov 17, 2023
60f2345
Merge upstream and update generated code for v669
stripe-openapi[bot] Nov 17, 2023
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
60 changes: 26 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ on:

jobs:
lint:
name: Lint
name: Lint & Mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: mypy
run: make mypy
- name: lint
run: make lint
- name: fmtcheck
Expand Down Expand Up @@ -60,59 +62,49 @@ jobs:
path: dist/

test:
name: Test
# Specific ubuntu version to support python 3.6 testing
# see https://github.com/actions/setup-python/issues/544#issuecomment-1332535877 for details
# move to ubuntu-latest when we drop 3.6
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version:
[
"3.6",
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"pypy-3.7",
"pypy-3.8",
"pypy-3.9",
"pypy-3.10",
]

python:
- { version: "3.6" , env: "py36" }
- { version: "3.7" , env: "py37" }
- { version: "3.8" , env: "py38" }
- { version: "3.9" , env: "py39" }
- { version: "3.10" , env: "py310" }
- { version: "3.11" , env: "py311" }
- { version: "3.12" , env: "py312" }
- { version: "pypy-3.7" , env: "py3.7" }
- { version: "pypy-3.8" , env: "py3.8" }
- { version: "pypy-3.9" , env: "py3.9" }
- { version: "pypy-3.10" , env: "py3.10" }
name: Test (${{ matrix.python.version }})
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python.version }} and 3.10
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "setup.py"

- name: Upgrade pip and virtualenv to latest
run: pip install --upgrade pip virtualenv
python-version: |
${{ matrix.python.version }}
3.10

- uses: stripe/openapi/actions/stripe-mock@master

- name: Typecheck with pyright
run: make pyright
# Pip won't install newer versions of pyright on python 3.6 (odd, because pyright is a node module)
# so we skip running pyright, and do double duty on python 3.7 using the --pythonversion flag.
if: matrix.python-version != '3.6'

- name: Typecheck with pyright
run: make pyright PYRIGHT_ARGS="--pythonversion 3.6"
if: matrix.python-version == '3.7'
run: PYRIGHT_ARGS="-- --pythonversion ${{ matrix.python.version }}" make pyright
# Skip typecheking in pypy legs
if: ${{ !contains(matrix.python.version, 'pypy') }}

- name: Test with pytest
run: make ci-test
run: TOX_ARGS="-e ${{ matrix.python.env }}" make ci-test

- name: Calculate and publish coverage
run: make coveralls
if: env.COVERALLS_REPO_TOKEN && matrix.python-version == '3.10'
if: env.COVERALLS_REPO_TOKEN && matrix.python.version == '3.10'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 7.5.0 - 2023-11-16
* [#1127](https://github.com/stripe/stripe-python/pull/1127) Update generated code
* Add support for `bacs_debit_payments` on `Account.CreateParamsSettings`
* Add support for `service_user_number` on `Account.Settings.BacsDebitPayments`
* Add support for `capture_before` on `Charge.PaymentMethodDetails.Card.capture_before`
* Add support for `Paypal` on `Checkout.Session.PaymentMethodOptions`
* Add support for `tax_amounts` on `CreditNote.CreateParamsLine`, `CreditNote.PreviewParamsLine`, and `CreditNote.PreviewLinesParamsLine`
* Add support for `network_data` on `Issuing.Transaction`
* Add support for `status` on `Checkout.Session.ListParams`
* [#1135](https://github.com/stripe/stripe-python/pull/1135) Add initial tests for exports and run them in mypy and pyright
* [#1130](https://github.com/stripe/stripe-python/pull/1130) Mention types in README.md
* [#1134](https://github.com/stripe/stripe-python/pull/1134) Run pyright via tox
* [#1131](https://github.com/stripe/stripe-python/pull/1131) Upgrade black dependency
* [#1132](https://github.com/stripe/stripe-python/pull/1132) Fix unnecessary casts from pyright 1.1.336
* [#1126](https://github.com/stripe/stripe-python/pull/1126) Suppress type errors from latest pyright
* [#1125](https://github.com/stripe/stripe-python/pull/1125) Add support for Python 3.11/3.12
* [#1123](https://github.com/stripe/stripe-python/pull/1123) Move to python3 venv and update vscode settings

## 7.5.0b1 - 2023-11-10
* [#1120](https://github.com/stripe/stripe-python/pull/1120) Update generated code for beta

Expand Down
24 changes: 9 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
VENV_NAME?=venv
PIP?=pip
PYTHON?=python3
PYTHON?=python3.10
DEFAULT_TEST_ENV?=py310

venv: $(VENV_NAME)/bin/activate

Expand All @@ -9,8 +10,8 @@ $(VENV_NAME)/bin/activate: setup.py requirements.txt
${VENV_NAME}/bin/python -m pip install -r requirements.txt
@touch $(VENV_NAME)/bin/activate

test: venv
@${VENV_NAME}/bin/tox -p auto $(TOX_ARGS)
test: venv pyright lint mypy
@${VENV_NAME}/bin/tox -p auto -e $(DEFAULT_TEST_ENV) $(TOX_ARGS)

test-nomock: venv
@${VENV_NAME}/bin/tox -p auto -- --nomock $(TOX_ARGS)
Expand All @@ -22,17 +23,10 @@ coveralls: venv
@${VENV_NAME}/bin/tox -e coveralls

pyright: venv
# In order for pyright to be able to follow imports, we need "editable_mode=compat" to force setuptools to do
# an editable install via a .pth file mechanism and not "import hooks". See
# the "editable installs" section of https://github.com/microsoft/pyright/blob/main/docs/import-resolution.md#editable-installs

# This command might fail if we're on python 3.6, as versions of pip that
# support python 3.6 don't know about "--config-settings", but in this case
# we don't need to pass config-settings anyway because "editable_mode=compat" just
# means to perform as these old versions of pip already do.
pip install -e . --config-settings editable_mode=compat || pip install -e .
@${VENV_NAME}/bin/pyright --version
@${VENV_NAME}/bin/pyright $(PYRIGHT_ARGS)
@${VENV_NAME}/bin/tox -e pyright $(PYRIGHT_ARGS)

mypy: venv
@${VENV_NAME}/bin/tox -e mypy $(MYPY_ARGS)

fmt: venv
@${VENV_NAME}/bin/tox -e fmt
Expand All @@ -52,4 +46,4 @@ update-version:

codegen-format: fmt

.PHONY: ci-test clean codegen-format coveralls fmt fmtcheck lint test test-nomock test-travis update-version venv pyright
.PHONY: ci-test clean codegen-format coveralls fmt fmtcheck lint test test-nomock test-travis update-version venv pyright mypy
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v655
v669
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,40 @@ You can disable this behavior if you prefer:
stripe.enable_telemetry = False
```

### Beta SDKs
## Types

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.

### 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`.

### 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.

## Beta SDKs

Stripe has features in the beta phase that can be accessed via the beta version of this package.
We would love for you to try these and share feedback with us before these features reach the stable phase.
Expand Down
36 changes: 23 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.black]
line-length=79
line-length = 79
target-version = [
"py35",
"py36",
"py37",
"py38",
"py39",
"py310",
# "py311", # black 21.12b0 doesn't
# "py312", # support these targets
# "py311", # black 21.12b0 doesn't
# "py312", # support these targets
]
exclude = '''
/(
Expand All @@ -23,14 +23,24 @@ exclude = '''
)
'''
[tool.pyright]
executionEnvironments=[
{"root" = "stripe"},
{"root" = "tests"}
include = [
"stripe",
"tests/test_generated_examples.py",
"tests/test_exports.py",
]
include=["stripe", "tests/test_generated_examples.py"]
exclude=["build", "**/__pycache__"]
reportMissingTypeArgument=true
reportUnnecessaryCast=true
reportUnnecessaryComparison=true
reportUnnecessaryContains=true
reportUnnecessaryIsInstance=true
exclude = ["build", "**/__pycache__"]
reportMissingTypeArgument = true
reportUnnecessaryCast = true
reportUnnecessaryComparison = true
reportUnnecessaryContains = true
reportUnnecessaryIsInstance = true
reportPrivateImportUsage = true
reportUnnecessaryTypeIgnoreComment = true

[tool.mypy]
follow_imports = "silent"
python_version = "3.10"
files = ["tests/test_exports.py"]
disallow_untyped_calls = true
disallow_untyped_defs = true
warn_unused_ignores = true
25 changes: 10 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# cryptography 40.0.0 deprecates support for Python 3.6 and PyPy3 < 7.3.10
cryptography<40
tox
# These requirements must be installable only on py3.10 +
twine
pyright <= 1.1.334
pytest-cov >= 2.8.1, < 2.11.0
pytest-mock >= 2.0.0
pytest-xdist >= 1.31.0
pytest >= 6.0.0
# black==23.11.0 supports py311/py312 targets,
# but it's keen to reformat way too many files
black==21.12b0
click==8.0.4 # Version 8.1 breaks black
# 4.5.0 is the last version that works with virtualenv<20.22.0
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
flake8
coverage >= 4.5.3, < 5
coveralls
tox-gh-actions
mypy == 1.7.0

-r test-requirements.txt
4 changes: 2 additions & 2 deletions stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
log: Optional[Literal["debug", "info"]] = None

# API resources
from stripe.api_resources import * # pyright: ignore # noqa
from stripe.api_resources import * # noqa

from stripe.api_resources import abstract # pyright: ignore # noqa
from stripe.api_resources import abstract # noqa

# OAuth
from stripe.oauth import OAuth # noqa
Expand Down
2 changes: 1 addition & 1 deletion stripe/api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(
self._client = client
elif stripe.default_http_client:
self._client = stripe.default_http_client
if proxy != self._default_proxy: # type: ignore
if proxy != self._default_proxy:
warnings.warn(
"stripe.proxy was updated after sending a "
"request - this is a no-op. To use a different proxy, "
Expand Down
4 changes: 2 additions & 2 deletions stripe/api_resources/abstract/api_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _static_request(

if idempotency_key is not None:
headers = {} if headers is None else headers.copy()
headers.update(util.populate_headers(idempotency_key)) # type: ignore
headers.update(util.populate_headers(idempotency_key))

response, api_key = requestor.request(method_, url_, params, headers)
return util.convert_to_stripe_object(
Expand Down Expand Up @@ -186,7 +186,7 @@ def _static_request_stream(

if idempotency_key is not None:
headers = {} if headers is None else headers.copy()
headers.update(util.populate_headers(idempotency_key)) # type: ignore
headers.update(util.populate_headers(idempotency_key))

response, _ = requestor.request_stream(method_, url_, params, headers)
return response
2 changes: 1 addition & 1 deletion stripe/api_resources/abstract/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def class_url(cls):
)
# Namespaces are separated in object names with periods (.) and in URLs
# with forward slashes (/), so replace the former with the latter.
base = cls._resource_cls.OBJECT_NAME.replace(".", "/") # type: ignore
base = cls._resource_cls.OBJECT_NAME.replace(".", "/")
return "/v1/test_helpers/%ss" % (base,)

def instance_url(self):
Expand Down
Loading