Skip to content

Commit

Permalink
Merge pull request #1439 from stripe/latest-codegen-beta
Browse files Browse the repository at this point in the history
Update generated code for beta
  • Loading branch information
stripe-openapi[bot] authored Jan 18, 2025
2 parents 46741a7 + be43bda commit 4e0f89b
Show file tree
Hide file tree
Showing 47 changed files with 1,139 additions and 216 deletions.
98 changes: 45 additions & 53 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,47 @@ on:

jobs:
lint:
name: Lint & Mypy
runs-on: ubuntu-latest
name: Static Checks
runs-on: "ubuntu-24.04"
steps:
- uses: extractions/setup-just@v2
- 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
run: make fmtcheck
- name: check examples w/ mypy (against [email protected])
run: just typecheck-examples
# skip deps on all these since mypy installed everything
- name: check linting
run: just --no-deps lint
- name: check formatting
run: just --no-deps format-check
# pyright depends on node, which it handles and installs for itself as needed
# we _could_ run setup-node to make it available for it if we're having reliability problems
- name: check types (all Python versions)
run: |
set -eox
for minor in {6..12}; do
just --no-deps typecheck $minor
done
build:
name: Build
runs-on: ubuntu-latest
runs-on: "ubuntu-24.04"
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install tools
run: make venv

- name: Build and check package
run: |
set -x
source venv/bin/activate
python setup.py clean --all sdist bdist_wheel --universal
python -m twine check dist/*
just build
- name: "Upload Artifact"
uses: actions/upload-artifact@v3
Expand All @@ -69,45 +75,30 @@ jobs:
strategy:
fail-fast: false
matrix:
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 }})
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"
name: Test (${{ matrix.python_version }})
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python.version }} and 3.10
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: |
${{ matrix.python.version }}
3.10
python-version: ${{ matrix.python_version }}
- uses: stripe/openapi/actions/stripe-mock@master

- name: Typecheck with pyright
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: 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'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: "run tests"
run: just test

publish:
name: Publish
Expand All @@ -116,7 +107,7 @@ jobs:
startsWith(github.ref, 'refs/tags/v') &&
endsWith(github.actor, '-stripe')
needs: [build, test, lint]
runs-on: ubuntu-latest
runs-on: "ubuntu-24.04"
steps:
- uses: actions/checkout@v3
- name: Download all workflow run artifacts
Expand All @@ -137,11 +128,12 @@ jobs:
GPG_SIGNING_PRIVKEY: ${{ secrets.GPG_SIGNING_PRIVKEY }}
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }}
- name: Install tools
run: make venv
- name: Publish packages to PyPy
run: just install-build-deps
- name: Publish packages to PyPI
# could probably move this into a just recipe too?
run: |
set -ex
source venv/bin/activate
source .venv/bin/activate
export VERSION=$(cat VERSION)
gpg --detach-sign --local-user $GPG_SIGNING_KEYID --pinentry-mode loopback --passphrase $GPG_SIGNING_PASSPHRASE -a dist/stripe-$VERSION.tar.gz
gpg --detach-sign --local-user $GPG_SIGNING_KEYID --pinentry-mode loopback --passphrase $GPG_SIGNING_PASSPHRASE -a dist/stripe-$VERSION-py2.py3-none-any.whl
Expand Down
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Contributing

We welcome bug reports, feature requests, and code contributions in a pull request.

For most pull requests, we request that you identify or create an associated issue that has the necessary context. We use these issues to reach agreement on an approach and save the PR author from having to redo work. Fixing typos or documentation issues likely do not need an issue; for any issue that introduces substantial code changes, changes the public interface, or if you aren't sure, please find or [create an issue](https://www.github.com/stripe/stripe-python/issues/new/choose).

## Contributor License Agreement

All contributors must sign the Contributor License Agreement (CLA) before we can accept their contribution. If you have not yet signed the agreement, you will be given an option to do so when you open a pull request. You can then sign by clicking on the badge in the comment from @CLAassistant.

## Generated code

This project has a combination of manually maintained code and code generated from our private code generator. If your contribution involves changes to generated code, please call this out in the issue or pull request as we will likely need to make a change to our code generator before accepting the contribution.

To identify files with purely generated code, look for the comment `File generated from our OpenAPI spec.` at the start of the file. Generated blocks of code within hand-written files will be between comments that say `The beginning of the section generated from our OpenAPI spec` and `The end of the section generated from our OpenAPI spec`.

## Compatibility with supported language and runtime versions

This project supports [many different langauge and runtime versions](README.md#requirements) and we are unable to accept any contribution that does not work on _all_ supported versions. If, after discussing the approach in the associated issue, your change must use an API / feature that isn't available in all supported versions, please call this out explicitly in the issue or pull request so we can help figure out the best way forward.

## Set up your dev environment

Please refer to this project's [README.md](README.md#development) for instructions on how to set up your development environment.

4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include .coveragerc .flake8 CHANGELOG.md LICENSE LONG_DESCRIPTION.rst README.md VERSION pytest.ini tox.ini
# this file specifies what's included in a source distribution (https://packaging.python.org/en/latest/glossary/#term-Source-Distribution-or-sdist)
# see also: https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html
include .flake8 CHANGELOG.md LICENSE LONG_DESCRIPTION.rst README.md VERSION pytest.ini justfile
recursive-include tests *.py
recursive-include examples *.txt *.py
49 changes: 0 additions & 49 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1436
v1454
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![pypi](https://img.shields.io/pypi/v/stripe.svg)](https://pypi.python.org/pypi/stripe)
[![Build Status](https://github.com/stripe/stripe-python/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stripe/stripe-python/actions?query=branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/stripe/stripe-python/badge.svg?branch=master)](https://coveralls.io/github/stripe/stripe-python?branch=master)

The Stripe Python library provides convenient access to the Stripe API from
applications written in the Python language. It includes a pre-defined set of
Expand Down Expand Up @@ -332,6 +331,8 @@ New features and bug fixes are released on the latest major version of the Strip

## Development

[Contribution guidelines for this project](CONTRIBUTING.md)

The test suite depends on [stripe-mock], so make sure to fetch and run it from a
background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):
Expand All @@ -341,54 +342,57 @@ go install github.com/stripe/stripe-mock@latest
stripe-mock
```
Run the following command to set up the development virtualenv:
```sh
make
```
We use [just](https://github.com/casey/just) for conveniently running development tasks. You can use them directly, or copy the commands out of the `justfile`. To our help docs, run `just`. By default, all commands will use an virtualenv created by your default python version (whatever comes out of `python --version`). We recommend using [mise](https://mise.jdx.dev/lang/python.html) or [pyenv](https://github.com/pyenv/pyenv) to control that version.
Run all tests on all supported Python versions:
Run the following command to set up the development virtualenv:
```sh
make test
just venv
# or: python -m venv venv && venv/bin/python -I -m pip install -e .
```
Run all tests for a specific Python version (modify `-e` according to your Python target):
Run all tests:
```sh
TOX_ARGS="-e py37" make test
just test
# or: venv/bin/pytest
```
Run all tests in a single file:
```sh
TOX_ARGS="-e py37 -- tests/api_resources/abstract/test_updateable_api_resource.py" make test
just test tests/api_resources/abstract/test_updateable_api_resource.py
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py
```
Run a single test suite:
```sh
TOX_ARGS="-e py37 -- tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource" make test
just test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource
```
Run a single test:
```sh
TOX_ARGS="-e py37 -- tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save" make test
just test tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save
# or: venv/bin/pytest tests/api_resources/abstract/test_updateable_api_resource.py::TestUpdateableAPIResource::test_save
```
Run the linter with:
```sh
make lint
just lint
# or: venv/bin/python -m flake8 --show-source stripe tests setup.py
```
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:
```sh
make fmt
just format
# or: venv/bin/ruff format . --quiet
```
[api-keys]: https://dashboard.stripe.com/account/apikeys
Expand Down
4 changes: 4 additions & 0 deletions deps/build-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# packages needed to package & release

twine
setuptools
11 changes: 11 additions & 0 deletions deps/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# packages needed to run static analysis (lints, types, etc)
# version requirements: any modern python version (currently 3.10)

# typechecking for all versions
pyright == 1.1.336
# general typechecking
mypy == 1.7.0
# formatting
ruff == 0.4.4
# linting
flake8
6 changes: 2 additions & 4 deletions test-requirements.txt → deps/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These requirements must be installable on all our supported versions
# packages needed to run unit tests (including extra supported http libraries)
# version requirements: all supported versions (currently 3.6-3.12)

# This is the last version of httpx compatible with Python 3.6
httpx == 0.22.0; python_version == "3.6"
Expand All @@ -8,10 +9,7 @@ aiohttp == 3.8.6; python_version <= "3.7"
aiohttp == 3.9.4; python_version > "3.7"
anyio[trio] == 3.6.2

pytest-cov >= 2.8.1, < 2.11.0
pytest-mock >= 2.0.0
mock >= 4.0; python_version < "3.8"
pytest-xdist >= 1.31.0
pytest >= 6.0.0
coverage >= 4.5.3, < 5
coveralls
Loading

0 comments on commit 4e0f89b

Please sign in to comment.