-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Incorrect typing on AsyncResponse.iter_content() #185
Comments
It's true, something isn't right. But it is not what you think it is. If you have a (rather clean, without breakage) solution that we can apply that makes both modern IDEs and mypy happy with, we'll proceed. async def reproducer() -> typing.AsyncGenerator[bytes, None]:
async def gen() -> typing.AsyncGenerator[bytes, None]:
yield b"foo"
yield b"bar"
return gen() So there you have to We'll need a typing expert to investigate. Regards, |
3.11.3 (2024-12-13) ------------------- **Fixed** - Static type checker getting confused around ``AsyncSession`` and attached overloads (``AsyncResponse`` or ``Response``). (#185) **Changed** - Default keepalive (HTTP/2, and HTTP/3) changed to 1 hour. In conformance with urllib3-future. **Removed** - Automatic resolution of pending lazy responses if there are too many of them. Previously, we hardcoded a limit of 128 * NUM_CONN_POOL maximum inflight (aka. unresolved/lazy) response. This was unrealistic due to a number of factors like (but not limited to): A) remote peers can choose at will the max streams. B) we can have multiple pool with multiple (varying) max capacities. C) retrieving max streams per pool per conn is a very costly procedure (in terms of performance). We will revisit this later on. You still can set ``max_in_flight_multiplexed`` in your ``HTTPAdapter`` to restore this broken behavior.
I'm experiencing the same problem with async with niquests.AsyncSession() as session:
response = await session.get(url, stream=True)
async for chunk in await response.iter_content(chunk_size=4096): This causes Pylance to generate the warning:
Could this be reopened @Ousret ? |
Could you share the exact environment you are in? IDE version, Pylance version? Does Pylance have a issue tracker? If so could you ask for their expertise on that matter? Regards, |
One must run
async for chunk in await async_response.iter_content()
(which conflicts with the type hints provided forAsyncResponse.iter_content()
) instead of the expectedasync for chunk in async_response.iter_content()
.Expected Result
Content of the HTTP response to be printed in chunks to stdout.
Actual Result
Exception:
Reproduction Steps
System Information
Workaround
The text was updated successfully, but these errors were encountered: