From ae23fd6a1645eacaf63d64c638f19310282d07b9 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 18 Jul 2021 12:45:09 +0100 Subject: [PATCH] Update to Mypy 0.910 (#5890) --- .mypy.ini | 1 + CHANGES/5890.misc | 1 + requirements/dev.txt | 4 +++- requirements/lint.in | 3 ++- requirements/lint.txt | 4 +++- requirements/test.txt | 3 ++- tests/autobahn/client/client.py | 4 ++-- tests/autobahn/server/server.py | 6 +++--- 8 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 CHANGES/5890.misc diff --git a/.mypy.ini b/.mypy.ini index b5cedf90b7c..5b5796e4a51 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -1,6 +1,7 @@ [mypy] files = aiohttp, examples, tests check_untyped_defs = True +exclude = examples/legacy/ follow_imports_for_stubs = True #disallow_any_decorated = True disallow_any_generics = True diff --git a/CHANGES/5890.misc b/CHANGES/5890.misc new file mode 100644 index 00000000000..489cfc336a7 --- /dev/null +++ b/CHANGES/5890.misc @@ -0,0 +1 @@ +Update to Mypy 0.910. diff --git a/requirements/dev.txt b/requirements/dev.txt index 71eb3643adc..26caf38a37b 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -130,7 +130,7 @@ multidict==5.1.0 # via # -r requirements/multidict.txt # yarl -mypy==0.790 ; implementation_name == "cpython" +mypy==0.910 ; implementation_name == "cpython" # via # -r requirements/lint.txt # -r requirements/test.txt @@ -265,6 +265,8 @@ typed-ast==1.4.2 # via # -r requirements/lint.txt # mypy +types-chardet==0.1.3 + # via -r requirements/lint.txt typing-extensions==3.7.4.3 # via # -r requirements/base.txt diff --git a/requirements/lint.in b/requirements/lint.in index 193229f3fa0..4e6bec024dc 100644 --- a/requirements/lint.in +++ b/requirements/lint.in @@ -2,6 +2,7 @@ black==21.6b0; implementation_name=="cpython" flake8==3.9.2 flake8-pyi==20.10.0 isort==5.9.2 -mypy==0.790; implementation_name=="cpython" +mypy==0.910; implementation_name=="cpython" pre-commit==2.13.0 pytest==6.2.2 +types-chardet==0.1.3 diff --git a/requirements/lint.txt b/requirements/lint.txt index ab2f2de0bd8..a950fef847f 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -36,7 +36,7 @@ isort==5.9.2 # via -r requirements/lint.in mccabe==0.6.1 # via flake8 -mypy==0.790 ; implementation_name == "cpython" +mypy==0.910 ; implementation_name == "cpython" # via -r requirements/lint.in mypy-extensions==0.4.3 # via @@ -77,6 +77,8 @@ toml==0.10.2 # pytest typed-ast==1.4.2 # via mypy +types-chardet==0.1.3 + # via -r requirements/lint.txt typing-extensions==3.7.4.3 # via mypy virtualenv==20.4.2 diff --git a/requirements/test.txt b/requirements/test.txt index 36707a4f45f..31bcf6a612b 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,7 +4,7 @@ Brotli==1.0.9 coverage==5.5 cryptography==3.3.1; platform_machine!="i686" and python_version<"3.9" # no 32-bit wheels; no python 3.9 wheels yet freezegun==1.1.0 -mypy==0.790; implementation_name=="cpython" +mypy==0.910; implementation_name=="cpython" mypy-extensions==0.4.3; implementation_name=="cpython" pytest==6.2.2 pytest-cov==2.12.1 @@ -12,3 +12,4 @@ pytest-mock==3.6.1 re-assert==1.1.0 setuptools-git==1.2 trustme==0.8.0; platform_machine!="i686" # no 32-bit wheels +types-chardet==0.1.3 diff --git a/tests/autobahn/client/client.py b/tests/autobahn/client/client.py index afb309aef36..107c183070e 100644 --- a/tests/autobahn/client/client.py +++ b/tests/autobahn/client/client.py @@ -5,7 +5,7 @@ import aiohttp -async def client(url, name): +async def client(url: str, name: str) -> None: async with aiohttp.ClientSession() as session: async with session.ws_connect(url + "/getCaseCount") as ws: num_tests = int((await ws.receive()).data) @@ -28,7 +28,7 @@ async def client(url, name): print("finally requesting %s" % url) -async def run(url, name): +async def run(url: str, name: str) -> None: try: await client(url, name) except Exception: diff --git a/tests/autobahn/server/server.py b/tests/autobahn/server/server.py index 684cdcce6ff..d4ca04b1d5f 100644 --- a/tests/autobahn/server/server.py +++ b/tests/autobahn/server/server.py @@ -5,11 +5,11 @@ from aiohttp import WSCloseCode, web -async def wshandler(request): +async def wshandler(request: web.Request) -> web.WebSocketResponse: ws = web.WebSocketResponse(autoclose=False) is_ws = ws.can_prepare(request) if not is_ws: - return web.HTTPBadRequest() + raise web.HTTPBadRequest() await ws.prepare(request) @@ -29,7 +29,7 @@ async def wshandler(request): return ws -async def on_shutdown(app): +async def on_shutdown(app: web.Application) -> None: for ws in set(app["websockets"]): await ws.close(code=WSCloseCode.GOING_AWAY, message="Server shutdown")