Skip to content

Make stream_writer optional in ClientResponse.__init__#13051

Open
muhamedfazalps wants to merge 2 commits into
aio-libs:masterfrom
muhamedfazalps:fix/make-stream-writer-optional
Open

Make stream_writer optional in ClientResponse.__init__#13051
muhamedfazalps wants to merge 2 commits into
aio-libs:masterfrom
muhamedfazalps:fix/make-stream-writer-optional

Conversation

@muhamedfazalps

Copy link
Copy Markdown

Summary

Make the stream_writer parameter optional in ClientResponse.__init__ to preserve backward compatibility.

Fixes #12815

Motivation

The stream_writer parameter was added as a required keyword argument in aiohttp 3.14.0 (PR #12452). This broke backward compatibility with aioresponses and other libraries that create ClientResponse instances directly:

TypeError: ClientResponse.__init__() missing 1 required keyword-only argument: 'stream_writer'

This is a breaking change that should not have been introduced in a minor version bump.

Changes

  • aiohttp/client_reqrep.py: Changed stream_writer: AbstractStreamWriter to stream_writer: AbstractStreamWriter | None = None

Example

Before (broken):

resp = ClientResponse(method, url, writer=..., ...)
# TypeError: missing stream_writer

After (works):

resp = ClientResponse(method, url, writer=..., ...)
# Works — stream_writer defaults to None

Discovered during open source research. https://buymeacoffee.com/muhamedfazalps

Fixes aio-libs#12815

The stream_writer parameter was added as a required keyword argument in
aiohttp 3.14.0, breaking backward compatibility with aioresponses and
other libraries that create ClientResponse instances directly.

This change makes stream_writer optional with a default of None, so
existing code that does not pass stream_writer continues to work.
@muhamedfazalps muhamedfazalps requested a review from asvetlov as a code owner July 4, 2026 18:06
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.96%. Comparing base (e3774b4) to head (5439e8c).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #13051   +/-   ##
=======================================
  Coverage   98.96%   98.96%           
=======================================
  Files         131      131           
  Lines       48156    48156           
  Branches     2499     2499           
=======================================
  Hits        47656    47656           
  Misses        376      376           
  Partials      124      124           
Flag Coverage Δ
Autobahn 22.21% <100.00%> (ø)
CI-GHA 98.90% <100.00%> (-0.01%) ⬇️
OS-Linux 98.67% <100.00%> (+<0.01%) ⬆️
OS-Windows 97.04% <100.00%> (ø)
OS-macOS 97.94% <100.00%> (-0.01%) ⬇️
Py-3.10 98.14% <100.00%> (-0.01%) ⬇️
Py-3.11 98.41% <100.00%> (+<0.01%) ⬆️
Py-3.12 98.50% <100.00%> (ø)
Py-3.13 98.47% <100.00%> (-0.01%) ⬇️
Py-3.14 98.49% <100.00%> (-0.01%) ⬇️
Py-3.14t 97.58% <100.00%> (-0.01%) ⬇️
Py-pypy-3.11 97.45% <100.00%> (+<0.01%) ⬆️
VM-macos 97.94% <100.00%> (-0.01%) ⬇️
VM-ubuntu 98.67% <100.00%> (+<0.01%) ⬆️
VM-windows 97.04% <100.00%> (ø)
cython-coverage 38.11% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Jul 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 83 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing muhamedfazalps:fix/make-stream-writer-optional (5439e8c) with master (e3774b4)

Open in CodSpeed

Footnotes

  1. 83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

aioresponses is incompatible with aiohttp 3.14.0 - switch to aiointercept

1 participant