Repository: aio-libs/aiohttp

Issue:
Drop aiodns < 1.1
aiodns 1.1.1 was released on Oct 14, 2016
Let's drop aiodns 1.0 in aiohttp 4.0


Discussion:

Resolving patch:
diff --git a/aiohttp/resolver.py b/aiohttp/resolver.py
--- a/aiohttp/resolver.py
+++ b/aiohttp/resolver.py
@@ -52,10 +52,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
         self._loop = get_running_loop()
         self._resolver = aiodns.DNSResolver(*args, loop=self._loop, **kwargs)
 
-        if not hasattr(self._resolver, 'gethostbyname'):
-            # aiodns 1.1 is not available, fallback to DNSResolver.query
-            self.resolve = self._resolve_with_query  # type: ignore
-
     async def resolve(self, host: str, port: int=0,
                       family: int=socket.AF_INET) -> List[Dict[str, Any]]:
         try:
@@ -76,33 +72,6 @@ async def resolve(self, host: str, port: int=0,
 
         return hosts
 
-    async def _resolve_with_query(
-            self, host: str, port: int=0,
-            family: int=socket.AF_INET) -> List[Dict[str, Any]]:
-        if family == socket.AF_INET6:
-            qtype = 'AAAA'
-        else:
-            qtype = 'A'
-
-        try:
-            resp = await self._resolver.query(host, qtype)
-        except aiodns.error.DNSError as exc:
-            msg = exc.args[1] if len(exc.args) >= 1 else "DNS lookup failed"
-            raise OSError(msg) from exc
-
-        hosts = []
-        for rr in resp:
-            hosts.append(
-                {'hostname': host,
-                 'host': rr.host, 'port': port,
-                 'family': family, 'proto': 0,
-                 'flags': socket.AI_NUMERICHOST})
-
-        if not hosts:
-            raise OSError("DNS lookup failed")
-
-        return hosts
-
     async def close(self) -> None:
         return self._resolver.cancel()
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -134,7 +134,7 @@ def read(f):
     install_requires=install_requires,
     extras_require={
         'speedups': [
-            'aiodns',
+            'aiodns>=1.1',
             'Brotli',
             'cchardet',
         ],


Test patch:
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -56,17 +56,6 @@ async def test_async_resolver_positive_lookup(loop) -> None:
                                                 socket.AF_INET)
 
 
-@pytest.mark.skipif(aiodns is None, reason="aiodns required")
-async def test_async_resolver_query_positive_lookup(loop) -> None:
-    with patch('aiodns.DNSResolver') as mock:
-        del mock().gethostbyname
-        mock().query.return_value = fake_query_result(['127.0.0.1'])
-        resolver = AsyncResolver()
-        real = await resolver.resolve('www.python.org')
-        ipaddress.ip_address(real[0]['host'])
-        mock().query.assert_called_with('www.python.org', 'A')
-
-
 @pytest.mark.skipif(not gethostbyname, reason="aiodns 1.1 required")
 async def test_async_resolver_multiple_replies(loop) -> None:
     with patch('aiodns.DNSResolver') as mock:
@@ -78,17 +67,6 @@ async def test_async_resolver_multiple_replies(loop) -> None:
         assert len(ips) > 3, "Expecting multiple addresses"
 
 
-@pytest.mark.skipif(aiodns is None, reason="aiodns required")
-async def test_async_resolver_query_multiple_replies(loop) -> None:
-    with patch('aiodns.DNSResolver') as mock:
-        del mock().gethostbyname
-        ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
-        mock().query.return_value = fake_query_result(ips)
-        resolver = AsyncResolver()
-        real = await resolver.resolve('www.google.com')
-        ips = [ipaddress.ip_address(x['host']) for x in real]
-
-
 @pytest.mark.skipif(not gethostbyname, reason="aiodns 1.1 required")
 async def test_async_resolver_negative_lookup(loop) -> None:
     with patch('aiodns.DNSResolver') as mock:
@@ -98,26 +76,6 @@ async def test_async_resolver_negative_lookup(loop) -> None:
             await resolver.resolve('doesnotexist.bla')
 
 
-@pytest.mark.skipif(aiodns is None, reason="aiodns required")
-async def test_async_resolver_query_negative_lookup(loop) -> None:
-    with patch('aiodns.DNSResolver') as mock:
-        del mock().gethostbyname
-        mock().query.side_effect = aiodns.error.DNSError()
-        resolver = AsyncResolver()
-        with pytest.raises(OSError):
-            await resolver.resolve('doesnotexist.bla')
-
-
-@pytest.mark.skipif(aiodns is None, reason="aiodns required")
-async def test_async_resolver_no_hosts_in_query(loop) -> None:
-    with patch('aiodns.DNSResolver') as mock:
-        del mock().gethostbyname
-        mock().query.return_value = fake_query_result([])
-        resolver = AsyncResolver()
-        with pytest.raises(OSError):
-            await resolver.resolve('doesnotexist.bla')
-
-
 @pytest.mark.skipif(not gethostbyname, reason="aiodns 1.1 required")
 async def test_async_resolver_no_hosts_in_gethostbyname(loop) -> None:
     with patch('aiodns.DNSResolver') as mock:
@@ -193,18 +151,6 @@ async def test_async_resolver_ipv6_positive_lookup(loop) -> None:
                                                 socket.AF_INET6)
 
 
-@pytest.mark.skipif(aiodns is None, reason="aiodns required")
-async def test_async_resolver_query_ipv6_positive_lookup(loop) -> None:
-    with patch('aiodns.DNSResolver') as mock:
-        del mock().gethostbyname
-        mock().query.return_value = fake_query_result(['::1'])
-        resolver = AsyncResolver()
-        real = await resolver.resolve('www.python.org',
-                                      family=socket.AF_INET6)
-        ipaddress.ip_address(real[0]['host'])
-        mock().query.assert_called_with('www.python.org', 'AAAA')
-
-
 async def test_async_resolver_aiodns_not_present(loop, monkeypatch) -> None:
     monkeypatch.setattr("aiohttp.resolver.aiodns", None)
     with pytest.raises(RuntimeError):