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

0.65 TypeError: AsyncClient.__init__() got an unexpected keyword argument 'app' #2443

Closed
simonw opened this issue Nov 29, 2024 · 3 comments
Closed
Labels

Comments

@simonw
Copy link
Owner

simonw commented Nov 29, 2024

Just stared seeing this error today after the release of httpx 0.28.0:

File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/datasette/app.py", line 1601, in request
    async with httpx.AsyncClient(app=self.app) as client:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncClient.__init__() got an unexpected keyword argument 'app'
@simonw simonw added the bug label Nov 29, 2024
@simonw
Copy link
Owner Author

simonw commented Nov 29, 2024

I fixed this code in main but I never backported the fix to the 0.65 release line. Here's the code at fault:

datasette/datasette/app.py

Lines 1571 to 1573 in 753ddc9

async def get(self, path, **kwargs):
async with httpx.AsyncClient(app=self.app) as client:
return await client.get(self._fix(path), **kwargs)

In main it now looks like this:

datasette/datasette/app.py

Lines 2015 to 2020 in e85517d

async def _request(self, method, path, **kwargs):
async with httpx.AsyncClient(
transport=httpx.ASGITransport(app=self.app),
cookies=kwargs.pop("cookies", None),
) as client:
return await getattr(client, method)(self._fix(path), **kwargs)

@simonw
Copy link
Owner Author

simonw commented Nov 29, 2024

I don't think depending on httpx>=0.28.0 is strictly necessary here - in fact it could break things for people who depend on Datasette stable but also have some other dependency which isn't yet ready for the breaking changes in httpx.

(Also the tests just failed because my Pyodide test currently pins to 0.23.0)

simonw added a commit that referenced this issue Nov 29, 2024
simonw added a commit that referenced this issue Nov 29, 2024
simonw added a commit that referenced this issue Nov 29, 2024
@simonw
Copy link
Owner Author

simonw commented Nov 29, 2024

Released in 0.65.1.

@simonw simonw closed this as completed Nov 29, 2024
simonw added a commit to simonw/til that referenced this issue Nov 29, 2024
To ensure fix for the HTTPX problem:

- simonw/datasette#2443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant