From 356e7853a441518dd4153003f635f9ef14c0d9a4 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 13 Jul 2019 18:16:53 +0200 Subject: [PATCH] Move assignments to help mypy Fixes: > error: No binding for nonlocal 'request_complete' found mypy 0.720 --- starlette/testclient.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/starlette/testclient.py b/starlette/testclient.py index 7679207a..e1787a77 100644 --- a/starlette/testclient.py +++ b/starlette/testclient.py @@ -154,6 +154,13 @@ class _ASGIAdapter(requests.adapters.HTTPAdapter): "extensions": {"http.response.template": {}}, } + request_complete = False + response_started = False + response_complete = False + raw_kwargs = {"body": io.BytesIO()} # type: typing.Dict[str, typing.Any] + template = None + context = None + async def receive() -> Message: nonlocal request_complete, response_complete @@ -218,13 +225,6 @@ class _ASGIAdapter(requests.adapters.HTTPAdapter): template = message["template"] context = message["context"] - request_complete = False - response_started = False - response_complete = False - raw_kwargs = {"body": io.BytesIO()} # type: typing.Dict[str, typing.Any] - template = None - context = None - try: loop = asyncio.get_event_loop() except RuntimeError: