From 2a27dba1c86d7387bf916885f73bb253e3335d55 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 13:32:40 +0200 Subject: [PATCH 1/5] Release 7.2.1: PaymentRequiredError for HTTP 402. --- CHANGELOG.rst | 5 +++++ README.rst | 1 + castle/core/process_response.py | 2 ++ castle/errors.py | 4 ++++ castle/test/core/process_response_test.py | 5 +++++ castle/version.py | 2 +- 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7abafa7..f00c222 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ master ------ +7.2.1 (2026-09-07) +------------------ + +- add ``PaymentRequiredError`` for HTTP 402 responses + 7.2.0 (2026-06-09) ------------------ diff --git a/README.rst b/README.rst index b6bbdd0..a45dc00 100644 --- a/README.rst +++ b/README.rst @@ -190,6 +190,7 @@ All exceptions inherit from ``CastleError``. The most useful ones: - ``InvalidRequestTokenError`` — the request token is missing or invalid - ``InvalidParametersError`` — 422 response with validation details - ``RateLimitError`` — 429 response; back off and retry +- ``PaymentRequiredError`` — 402 response - ``UnauthorizedError`` — 401; bad API secret - ``InternalServerError`` — 5xx response from Castle - ``WebhookVerificationError`` — webhook signature did not match diff --git a/castle/core/process_response.py b/castle/core/process_response.py index e8d7669..93e216d 100644 --- a/castle/core/process_response.py +++ b/castle/core/process_response.py @@ -10,12 +10,14 @@ InternalServerError, InvalidRequestTokenError, RateLimitError, + PaymentRequiredError, ) from castle.logger import Logger RESPONSE_ERRORS = { 400: BadRequestError, 401: UnauthorizedError, + 402: PaymentRequiredError, 403: ForbiddenError, 404: NotFoundError, 419: UserUnauthorizedError, diff --git a/castle/errors.py b/castle/errors.py index 5911ea5..d2fc39a 100644 --- a/castle/errors.py +++ b/castle/errors.py @@ -55,5 +55,9 @@ class RateLimitError(APIError): pass +class PaymentRequiredError(APIError): + pass + + class InternalServerError(APIError): pass diff --git a/castle/test/core/process_response_test.py b/castle/test/core/process_response_test.py index 87f0dce..6974d02 100644 --- a/castle/test/core/process_response_test.py +++ b/castle/test/core/process_response_test.py @@ -13,6 +13,7 @@ InternalServerError, InvalidRequestTokenError, RateLimitError, + PaymentRequiredError, ) @@ -91,6 +92,10 @@ def test_verify_419(self): with self.assertRaises(UserUnauthorizedError): CoreProcessResponse(response(status_code=419)).verify() + def test_verify_402(self): + with self.assertRaises(PaymentRequiredError): + CoreProcessResponse(response(status_code=402)).verify() + def test_verify_429(self): with self.assertRaises(RateLimitError): CoreProcessResponse(response(status_code=429)).verify() diff --git a/castle/version.py b/castle/version.py index 52dac8d..76c6921 100644 --- a/castle/version.py +++ b/castle/version.py @@ -1 +1 @@ -VERSION = '7.2.0' +VERSION = '7.2.1' From 1c88b3c32017b12f0e9ddb63ddd787360d530d92 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 13:50:12 +0200 Subject: [PATCH 2/5] Pin ruff to 0.15.16. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 82867e1..6e9502d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ Changelog = "https://github.com/castle/castle-python/blob/master/CHANGELOG.rst" [project.optional-dependencies] test = ["responses>=0.23"] -lint = ["ruff>=0.6"] +lint = ["ruff==0.15.16"] [tool.setuptools.dynamic] version = { attr = "castle.version.VERSION" } From 296dcea7b8138572fe0c99cd5f860e8057f7007e Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 13:56:33 +0200 Subject: [PATCH 3/5] Bump requests, ruff, and CI while keeping Python 3.9. --- .github/workflows/lint.yml | 4 ++-- .github/workflows/specs.yml | 6 +++--- CHANGELOG.rst | 3 +++ DEVELOPMENT.rst | 2 +- pyproject.toml | 5 +++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d08f9fb..d3746f9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v7 with: python-version: '3.13' diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index ca3b64c..79a2a30 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -12,13 +12,13 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f00c222..b4ddae6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,9 @@ master ------------------ - add ``PaymentRequiredError`` for HTTP 402 responses +- raise the ``requests`` minimum to ``2.32.5`` +- pin ``ruff`` to ``0.15.22`` +- test on Python 3.9–3.14 7.2.0 (2026-06-09) ------------------ diff --git a/DEVELOPMENT.rst b/DEVELOPMENT.rst index f138658..fa2e9b2 100644 --- a/DEVELOPMENT.rst +++ b/DEVELOPMENT.rst @@ -24,7 +24,7 @@ Test $ make test -Runs ``python3 -m unittest -v castle.test``. CI runs the same suite on Python 3.9–3.13 via GitHub Actions (``.github/workflows/specs.yml``). +Runs ``python3 -m unittest -v castle.test``. CI runs the same suite on Python 3.9–3.14 via GitHub Actions (``.github/workflows/specs.yml``). Linting ------- diff --git a/pyproject.toml b/pyproject.toml index 6e9502d..266fd2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ authors = [ requires-python = ">=3.9" dynamic = ["version"] dependencies = [ - "requests>=2.31", + "requests>=2.32.5", ] classifiers = [ "Environment :: Web Environment", @@ -27,6 +27,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] [project.urls] @@ -36,7 +37,7 @@ Changelog = "https://github.com/castle/castle-python/blob/master/CHANGELOG.rst" [project.optional-dependencies] test = ["responses>=0.23"] -lint = ["ruff==0.15.16"] +lint = ["ruff==0.15.22"] [tool.setuptools.dynamic] version = { attr = "castle.version.VERSION" } From 20602e941ad1a42d7b4447329e6562126bbdd68b Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 13:59:36 +0200 Subject: [PATCH 4/5] Match example-app CI: checkout@v5 and setup-python@v6. --- .github/workflows/lint.yml | 5 +++-- .github/workflows/specs.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d3746f9..e22c0f4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,12 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v7 + uses: actions/setup-python@v6 with: python-version: '3.13' + cache: pip - name: Install ruff run: | diff --git a/.github/workflows/specs.yml b/.github/workflows/specs.yml index 79a2a30..cd07851 100644 --- a/.github/workflows/specs.yml +++ b/.github/workflows/specs.yml @@ -15,12 +15,13 @@ jobs: python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v7 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + cache: pip - name: Install dependencies run: | From 9b950df8c6d33827d6d591cff650fbb389d2601f Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 7 Sep 2026 15:43:45 +0200 Subject: [PATCH 5/5] Release 7.3.0 Bump the PaymentRequiredError release from 7.2.1 to 7.3.0. --- CHANGELOG.rst | 2 +- castle/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b4ddae6..9d24834 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ master ------ -7.2.1 (2026-09-07) +7.3.0 (2026-09-07) ------------------ - add ``PaymentRequiredError`` for HTTP 402 responses diff --git a/castle/version.py b/castle/version.py index 76c6921..8d0dc2c 100644 --- a/castle/version.py +++ b/castle/version.py @@ -1 +1 @@ -VERSION = '7.2.1' +VERSION = '7.3.0'