Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82e150a

Browse files
authored
Keep tests working w/ upcoming aiohttp 4.0.0 (psf#2974)
aiohttp.test_utils.unittest_run_loop was deprecated since aiohttp 3.8 and aiohttp 4 (which isn't a thing quite yet) removes it. To maintain compatibility with the full range of versions we declare to support, test_blackd.py will now define a no-op replacement if it can't be imported. Also, mypy is painfully slow to use without a cache, let's reenable it.
1 parent 2d62a09 commit 82e150a

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ warn_unreachable=True
3232
disallow_untyped_defs=True
3333
check_untyped_defs=True
3434

35-
# No incremental mode
36-
cache_dir=/dev/null
37-
3835
[mypy-black]
3936
# The following is because of `patch_click()`. Remove when
4037
# we drop Python 3.6 support.

tests/test_blackd.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from typing import Any
23
from unittest.mock import patch
34

45
from click.testing import CliRunner
@@ -8,12 +9,18 @@
89

910
try:
1011
import blackd
11-
from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop
12+
from aiohttp.test_utils import AioHTTPTestCase
1213
from aiohttp import web
14+
except ImportError as e:
15+
raise RuntimeError("Please install Black with the 'd' extra") from e
16+
17+
try:
18+
from aiohttp.test_utils import unittest_run_loop
1319
except ImportError:
14-
has_blackd_deps = False
15-
else:
16-
has_blackd_deps = True
20+
# unittest_run_loop is unnecessary and a no-op since aiohttp 3.8, and aiohttp 4
21+
# removed it. To maintain compatibility we can make our own no-op decorator.
22+
def unittest_run_loop(func: Any, *args: Any, **kwargs: Any) -> Any:
23+
return func
1724

1825

1926
@pytest.mark.blackd

0 commit comments

Comments
 (0)