Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider replacing httpx with requests for pyodide support #1957

Open
simontaurus opened this issue May 12, 2024 · 0 comments
Open

Consider replacing httpx with requests for pyodide support #1957

simontaurus opened this issue May 12, 2024 · 0 comments

Comments

@simontaurus
Copy link

simontaurus commented May 12, 2024

Is your feature request related to a problem? Please describe.
Even with wolverdude/GenSON#73 fixed, datamodel-code-generator still depends on httpx, which is not yet supported in pyodide (see koenvo/pyodide-http#37)

Describe the solution you'd like
Replacing httpx with requests would solve this issue.
Beside some mockup patches in the tests, this is merly about two lines:


which can be replaced with

requests.get(url, headers=headers, verify=verify, allow_redirects=follow_redirects, params=params)

and

return str(httpx.URL(url).join(ref))

which should be replaceable with

urllib.parse.urlparse

wrapped here: https://github.com/encode/httpx/blob/88a81c5d31a4a8b4bd0a860dedd3bb12dc09ff86/httpx/_urls.py#L370

see also https://github.com/search?q=repo%3Akoxudaxi%2Fdatamodel-code-generator%20httpx&type=code

Describe alternatives you've considered
As a temporary workaround, a patch is also possible:

import requests
import httpx
def patch_get(url, headers, verify, follow_redirects, params
    ):
    return requests.get(
        url, headers=headers, verify=verify, allow_redirects=follow_redirects, params=params
    )
httpx.get = patch_get

Additional context
Patch solution is used here: https://oo-ld.github.io/playground-python-yaml/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant