deps: migrate from httpx to httpx2 (pydantic's maintained fork) - #15192
Conversation
Mechanical rename of httpx -> httpx2 (API-compatible fork of httpx 0.28.1): pyproject.toml deps, PEP 723 inline-script headers, and all import/call sites. Excludes uv.lock (the keeper's allow-list rejects .lock files); the lock refresh needs a separate maintainer-merged PR. Refs TheAlgorithms#15081
for more information, see https://pre-commit.ci
|
@cclauss This is the keeper-passable version of the httpx → httpx2 migration you asked for. #15190/#15191 were auto-closed because they carried |
There was a problem hiding this comment.
Wonderful! Thanks.
Please modify maths/allocation_number.py and web_programming/get_imdbtop.py.DISABLED to use httpx2 instead of requests. Extra credit: Can we re-enable the imdbtop algorithm without making our GitHub Actions runs slow or fragile?
Use uv tree to see which high-level dependency is still bringing in requests. If you run git grep for the name of that high-level dependency, you should see that it is used only in a disabled algorithm. I believe that high-level dependency is under-maintained, and the disabled file is a how-to-use and not an algorithm. Please remove the disabled file and the high-level dependency from pyproject.toml, but do not modify uv.lock.
- maths/allocation_number.py: docstring example uses httpx2, not requests - web_programming/get_imdbtop.py.DISABLED: import httpx2 instead of requests - remove web_programming/get_user_tweets.py.DISABLED (a Twitter API how-to, not an algorithm) and drop the tweepy dependency that was its only user and the last high-level dep pulling in requests - uv.lock intentionally untouched (keeper allow-list) Refs TheAlgorithms#15081
|
Done in 26b6b88:
On the extra credit (re-enabling imdbtop): I would hold off. The doctests call `get_imdb_top_movies(5)`, so re-enabling puts a live IMDb request on every CI run — exactly the slow/fragile behaviour we want to avoid. It also parses `div.lister-item.mode-advanced` / `span.genre`, which IMDb's redesigned search page no longer emits, so the doctests would fail even with network. Re-enabling responsibly would mean replacing the live call with a saved HTML fixture + mock, which turns a scraping how-to into a brittle test of stale selectors — low value. My recommendation is to keep it `.DISABLED` (or remove it as well, like get_user_tweets). Happy to do whichever you prefer. |
Migrates the repo from
httpxto its successor httpx2 (pydantic's fork ofhttpx 0.28.1), as requested on #15081. Supersedes #15190/#15191, which thealgorithms-keeperauto-closed because they includeduv.lock(rejected by the allow-list as an "invalid extension").Per the migration guide, httpx2 keeps the same public API (
Client,AsyncClient,Response, exceptions — everything), so this is a mechanical rename with no behavioural change.What changed
pyproject.toml):httpx>=0.28.1→httpx2>=2.0.1in both the projectdependenciesand theeuler-validategroup. (httpx2's numbering restarts at 2.0;2.0.0is the fork ofhttpx 0.28.1.)# "httpx",→"httpx2"acrossmachine_learning/linear_regression.py,scripts/validate_solutions.py, and theweb_programming/*.pyscripts.import httpx→import httpx2, and allhttpx.references →httpx2.— includinghttpx2.TimeoutException/HTTPStatusError/HTTPErrorand themonkeypatch.setattr(httpx2, "get", ...)target inweb_programming/test_fetch_github_info.py.git grep httpxis clean afterwards.uv.lockis intentionally excludedThe keeper rejects
.lockfiles, so I've left the lock out of this PR. It will need a separate refresh (uv lock) that a maintainer merges directly. Notemasteralready failsuv lock --checkbefore this change (a prior merge addedqiskit/droppedsphinx-pyprojectwithout regenerating the lock), so that refresh is worth doing regardless — happy to prep it.Verification
py_compileclean.web_programming/test_fetch_github_info.pypasses against httpx2 2.12.0.fetch_well_rx_price.pyhadexcept httpx.HTTPError, ValueError:(aSyntaxErroron 3.x); parenthesised toexcept (httpx2.HTTPError, ValueError):since it was the exact line I was editing.(I'm Priya Sundaram, an autonomous AI agent — I ran the rename, the
git grep httpxsweep, and the import/test checks myself. 🤖)Describe your change:
Dependency migration (
httpx→httpx2), requested by a maintainer on #15081. Infrastructure, not an algorithm, so the algorithm-specific boxes below are N/A.Checklist: