Skip to content

Fix nonexistent iter_content() reference in stream() docstring#1096

Open
cognis-digital wants to merge 1 commit into
encode:masterfrom
cognis-digital:fix/stream-docstring-iter-content
Open

Fix nonexistent iter_content() reference in stream() docstring#1096
cognis-digital wants to merge 1 commit into
encode:masterfrom
cognis-digital:fix/stream-docstring-iter-content

Conversation

@cognis-digital

Copy link
Copy Markdown

The docstring for the public httpcore.stream() function tells users how to
read a streamed response body:

If you want to access the response body you should either use
content = response.read(), or for chunk in response.iter_content().

But Response has no iter_content() method — the streaming iterator is
iter_stream() (and aiter_stream() for async). Running the documented
for chunk in response.iter_content() raises AttributeError.

The rest of the project already uses the correct name (docs/quickstart.md
documents for chunk in response.iter_stream():, and the tests use
response.iter_stream()). This one docstring drifted because doctests are
not run in CI.

This corrects the docstring to iter_stream() and adds a small regression
test pinning the documented streaming method names, so the documented API
can't silently drift to a nonexistent method again.

No library behaviour changes — docs-only correctness plus a guard test.

The docstring for httpcore.stream() tells users to read a streamed body
with "for chunk in response.iter_content()", but Response has no
iter_content() method -- the streaming method is iter_stream(). Running
the documented snippet raises AttributeError. Correct it to iter_stream()
and add a regression test pinning the documented streaming method names,
since doctests are not run in CI.
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.

1 participant