From a07aae7c748cc49f35917e9126b13f71beebb7f8 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 09:33:33 -0800 Subject: [PATCH 01/34] Run pyright in tox --- Makefile | 12 +----------- requirements.txt | 5 +++-- tox.ini | 8 ++++++++ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 4349c8722..ae8370e3d 100644 --- a/Makefile +++ b/Makefile @@ -22,17 +22,7 @@ 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) fmt: venv @${VENV_NAME}/bin/tox -e fmt diff --git a/requirements.txt b/requirements.txt index 05f5feee8..affcd1781 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,8 @@ cryptography<40 tox twine -pyright +tox == 4.11.3 +pyright == 1.1.336 pytest-cov >= 2.8.1, < 2.11.0 pytest-mock >= 2.0.0 pytest-xdist >= 1.31.0 @@ -14,4 +15,4 @@ click==8.0.4 # Version 8.1 breaks black flake8 coverage >= 4.5.3, < 5 coveralls -tox-gh-actions +tox-gh-actions == 3.1.3 diff --git a/tox.ini b/tox.ini index c37452d52..09bd649b6 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ envlist = fmt lint + pyright py{312,311,310,39,38,37,36,py3} skip_missing_interpreters = true @@ -42,6 +43,13 @@ commands = pytest --cov {posargs:-n auto} --ignore stripe # CFLAGS="-I$(brew --prefix openssl@1.1)/include" passenv = LDFLAGS,CFLAGS +[testenv:pyright] +basepython = python3.10 +use_develop = true +commands = pyright +deps = + -r requirements.txt + [testenv:fmt] description = run code formatting using black basepython = python3.10 From f17707942b547b206769609df86d08bd49cf37fd Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 10:14:36 -0800 Subject: [PATCH 02/34] Update tox.ini by adding skipsdist, skip_install, usedevelop and package set to editable-legacy under testenv:pyright section. --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 09bd649b6..5f89711e4 100644 --- a/tox.ini +++ b/tox.ini @@ -44,8 +44,11 @@ commands = pytest --cov {posargs:-n auto} --ignore stripe passenv = LDFLAGS,CFLAGS [testenv:pyright] +skipsdist = true +skip_install = true +usedevelop = true basepython = python3.10 -use_develop = true +package = editable-legacy commands = pyright deps = -r requirements.txt From f93fd7f8e440afa2be2d2475aa9e13c3888af9dd Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 10:28:03 -0800 Subject: [PATCH 03/34] more --- pyproject.toml | 24 ++++++++++-------------- tox.ini | 8 +++----- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9a1fe8b0a..7c651f1f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.black] -line-length=79 +line-length = 79 target-version = [ "py35", "py36", @@ -7,8 +7,8 @@ target-version = [ "py38", "py39", "py310", -# "py311", # black 21.12b0 doesn't -# "py312", # support these targets + # "py311", # black 21.12b0 doesn't + # "py312", # support these targets ] exclude = ''' /( @@ -23,14 +23,10 @@ exclude = ''' ) ''' [tool.pyright] -executionEnvironments=[ - {"root" = "stripe"}, - {"root" = "tests"} -] -include=["stripe", "tests/test_generated_examples.py"] -exclude=["build", "**/__pycache__"] -reportMissingTypeArgument=true -reportUnnecessaryCast=true -reportUnnecessaryComparison=true -reportUnnecessaryContains=true -reportUnnecessaryIsInstance=true +include = ["stripe", "tests/test_generated_examples.py"] +exclude = ["build", "**/__pycache__"] +reportMissingTypeArgument = true +reportUnnecessaryCast = true +reportUnnecessaryComparison = true +reportUnnecessaryContains = true +reportUnnecessaryIsInstance = true diff --git a/tox.ini b/tox.ini index 5f89711e4..710477613 100644 --- a/tox.ini +++ b/tox.ini @@ -44,12 +44,10 @@ commands = pytest --cov {posargs:-n auto} --ignore stripe passenv = LDFLAGS,CFLAGS [testenv:pyright] -skipsdist = true -skip_install = true -usedevelop = true basepython = python3.10 -package = editable-legacy -commands = pyright +skip_install = true +commands = + pyright deps = -r requirements.txt From 34fbad7502f28b169f04042257443aba1430c3f4 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 10:29:20 -0800 Subject: [PATCH 04/34] Remove 'tox' from requirements.txt. --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 626b50e60..3c96bb2c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ # cryptography 40.0.0 deprecates support for Python 3.6 and PyPy3 < 7.3.10 cryptography<40 -tox twine tox == 4.11.3 pyright == 1.1.336 From 4b817ab1c030d2e51aba9e84827a58fd6a57b90d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 10:31:34 -0800 Subject: [PATCH 05/34] need no deps --- Makefile | 2 +- tox.ini | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ae8370e3d..d35ee6711 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ $(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 +test: venv pyright @${VENV_NAME}/bin/tox -p auto $(TOX_ARGS) test-nomock: venv diff --git a/tox.ini b/tox.ini index 710477613..889399ed2 100644 --- a/tox.ini +++ b/tox.ini @@ -48,8 +48,6 @@ basepython = python3.10 skip_install = true commands = pyright -deps = - -r requirements.txt [testenv:fmt] description = run code formatting using black From 3bd1e4a454467d7e14ddfcc179aee861f1b8bf5a Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 10:45:18 -0800 Subject: [PATCH 06/34] isntall and test using different versions --- .github/workflows/ci.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddbf3cf6d..ac74cf5f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,9 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -92,23 +95,10 @@ jobs: cache: "pip" cache-dependency-path: "setup.py" - - name: Upgrade pip and virtualenv to latest - run: pip install --upgrade pip virtualenv - - 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' - - name: Test with pytest - run: make ci-test + run: TOX_ARGS="-e ${{ matrix.python-version }}" make ci-test - name: Calculate and publish coverage run: make coveralls From 444a3db731832f3e0c52f0facf8e875f7f7876af Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 10:53:44 -0800 Subject: [PATCH 07/34] split requirements --- requirements.txt | 8 ++------ test-requirements.txt | 8 ++++++++ tox.ini | 8 +++++++- 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 test-requirements.txt diff --git a/requirements.txt b/requirements.txt index 3c96bb2c4..16946d8db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,12 +3,8 @@ cryptography<40 twine tox == 4.11.3 pyright == 1.1.336 -pytest-cov >= 2.8.1, < 2.11.0 -pytest-mock >= 2.0.0 -pytest-xdist >= 1.31.0 -pytest >= 6.0.0 black == 22.8.0 flake8 -coverage >= 4.5.3, < 5 -coveralls tox-gh-actions == 3.1.3 + +-r test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..01c30b5d0 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,8 @@ + +pyright == 1.1.336 +pytest-cov >= 2.8.1, < 2.11.0 +pytest-mock >= 2.0.0 +pytest-xdist >= 1.31.0 +pytest >= 6.0.0 +coverage >= 4.5.3, < 5 +coveralls diff --git a/tox.ini b/tox.ini index 889399ed2..aeea7a31d 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ description = run the unit tests under {basepython} setenv = COVERAGE_FILE = {toxworkdir}/.coverage.{envname} deps = - -r requirements.txt + -r test-requirements.txt # ignore stripe directory as all tests are inside ./tests commands = pytest --cov {posargs:-n auto} --ignore stripe @@ -48,12 +48,16 @@ basepython = python3.10 skip_install = true commands = pyright +deps = + -r requirements.txt [testenv:fmt] description = run code formatting using black basepython = python3.10 commands = black . {posargs} skip_install = true +deps = + -r requirements.txt [testenv:lint] description = run static analysis and style check using flake8 @@ -61,6 +65,8 @@ basepython = python3.10 commands = python -m flake8 --show-source stripe tests setup.py skip_install = true +deps = + -r requirements.txt [testenv:coveralls] description = upload coverage to coveralls.io From 23499c93eb3019a986794e2dad0cf2dc2ea5d002 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:02:39 -0800 Subject: [PATCH 08/34] Git: Add 'fail-fast: false' to CI workflow configuration and remove 'pyright == 1.1.336' from test-requirements. --- .github/workflows/ci.yml | 1 + test-requirements.txt | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac74cf5f3..f9123f50a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,7 @@ jobs: # move to ubuntu-latest when we drop 3.6 runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: python-version: [ diff --git a/test-requirements.txt b/test-requirements.txt index 01c30b5d0..97d6ac2ff 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,3 @@ - -pyright == 1.1.336 pytest-cov >= 2.8.1, < 2.11.0 pytest-mock >= 2.0.0 pytest-xdist >= 1.31.0 From e46ed693046e4ef39f2bc28870943a91586cc4c8 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:05:16 -0800 Subject: [PATCH 09/34] Update ci.yml: remove previous Python 3.10 set up, use matrix python-version for set up, add new set up for Python 3.10 after pip cache settings. --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9123f50a..c9f57ebcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,9 +86,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -96,6 +93,9 @@ jobs: cache: "pip" cache-dependency-path: "setup.py" + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + - uses: stripe/openapi/actions/stripe-mock@master - name: Test with pytest From 4f0e36aef68131813ae68165297f84cdecc9e298 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:08:22 -0800 Subject: [PATCH 10/34] Makefile: Change default Python version from python3 to python3.10. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d35ee6711..054a48649 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VENV_NAME?=venv PIP?=pip -PYTHON?=python3 +PYTHON?=python3.10 venv: $(VENV_NAME)/bin/activate From b54f7da4cb2187a26dde4c833f2af4cdb8625444 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:10:10 -0800 Subject: [PATCH 11/34] Update ci.yml to set up Python version 3.10 in Github workflows. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9f57ebcc..e390fe59c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,6 +95,8 @@ jobs: - name: Set up Python 3.10 uses: actions/setup-python@v4 + with: + python-version: "3.10" - uses: stripe/openapi/actions/stripe-mock@master From 55451593850a54ab52eab5600f0c47ef4279d6c1 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:12:57 -0800 Subject: [PATCH 12/34] explicit --- Makefile | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 054a48649..044e0f2bd 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ $(VENV_NAME)/bin/activate: setup.py requirements.txt @touch $(VENV_NAME)/bin/activate test: venv pyright - @${VENV_NAME}/bin/tox -p auto $(TOX_ARGS) + @${VENV_NAME}/bin/tox -p auto -e $(PYTHON) $(TOX_ARGS) test-nomock: venv @${VENV_NAME}/bin/tox -p auto -- --nomock $(TOX_ARGS) diff --git a/tox.ini b/tox.ini index aeea7a31d..41221469f 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,6 @@ envlist = lint pyright py{312,311,310,39,38,37,36,py3} -skip_missing_interpreters = true [gh-actions] python = From fe09c960106938c38257b8edf36e9bff7fd82864 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:18:47 -0800 Subject: [PATCH 13/34] Change job name in ci.yml from 'Lint' to 'Typecheck and lint' and add typechecking step with pyright. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e390fe59c..689833d36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ on: jobs: lint: - name: Lint + name: Typecheck and lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -27,6 +27,8 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Typecheck with pyright + run: make pyright - name: lint run: make lint - name: fmtcheck From 4b844413f21f1ec9b07b8d547b8c2c3290dd5ac6 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:23:18 -0800 Subject: [PATCH 14/34] Combine testenv:pyright, testenv:fmt, and testenv:lint into a single testenv in tox.ini. --- tox.ini | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/tox.ini b/tox.ini index 41221469f..5bc18bb13 100644 --- a/tox.ini +++ b/tox.ini @@ -42,28 +42,13 @@ commands = pytest --cov {posargs:-n auto} --ignore stripe # CFLAGS="-I$(brew --prefix openssl@1.1)/include" passenv = LDFLAGS,CFLAGS -[testenv:pyright] +[testenv:{lint,fmt,pyright}] basepython = python3.10 skip_install = true commands = - pyright -deps = - -r requirements.txt - -[testenv:fmt] -description = run code formatting using black -basepython = python3.10 -commands = black . {posargs} -skip_install = true -deps = - -r requirements.txt - -[testenv:lint] -description = run static analysis and style check using flake8 -basepython = python3.10 -commands = - python -m flake8 --show-source stripe tests setup.py -skip_install = true + pyright: pyright + lint: python -m flake8 --show-source stripe tests setup.py + fmt: black . {posargs} deps = -r requirements.txt From 07654f0fa1e00f13be5328fd09256e1d1b5964a2 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:25:41 -0800 Subject: [PATCH 15/34] The commit modifies the CI workflow file to change the job name from "Typecheck and lint" to "Lint", remove the "Typecheck with pyright" step from the lint job, add a new "Typecheck with pyright" step to the jobs with command line arguments, and rearrange the order of the steps. --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 689833d36..c79da7970 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ on: jobs: lint: - name: Typecheck and lint + name: Lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -27,8 +27,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" - - name: Typecheck with pyright - run: make pyright - name: lint run: make lint - name: fmtcheck @@ -102,6 +100,9 @@ jobs: - uses: stripe/openapi/actions/stripe-mock@master + - name: Typecheck with pyright + run: PYRIGHT_ARGS="--pythonversion ${{ matrix.python-version }}" make pyright + - name: Test with pytest run: TOX_ARGS="-e ${{ matrix.python-version }}" make ci-test From 0d28c00e0a0b3d116138b9284511d3d93a031c22 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:27:10 -0800 Subject: [PATCH 16/34] Git diff shows the changes made in the file ".github/workflows/ci.yml", specifically in the command for the "Typecheck with pyright" action. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c79da7970..0af111d71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,7 +101,7 @@ jobs: - uses: stripe/openapi/actions/stripe-mock@master - name: Typecheck with pyright - run: PYRIGHT_ARGS="--pythonversion ${{ matrix.python-version }}" make pyright + run: PYRIGHT_ARGS="-- --pythonversion ${{ matrix.python-version }}" make pyright - name: Test with pytest run: TOX_ARGS="-e ${{ matrix.python-version }}" make ci-test From c3764614c9a1262e4b731a33877d8070c56851d7 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:31:03 -0800 Subject: [PATCH 17/34] Git: Add condition to skip typechecking in pypy legs in ci.yml and pass positional arguments in pyright command in tox.ini. --- .github/workflows/ci.yml | 2 ++ tox.ini | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0af111d71..5d3576a8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,6 +102,8 @@ jobs: - 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-version }}" make ci-test diff --git a/tox.ini b/tox.ini index 5bc18bb13..6d4e186db 100644 --- a/tox.ini +++ b/tox.ini @@ -46,7 +46,7 @@ passenv = LDFLAGS,CFLAGS basepython = python3.10 skip_install = true commands = - pyright: pyright + pyright: pyright {posargs} lint: python -m flake8 --show-source stripe tests setup.py fmt: black . {posargs} deps = From 3f39b2360c90cfa0d3479abaa94c1ba2f1ab5022 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:39:12 -0800 Subject: [PATCH 18/34] [LLM] Makefile updated to include 'DEFAULT_TEST_ENV' variable, updated 'test' target to depend on 'lint', and changed 'PYTHON' variable in 'test' target to 'DEFAULT_TEST_ENV'. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 044e0f2bd..dd1ebcecd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ VENV_NAME?=venv PIP?=pip PYTHON?=python3.10 +DEFAULT_TEST_ENV?=py310 venv: $(VENV_NAME)/bin/activate @@ -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 pyright - @${VENV_NAME}/bin/tox -p auto -e $(PYTHON) $(TOX_ARGS) +test: venv pyright lint + @${VENV_NAME}/bin/tox -p auto -e $(DEFAULT_TEST_ENV) $(TOX_ARGS) test-nomock: venv @${VENV_NAME}/bin/tox -p auto -- --nomock $(TOX_ARGS) From 560ad48289cae7c7f30783ed47ab5115e7dc4a6c Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:49:04 -0800 Subject: [PATCH 19/34] [LLM] Added 'ignore_base_python_conflict = false' to tox.ini file. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 6d4e186db..a552d5d2b 100644 --- a/tox.ini +++ b/tox.ini @@ -20,6 +20,7 @@ python = 3.7: py37 3.6: py36 pypy-3: pypy3 +ignore_base_python_conflict = false [tool:pytest] testpaths = tests From 99aa7245ae088782110b4eb66b65ec0980fe255a Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 11:56:48 -0800 Subject: [PATCH 20/34] [LLM] Update '.github/workflows/ci.yml' and 'tox.ini' to map python-versions to environments explicitly and replace variable 'python-version' with 'env' in the command run by tox. --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++--------------- tox.ini | 11 ----------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d3576a8c..ae46748d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,20 +68,29 @@ jobs: 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", - ] + include: + - python-version: "3.6" + env: py36 + - python-version: "3.7" + env: py37 + - python-version: "3.8" + env: py38 + - python-version: "3.9" + env: py39 + - python-version: "3.10" + env: py310 + - python-version: "3.11" + env: py311 + - python-version: "3.12" + env: py312 + - python-version: "pypy-3.7" + env: py3.7 + - python-version: "pypy-3.8" + env: py3.8 + - python-version: "pypy-3.9" + env: py3.9 + - python-version: "pypy-3.10" + env: py3.10 steps: - uses: actions/checkout@v3 @@ -106,7 +115,7 @@ jobs: if: ${{ !contains(matrix.python-version, 'pypy') }} - name: Test with pytest - run: TOX_ARGS="-e ${{ matrix.python-version }}" make ci-test + run: TOX_ARGS="-e ${{ matrix.env }}" make ci-test - name: Calculate and publish coverage run: make coveralls diff --git a/tox.ini b/tox.ini index a552d5d2b..87461395d 100644 --- a/tox.ini +++ b/tox.ini @@ -9,17 +9,6 @@ envlist = lint pyright py{312,311,310,39,38,37,36,py3} - -[gh-actions] -python = - 3.12: py312 - 3.11: py311 - 3.10: py310 - 3.9: py39 - 3.8: py38 - 3.7: py37 - 3.6: py36 - pypy-3: pypy3 ignore_base_python_conflict = false [tool:pytest] From 69fd8b76335860e5d42a737cc913439dcc7314aa Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:04:13 -0800 Subject: [PATCH 21/34] [LLM] Removed separate Python 3.10 setup step and integrated it into the existing Python setup in ci.yml, and removed tox-gh-actions from requirements.txt. --- .github/workflows/ci.yml | 13 ++++--------- requirements.txt | 1 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae46748d7..d774be3bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,17 +95,12 @@ jobs: 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: Set up Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" + python-version: | + ${{ matrix.python-version }} + 3.10 - uses: stripe/openapi/actions/stripe-mock@master diff --git a/requirements.txt b/requirements.txt index 16946d8db..405d39254 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,5 @@ tox == 4.11.3 pyright == 1.1.336 black == 22.8.0 flake8 -tox-gh-actions == 3.1.3 -r test-requirements.txt From a1f7e35a7b60e8f8737a7e6d7d3380af7884fd59 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:10:52 -0800 Subject: [PATCH 22/34] remove stripe-mock-check --- tests/conftest.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 836859fe0..f66528a81 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,8 +12,6 @@ from tests.request_mock import RequestMock from tests.stripe_mock import StripeMock -MOCK_MINIMUM_VERSION = "0.109.0" - # Starts stripe-mock if an OpenAPI spec override is found in `openapi/`, and # otherwise fall back to `STRIPE_MOCK_PORT` or 12111. if StripeMock.start(): @@ -31,18 +29,6 @@ def pytest_configure(config): if not config.getoption("--nomock"): try: resp = urlopen("http://localhost:%s/" % MOCK_PORT) - info = resp.info() - version = info.get("Stripe-Mock-Version") - if version != "master" and StrictVersion(version) < StrictVersion( - MOCK_MINIMUM_VERSION - ): - sys.exit( - "Your version of stripe-mock (%s) is too old. The minimum " - "version to run this test suite is %s. Please " - "see its repository for upgrade instructions." - % (version, MOCK_MINIMUM_VERSION) - ) - except HTTPError as e: info = e.info() except Exception: From 836a1481c8d93cea35bd4447fda2a5f7e144d991 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:11:12 -0800 Subject: [PATCH 23/34] better --- tests/conftest.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f66528a81..5d57bb37d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -28,9 +28,7 @@ def stop_stripe_mock(): def pytest_configure(config): if not config.getoption("--nomock"): try: - resp = urlopen("http://localhost:%s/" % MOCK_PORT) - except HTTPError as e: - info = e.info() + urlopen("http://localhost:%s/" % MOCK_PORT) except Exception: sys.exit( "Couldn't reach stripe-mock at `localhost:%s`. Is " From 2093c66803b6242929f6a89856d5a38f50590ad6 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:13:31 -0800 Subject: [PATCH 24/34] try this --- tox.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tox.ini b/tox.ini index 87461395d..64625b986 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,9 @@ setenv = deps = -r test-requirements.txt +[testenv:py36] +basepython = python3.6 + # ignore stripe directory as all tests are inside ./tests commands = pytest --cov {posargs:-n auto} --ignore stripe # compilation flags can be useful when prebuilt wheels cannot be used, e.g. From e4c9434f2ef77e3890d4e0aa60d35a6ba5806973 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:14:10 -0800 Subject: [PATCH 25/34] remove more --- tests/conftest.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5d57bb37d..872716ed8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,13 +1,10 @@ import atexit import os import sys -from distutils.version import StrictVersion - import pytest import stripe from urllib.request import urlopen -from urllib.error import HTTPError from tests.request_mock import RequestMock from tests.stripe_mock import StripeMock From 5330a74065df23f40c7b27e22674c0ba332f87dc Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:17:49 -0800 Subject: [PATCH 26/34] [LLM] Update requirements.txt file to specify virtualenv version due to dropped support for Python versions <= 3.6, and remove Python 3.6 basepython specification from tox.ini file. --- requirements.txt | 2 ++ tox.ini | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 405d39254..c19066e4b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,7 @@ tox == 4.11.3 pyright == 1.1.336 black == 22.8.0 flake8 +#Virtualenv 20.22.0 dropped support for all Python versions smaller or equal to Python 3.6. +virtualenv<20.22.0 -r test-requirements.txt diff --git a/tox.ini b/tox.ini index 64625b986..87461395d 100644 --- a/tox.ini +++ b/tox.ini @@ -23,9 +23,6 @@ setenv = deps = -r test-requirements.txt -[testenv:py36] -basepython = python3.6 - # ignore stripe directory as all tests are inside ./tests commands = pytest --cov {posargs:-n auto} --ignore stripe # compilation flags can be useful when prebuilt wheels cannot be used, e.g. From d0ec83b13871b4099f89f0c3677159951ab8c3d7 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:19:51 -0800 Subject: [PATCH 27/34] [LLM] Downgrade tox from 4.11.3 to 4.5.0 and move the comment and version constraint for virtualenv in requirements.txt. --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index c19066e4b..d6065c252 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ # cryptography 40.0.0 deprecates support for Python 3.6 and PyPy3 < 7.3.10 cryptography<40 twine -tox == 4.11.3 +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 -#Virtualenv 20.22.0 dropped support for all Python versions smaller or equal to Python 3.6. -virtualenv<20.22.0 -r test-requirements.txt From 0d1da0f647bc73098a8f8baea6bea8007bd1226d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:19:59 -0800 Subject: [PATCH 28/34] comment --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d6065c252..9330f5167 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # cryptography 40.0.0 deprecates support for Python 3.6 and PyPy3 < 7.3.10 cryptography<40 twine +# 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 From 3e9cd04e2a32801a92b68b78138a84d84ca47b7d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:27:09 -0800 Subject: [PATCH 29/34] fix mock detection --- tests/conftest.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 872716ed8..809568516 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,11 +4,13 @@ import pytest import stripe -from urllib.request import urlopen +import requests from tests.request_mock import RequestMock from tests.stripe_mock import StripeMock +MOCK_MINIMUM_VERSION = "0.109.0" + # Starts stripe-mock if an OpenAPI spec override is found in `openapi/`, and # otherwise fall back to `STRIPE_MOCK_PORT` or 12111. if StripeMock.start(): @@ -25,7 +27,7 @@ def stop_stripe_mock(): def pytest_configure(config): if not config.getoption("--nomock"): try: - urlopen("http://localhost:%s/" % MOCK_PORT) + requests.get("http://localhost:%s/" % MOCK_PORT) except Exception: sys.exit( "Couldn't reach stripe-mock at `localhost:%s`. Is " From 5f3ae4aa12ad107ebc232628f762eb6c0d17b272 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:33:47 -0800 Subject: [PATCH 30/34] [LLM] Changed test name dynamic based on python-version, remove deprecated cryptography support for Python 3.6 and PyPy3 < 7.3.10 in requirements.txt, and added comments for requirements and test-requirements. --- .github/workflows/ci.yml | 3 +-- requirements.txt | 3 +-- test-requirements.txt | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d774be3bd..b6a6bfc16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: path: dist/ test: - name: Test + name: Test ${{ python-version }} # 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 @@ -91,7 +91,6 @@ jobs: env: py3.9 - python-version: "pypy-3.10" env: py3.10 - steps: - uses: actions/checkout@v3 diff --git a/requirements.txt b/requirements.txt index 9330f5167..2dfa00516 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ -# cryptography 40.0.0 deprecates support for Python 3.6 and PyPy3 < 7.3.10 -cryptography<40 +# These requirements must be installable only on py3.10 + twine # 4.5.0 is the last version that works with virtualenv<20.22.0 tox == 4.5.0 diff --git a/test-requirements.txt b/test-requirements.txt index 97d6ac2ff..a06d9840d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +# These requirements must be installable on all our supported versions pytest-cov >= 2.8.1, < 2.11.0 pytest-mock >= 2.0.0 pytest-xdist >= 1.31.0 From 3a4fbba7a0e60991761bcf41da306fd410513f15 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:35:35 -0800 Subject: [PATCH 31/34] [LLM] Move `name: Test ${{ python-version }}` from line 63 to line 94 in .github/workflows/ci.yml. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6a6bfc16..9dc4216ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,6 @@ jobs: path: dist/ test: - name: Test ${{ python-version }} # 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 @@ -91,6 +90,7 @@ jobs: env: py3.9 - python-version: "pypy-3.10" env: py3.10 + name: Test ${{ python-version }} steps: - uses: actions/checkout@v3 From 289988d6307bf72b14a14f0e76c9a75c6d9bf6b0 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:38:21 -0800 Subject: [PATCH 32/34] [LLM] Refactor python version setup in GitHub Actions workflow, change 'python-version' to 'python.version', significantly simplify matrix configuration, and adjust related environment variables. --- .github/workflows/ci.yml | 57 ++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9dc4216ec..f39ac0ba9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python-version: "3.10" + python.version: "3.10" - name: lint run: make lint - name: fmtcheck @@ -41,7 +41,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python-version: "3.10" + python.version: "3.10" - name: Install tools run: make venv @@ -67,53 +67,42 @@ jobs: strategy: fail-fast: false matrix: - include: - - python-version: "3.6" - env: py36 - - python-version: "3.7" - env: py37 - - python-version: "3.8" - env: py38 - - python-version: "3.9" - env: py39 - - python-version: "3.10" - env: py310 - - python-version: "3.11" - env: py311 - - python-version: "3.12" - env: py312 - - python-version: "pypy-3.7" - env: py3.7 - - python-version: "pypy-3.8" - env: py3.8 - - python-version: "pypy-3.9" - env: py3.9 - - python-version: "pypy-3.10" - env: py3.10 - name: Test ${{ python-version }} + 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 }} and 3.10 + - name: Set up Python ${{ matrix.python.version }} and 3.10 uses: actions/setup-python@v4 with: - python-version: | - ${{ matrix.python-version }} + python.version: | + ${{ matrix.python.version }} 3.10 - uses: stripe/openapi/actions/stripe-mock@master - name: Typecheck with pyright - run: PYRIGHT_ARGS="-- --pythonversion ${{ matrix.python-version }}" make pyright + run: PYRIGHT_ARGS="-- --pythonversion ${{ matrix.python.version }}" make pyright # Skip typecheking in pypy legs - if: ${{ !contains(matrix.python-version, 'pypy') }} + if: ${{ !contains(matrix.python.version, 'pypy') }} - name: Test with pytest - run: TOX_ARGS="-e ${{ matrix.env }}" 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 }} @@ -136,7 +125,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python-version: "3.10" + python.version: "3.10" - name: Configure GPG Key run: | From 5a6f5476cf5b268076aa9694267f07d9a8f9a206 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:38:47 -0800 Subject: [PATCH 33/34] [LLM] ci.yml: Change display format of Python version in test name. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f39ac0ba9..edbf1c6bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: - { 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 }} + name: Test (${{ matrix.python.version }}) steps: - uses: actions/checkout@v3 From e4fb670b05c2f2659ae76633b5210fd44096628e Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 15 Nov 2023 12:40:09 -0800 Subject: [PATCH 34/34] [LLM] Change key from 'python.version' to 'python-version' in .github/workflows/ci.yml. --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edbf1c6bb..5814deeee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python.version: "3.10" + python-version: "3.10" - name: lint run: make lint - name: fmtcheck @@ -41,7 +41,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python.version: "3.10" + python-version: "3.10" - name: Install tools run: make venv @@ -86,7 +86,7 @@ jobs: - name: Set up Python ${{ matrix.python.version }} and 3.10 uses: actions/setup-python@v4 with: - python.version: | + python-version: | ${{ matrix.python.version }} 3.10 @@ -125,7 +125,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v4 with: - python.version: "3.10" + python-version: "3.10" - name: Configure GPG Key run: |