From ff7bf6a36c0b81efa2a669cc589f1ba046b422bf Mon Sep 17 00:00:00 2001 From: Stefan T <66305+stj@users.noreply.github.com> Date: Wed, 2 Oct 2019 11:57:50 -0700 Subject: [PATCH] [3.6] Use Iterable hint instead of Sequence (#4125) Given that the `FrozenList` type hint is `Union[List[_T], Iterable[_T]]` the Application middleware type should not restrict to `Sequence` and support all `Iterable` types.. (cherry picked from commit 847539567a13e78c9df892b218fdd4e530f0a44c) Co-authored-by: Stefan T <66305+stj@users.noreply.github.com> --- CHANGES/4125.feature | 1 + CONTRIBUTORS.txt | 1 + aiohttp/web_app.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 CHANGES/4125.feature diff --git a/CHANGES/4125.feature b/CHANGES/4125.feature new file mode 100644 index 00000000000..43dd2638b4f --- /dev/null +++ b/CHANGES/4125.feature @@ -0,0 +1 @@ +Use `Iterable` hint instead of `Sequence` for `Application` `middleware` parameter. diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 8a3bf7754b2..5c63704704e 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -216,6 +216,7 @@ Simon Kennedy Sin-Woo Bang Stanislas Plum Stanislav Prokop +Stefan Tjarks Stepan Pletnev Stephen Granade Steven Seguin diff --git a/aiohttp/web_app.py b/aiohttp/web_app.py index afe53f5e1e4..dd82ab3942d 100644 --- a/aiohttp/web_app.py +++ b/aiohttp/web_app.py @@ -88,7 +88,7 @@ class Application(MutableMapping[str, Any]): def __init__(self, *, logger: logging.Logger=web_logger, router: Optional[UrlDispatcher]=None, - middlewares: Sequence[_Middleware]=(), + middlewares: Iterable[_Middleware]=(), handler_args: Mapping[str, Any]=None, client_max_size: int=1024**2, loop: Optional[asyncio.AbstractEventLoop]=None,