Skip to content

Commit a3e3371

Browse files
committed
Change ClientSession middlewares default to be an empty tuple
This will avoid one breaking change in 4.0 in when we make the other change in #10890 closes #10905
1 parent 5dcb36a commit a3e3371

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

aiohttp/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def __init__(
296296
max_line_size: int = 8190,
297297
max_field_size: int = 8190,
298298
fallback_charset_resolver: _CharsetResolver = lambda r, b: "utf-8",
299-
middlewares: Optional[Sequence[ClientMiddlewareType]] = None,
299+
middlewares: Sequence[ClientMiddlewareType] = (),
300300
) -> None:
301301
# We initialise _connector to None immediately, as it's referenced in __del__()
302302
# and could cause issues if an exception occurs during initialisation.

docs/client_reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The client session supports the context manager protocol for self closing.
5353
trust_env=False, \
5454
requote_redirect_url=True, \
5555
trace_configs=None, \
56-
middlewares=None, \
56+
middlewares=(), \
5757
read_bufsize=2**16, \
5858
max_line_size=8190, \
5959
max_field_size=8190, \
@@ -216,7 +216,7 @@ The client session supports the context manager protocol for self closing.
216216

217217
:param middlewares: A sequence of middleware instances to apply to all session requests.
218218
Each middleware must match the :type:`ClientMiddlewareType` signature.
219-
``None`` (default) is used when no middleware is needed.
219+
``()`` (empty tuple, default) is used when no middleware is needed.
220220
See :ref:`aiohttp-client-middleware` for more information.
221221

222222
.. versionadded:: 3.12

0 commit comments

Comments
 (0)