refactor: replace requests with httpx#38
Conversation
4dcf7f1 to
43a7735
Compare
Greptile SummaryReplaces
Confidence Score: 5/5Safe to merge; all production HTTP call sites are correctly migrated and the previously flagged redirect and timeout gaps have been addressed. Every source file change is a clean mechanical substitution with follow_redirects=True and appropriate timeouts. The only gaps are three missing follow_redirects=True flags in test helpers and a clarification question about the removed GET JSON body — neither affects production behaviour. tests/signatures/test_adapter_image.py (missing follow_redirects in three httpx.get calls) and dspy/clients/databricks.py (removed JSON body from GET request) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[HTTP call site] --> B{follow_redirects=True?}
B -->|YES - all prod files| C[httpx follows 3xx chain]
B -->|NO - 3 test helpers| D[httpx stops at first 3xx]
C --> E[raise_for_status and json operate on final response]
D --> F[raise_for_status passes - 3xx is not an error]
F --> G[content and headers come from redirect body not target]
style D fill:#ffe0b2
style G fill:#ffcccc
Reviews (4): Last reviewed commit: "refactor: replace requests with httpx" | Re-trigger Greptile |
65b1379 to
589fbbb
Compare
httpx is already a transitive dependency via openai and litellm. This
replaces all 7 source files and 1 test file that used requests with
httpx equivalents:
- Simple GET/POST/PUT calls: 1:1 swap
- Streaming download (utils/__init__.py): requests.get(stream=True) +
iter_content -> httpx.stream('GET') + iter_bytes
- allow_redirects=True -> follow_redirects=True
- requests.exceptions.RequestException -> httpx.HTTPError
- Removed json body from a GET request in databricks.py (no-op)
Removes requests, urllib3, and charset-normalizer from the dep tree.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
589fbbb to
48c489d
Compare
Summary
Replace
requestswithhttpxacross all 7 source files and 1 test file. httpx is already a transitive dependency via openai and litellm, so this adds no new packages while removingrequests,urllib3, andcharset-normalizerfrom the dependency tree.Changes
dspy/dsp/colbertv2.pyrequests.get/post->httpx.get/postdspy/utils/__init__.pyrequests.get(stream=True)+iter_content->httpx.stream('GET')+iter_bytes,allow_redirects->follow_redirectsdspy/adapters/types/image.pyrequests.get->httpx.getdspy/adapters/types/audio.pyrequests.get->httpx.getdspy/retrievers/databricks_rm.pyrequests.post->httpx.postdspy/clients/databricks.pyrequests.get/put/post->httpx.get/put/post, removed no-op json body from GET requestdspy/clients/lm_local.pyrequests.get->httpx.get,requests.exceptions.RequestException->httpx.HTTPErrorpyproject.tomlrequests>=2.31.0->httpx>=0.23.0Notes
httpx>=0.23.0matches openai's own lower bound