Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop old Mypy ignores #8365

Merged
merged 7 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ warn_return_any = True
#warn_unreachable = True
warn_unused_ignores = True

[mypy-aiodns]
ignore_missing_imports = True

[mypy-asynctest]
ignore_missing_imports = True

[mypy-brotli]
ignore_missing_imports = True

Expand All @@ -40,6 +34,3 @@ ignore_missing_imports = True

[mypy-gunicorn.*]
ignore_missing_imports = True

[mypy-python_on_whales]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion aiohttp/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class AbstractResolver(ABC):

@abstractmethod
async def resolve(
self, host: str, port: int = 0, family: int = socket.AF_INET
self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
) -> List[ResolveResult]:
"""Return IP address for given hostname"""

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def __init__(
*,
use_dns_cache: bool = True,
ttl_dns_cache: Optional[int] = 10,
family: int = 0,
family: socket.AddressFamily = socket.AddressFamily.AF_UNSPEC,
ssl: Union[bool, Fingerprint, SSLContext] = True,
local_addr: Optional[Tuple[str, int]] = None,
resolver: Optional[AbstractResolver] = None,
Expand Down
9 changes: 4 additions & 5 deletions aiohttp/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# aiodns_default = hasattr(aiodns.DNSResolver, 'getaddrinfo')
except ImportError: # pragma: no cover
aiodns = None
aiodns = None # type: ignore[assignment]


aiodns_default = False
Expand All @@ -32,7 +32,7 @@ def __init__(self) -> None:
self._loop = asyncio.get_running_loop()

async def resolve(
self, host: str, port: int = 0, family: int = socket.AF_INET
self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
) -> List[ResolveResult]:
infos = await self._loop.getaddrinfo(
host,
Expand Down Expand Up @@ -86,11 +86,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
if aiodns is None:
raise RuntimeError("Resolver requires aiodns library")

self._loop = asyncio.get_running_loop()
self._resolver = aiodns.DNSResolver(*args, loop=self._loop, **kwargs)
self._resolver = aiodns.DNSResolver(*args, **kwargs)

async def resolve(
self, host: str, port: int = 0, family: int = socket.AF_INET
self, host: str, port: int = 0, family: socket.AddressFamily = socket.AF_INET
) -> List[ResolveResult]:
try:
resp = await self._resolver.getaddrinfo(
Expand Down
4 changes: 2 additions & 2 deletions examples/fake_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pathlib
import socket
import ssl
from typing import Dict, List, Union
from typing import Dict, List

from aiohttp import ClientSession, TCPConnector, test_utils, web
from aiohttp.abc import AbstractResolver, ResolveResult
Expand All @@ -22,7 +22,7 @@ async def resolve(
self,
host: str,
port: int = 0,
family: Union[socket.AddressFamily, int] = socket.AF_INET,
family: socket.AddressFamily = socket.AF_INET,
) -> List[ResolveResult]:
fake_port = self._fakes.get(host)
if fake_port is not None:
Expand Down
2 changes: 2 additions & 0 deletions requirements/lint.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
aiodns
Dreamsorcerer marked this conversation as resolved.
Show resolved Hide resolved
aioredis
mypy; implementation_name == "cpython"
pre-commit
pytest
python-on-whales
slotscheck
uvloop; platform_system != "Windows"
9 changes: 1 addition & 8 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

getaddrinfo: Any = hasattr(aiodns.DNSResolver, "getaddrinfo")
except ImportError:
aiodns = None
aiodns = None # type: ignore[assignment]
getaddrinfo = False


Expand Down Expand Up @@ -289,13 +289,6 @@ async def test_default_loop_for_threaded_resolver(loop: Any) -> None:
assert resolver._loop is loop


@pytest.mark.skipif(aiodns is None, reason="aiodns required")
async def test_default_loop_for_async_resolver(loop: Any) -> None:
Dreamsorcerer marked this conversation as resolved.
Show resolved Hide resolved
asyncio.set_event_loop(loop)
resolver = AsyncResolver()
assert resolver._loop is loop


@pytest.mark.skipif(not getaddrinfo, reason="aiodns >=3.2.0 required")
async def test_async_resolver_ipv6_positive_lookup(loop: Any) -> None:
with patch("aiodns.DNSResolver") as mock:
Expand Down
Loading