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

Use Iterable instead Iterator on iterate_in_threadpool #2362

Merged
merged 7 commits into from
Dec 20, 2023
Merged

Use Iterable instead Iterator on iterate_in_threadpool #2362

merged 7 commits into from
Dec 20, 2023

Conversation

jamesbraza
Copy link
Contributor

@jamesbraza jamesbraza commented Dec 6, 2023

Summary

Having AsyncContentStream match typing of SyncContentStream, they should both be Iterator or Iterable, not separate.

Given iterate_in_threadpool is typed with Iterator, and returns an AsyncIterator, I think then AsyncContentStream should be an Iterator as well

From mypy inferred types in test_streaming_response_custom_iterable, it seems AsyncIterable is required. So, this PR standardizes on Iterable/AsyncIterable

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@jamesbraza jamesbraza changed the title Fixed AsyncContentStream typing to be AsyncIterator Fixed AsyncContentStream typing to be AsyncIterable Dec 7, 2023
@jamesbraza
Copy link
Contributor Author

Cc @tomchristie if you got time to take a look at this one, it's another bug I encountered recently

starlette/concurrency.py Outdated Show resolved Hide resolved
@tomchristie
Copy link
Member

@jamesbraza you probably want to check in with other encode maintainers for this project. (I'm focused on httpx, httpcore at the moment.)

starlette/concurrency.py Outdated Show resolved Hide resolved
starlette/concurrency.py Outdated Show resolved Hide resolved
starlette/concurrency.py Outdated Show resolved Hide resolved
@Kludex Kludex changed the title Fixed AsyncContentStream typing to be AsyncIterable Use Iterable instead Iterator on iterate_in_threadpool Dec 20, 2023
@Kludex Kludex merged commit 966f0fc into encode:master Dec 20, 2023
5 checks passed
@jamesbraza jamesbraza deleted the fixing-async-content-stream-typing branch December 20, 2023 22:16
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

Successfully merging this pull request may close these issues.

None yet

3 participants