From 2d992552874b4edad1b91f71e0e979b0642740af Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 17 Jul 2021 14:21:00 +0100 Subject: [PATCH 1/2] Update to Mypy 0.910. --- .mypy.ini | 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 +++--- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.mypy.ini b/.mypy.ini index 0b241fe889a..5774c368b4a 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/requirements/dev.txt b/requirements/dev.txt index 05f4af7f9e6..433f087ec56 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -136,7 +136,7 @@ mypy-extensions==0.4.3 ; implementation_name == "cpython" # -r requirements/test.txt # black # mypy -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 435c6ae1979..bb35b9d43d2 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.0 -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 41f7a7be83e..47c77477bc0 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -40,7 +40,7 @@ mypy-extensions==0.4.3 # via # black # mypy -mypy==0.790 ; implementation_name == "cpython" +mypy==0.910 ; implementation_name == "cpython" # via -r requirements/lint.in nodeenv==1.5.0 # via pre-commit @@ -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") From bf1342112f2d01d1b4f2aa65c92057a5a843f5a4 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 17 Jul 2021 14:25:24 +0100 Subject: [PATCH 2/2] Add change file. --- CHANGES/5890.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/5890.misc 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.