From 161bdbd07e2286dca83458d17b31d7267422e971 Mon Sep 17 00:00:00 2001 From: Namit Nathwani Date: Wed, 26 Feb 2025 18:32:51 +0530 Subject: [PATCH] update: bump `httpx`/`respx` dependencies - Pins `httpx`/respx to current major versions (<1.0.0) - Will allow users to update their dependencies without us having to keep up - Fixes broken tests due to latest `httpx` changes - Removes `respx` dependency from `fastapi` install - `fastapi` has no dependency on `respx` - We only use `respx` in tests - Bump version to `0.28.1` --- CHANGELOG.md | 4 ++++ dev-requirements.txt | 2 +- setup.py | 5 ++--- supertokens_python/constants.py | 2 +- tests/test_querier.py | 11 ++++++----- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69abf6684..4566f700a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.28.1] - 2025-02-26 +- Pins `httpx` and `respx` to current major versions (<1.0.0) +- Removes `respx` dependency from `fastapi` install + ## [0.28.0] - **[Breaking] Updates pre-commit hooks to use `pre-commit`** - Migration: diff --git a/dev-requirements.txt b/dev-requirements.txt index 1c3739f0f..bf7fd0e84 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -18,6 +18,6 @@ pytest-mock==3.14.0 pytest-rerunfailures==14.0 pyyaml==6.0.2 requests-mock==1.12.1 -respx==0.21.1 +respx>=0.13.0, <1.0.0 uvicorn==0.32.0 -e . diff --git a/setup.py b/setup.py index cfdcbd999..4180114c1 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,6 @@ # on changes in these frameworks "fastapi": ( [ - "respx==0.21.1", "fastapi", "uvicorn", "python-dotenv==1.0.1", @@ -83,7 +82,7 @@ setup( name="supertokens_python", - version="0.28.0", + version="0.28.1", author="SuperTokens", license="Apache 2.0", author_email="team@supertokens.com", @@ -116,7 +115,7 @@ # [crypto] ensures that it installs the `cryptography` library as well # based on constraints specified in https://github.com/jpadilla/pyjwt/blob/master/setup.cfg#L50 "PyJWT[crypto]>=2.5.0,<3.0.0", - "httpx>=0.15.0,<=0.27.2", + "httpx>=0.15.0,<1.0.0", "pycryptodome<3.21.0", "tldextract<5.1.3", "asgiref>=3.4.1,<4", diff --git a/supertokens_python/constants.py b/supertokens_python/constants.py index 48bf82850..804a53188 100644 --- a/supertokens_python/constants.py +++ b/supertokens_python/constants.py @@ -15,7 +15,7 @@ from __future__ import annotations SUPPORTED_CDI_VERSIONS = ["5.2"] -VERSION = "0.28.0" +VERSION = "0.28.1" TELEMETRY = "/telemetry" USER_COUNT = "/users/count" USER_DELETE = "/user/remove" diff --git a/tests/test_querier.py b/tests/test_querier.py index 9846b4a78..fef735694 100644 --- a/tests/test_querier.py +++ b/tests/test_querier.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. import asyncio -import json from typing import Any, Dict, Optional import httpx @@ -84,9 +83,7 @@ def api2_side_effect(_: httpx.Request): try: await q.send_get_request(NormalisedURLPath("/api1"), None, None) except Exception as e: - if "with status code: 429" in str( - e - ) and 'message: {"status": "RATE_ERROR"}' in str(e): + if "with status code: 429" in str(e) and '"RATE_ERROR"' in str(e): pass else: raise e @@ -186,12 +183,16 @@ async def test_querier_text_and_headers(): ) res = await q.send_get_request(NormalisedURLPath("/json-api"), None, None) + assert "content-length" in res["_headers"] + # httpx 0.28.0 seems to have changed their `json.dumps` signature in https://github.com/encode/httpx/issues/3363 + # Does not make sense to keep up to date with minor changes like this + # Dropping content-length checks to avoid flake here + res["_headers"].pop("content-length") assert res == { "bar": "baz", "_headers": { "greet": "hi", "content-type": "application/json", - "content-length": str(len(json.dumps(body))), }, }