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) #8383

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
disallow_untyped_calls = False
disallow_untyped_defs = False

[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 @@ -148,7 +148,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 @@ -766,7 +766,7 @@ def __init__(
fingerprint: Optional[bytes] = None,
use_dns_cache: bool = True,
ttl_dns_cache: Optional[int] = 10,
family: int = 0,
family: socket.AddressFamily = socket.AddressFamily.AF_UNSPEC,
ssl_context: Optional[SSLContext] = None,
ssl: Union[bool, Fingerprint, SSLContext] = True,
local_addr: Optional[Tuple[str, int]] = None,
Expand Down
9 changes: 4 additions & 5 deletions aiohttp/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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


aiodns_default = False
Expand All @@ -33,7 +33,7 @@ def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
self._loop = get_running_loop(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 @@ -92,15 +92,14 @@ def __init__(
if aiodns is None:
raise RuntimeError("Resolver requires aiodns library")

self._loop = get_running_loop(loop)
self._resolver = aiodns.DNSResolver(*args, loop=loop, **kwargs)
self._resolver = aiodns.DNSResolver(*args, **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
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 List, Union
from typing import List

import aiohttp
from aiohttp import web
Expand All @@ -24,7 +24,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
aioredis
mypy; implementation_name == "cpython"
pre-commit
pytest
python-on-whales
slotscheck
uvloop; platform_system != "Windows"
48 changes: 47 additions & 1 deletion requirements/lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@
#
# pip-compile --allow-unsafe --output-file=requirements/lint.txt --resolver=backtracking --strip-extras requirements/lint.in
#
aiodns==3.2.0
# via -r requirements/lint.in
aioredis==2.0.1
# via -r requirements/lint.in
annotated-types==0.6.0
# via pydantic
async-timeout==4.0.3
# via aioredis
certifi==2024.2.2
# via requests
cffi==1.16.0
# via pycares
cfgv==3.3.1
# via pre-commit
charset-normalizer==3.3.2
# via requests
click==8.1.6
# via slotscheck
# via
# slotscheck
# typer
distlib==0.3.7
# via virtualenv
exceptiongroup==1.1.2
Expand All @@ -20,8 +32,14 @@ filelock==3.12.2
# via virtualenv
identify==2.5.26
# via pre-commit
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.10.0 ; implementation_name == "cpython"
# via -r requirements/lint.in
mypy-extensions==1.0.0
Expand All @@ -36,21 +54,49 @@ pluggy==1.4.0
# via pytest
pre-commit==3.5.0
# via -r requirements/lint.in
pycares==4.4.0
# via aiodns
pycparser==2.22
# via cffi
pydantic==2.7.1
# via python-on-whales
pydantic-core==2.18.2
# via pydantic
pygments==2.17.2
# via rich
pytest==8.1.1
# via -r requirements/lint.in
python-on-whales==0.70.1
# via -r requirements/lint.in
pyyaml==6.0.1
# via pre-commit
requests==2.31.0
# via python-on-whales
rich==13.7.1
# via typer
shellingham==1.5.4
# via typer
slotscheck==0.19.0
# via -r requirements/lint.in
tomli==2.0.1
# via
# mypy
# pytest
# slotscheck
tqdm==4.66.2
# via python-on-whales
typer==0.12.3
# via python-on-whales
typing-extensions==4.11.0
# via
# aioredis
# mypy
# pydantic
# pydantic-core
# python-on-whales
# typer
urllib3==2.2.1
# via requests
uvloop==0.19.0 ; platform_system != "Windows"
# via -r requirements/lint.in
virtualenv==20.24.2
Expand Down
3 changes: 2 additions & 1 deletion tests/autobahn/test_autobahn.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def test_client(report_dir: Path, request: Any) -> None:
print("Stopping client and server")
client.terminate()
client.wait()
autobahn_container.stop()
# https://github.com/gabrieldemarmiesse/python-on-whales/pull/580
autobahn_container.stop() # type: ignore[union-attr]

failed_messages = get_failed_tests(f"{report_dir}/clients", "aiohttp")

Expand Down
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 @@ -295,13 +295,6 @@ async def test_default_loop_for_threaded_resolver(loop) -> None:
assert resolver._loop is loop


@pytest.mark.skipif(aiodns is None, reason="aiodns required")
async def test_default_loop_for_async_resolver(loop) -> None:
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