From: Daniel Hahler Date: Sat, 13 Jul 2019 16:16:53 +0000 (+0200) Subject: Move assignments to help mypy X-Git-Tag: 0.12.3~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F576%2Fhead;p=thirdparty%2Fstarlette.git Move assignments to help mypy Fixes: > error: No binding for nonlocal 'request_complete' found mypy 0.720 --- 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: