Skip to content

Commit 13ee1b0

Browse files
authored
Remove incorrect str possibility from HostnameResolver.getaddrinfo (#2964)
`_socket.getaddrinfo` takes care of encoding all passed in `str` host arguments before passing it to a custom resolver. Additionally, the docs say that a resolver will always receive IDNA-encoded bytes. However, the type hints of `HostnameResolver.getaddrinfo` imply that a resolver may need to contend with a `str` Remove the extraneous appearance
1 parent accaae4 commit 13ee1b0

5 files changed

+5
-5
lines changed

src/trio/_abc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class HostnameResolver(metaclass=ABCMeta):
168168
@abstractmethod
169169
async def getaddrinfo(
170170
self,
171-
host: bytes | str | None,
171+
host: bytes | None,
172172
port: bytes | str | int | None,
173173
family: int = 0,
174174
type: int = 0,

src/trio/_tests/test_highlevel_open_tcp_listeners.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class FakeHostnameResolver(HostnameResolver):
231231

232232
async def getaddrinfo(
233233
self,
234-
host: bytes | str | None,
234+
host: bytes | None,
235235
port: bytes | str | int | None,
236236
family: int = 0,
237237
type: int = 0,

src/trio/_tests/test_highlevel_open_tcp_stream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def _ip_to_gai_entry(self, ip: str) -> tuple[
294294

295295
async def getaddrinfo(
296296
self,
297-
host: str | bytes | None,
297+
host: bytes | None,
298298
port: bytes | str | int | None,
299299
family: int = -1,
300300
type: int = -1,

src/trio/_tests/test_highlevel_ssl_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class FakeHostnameResolver(trio.abc.HostnameResolver):
4949

5050
async def getaddrinfo(
5151
self,
52-
host: bytes | str | None,
52+
host: bytes | None,
5353
port: bytes | str | int | None,
5454
family: int = 0,
5555
type: int = 0,

src/trio/testing/_fake_net.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class FakeHostnameResolver(trio.abc.HostnameResolver):
138138

139139
async def getaddrinfo(
140140
self,
141-
host: bytes | str | None,
141+
host: bytes | None,
142142
port: bytes | str | int | None,
143143
family: int = 0,
144144
type: int = 0,

0 commit comments

Comments
 (0)