Skip to content

Commit

Permalink
Remove incorrect str possibility from HostnameResolver.getaddrinfo (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
tjstum committed Feb 29, 2024
1 parent accaae4 commit 13ee1b0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/trio/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class HostnameResolver(metaclass=ABCMeta):
@abstractmethod
async def getaddrinfo(
self,
host: bytes | str | None,
host: bytes | None,
port: bytes | str | int | None,
family: int = 0,
type: int = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_highlevel_open_tcp_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class FakeHostnameResolver(HostnameResolver):

async def getaddrinfo(
self,
host: bytes | str | None,
host: bytes | None,
port: bytes | str | int | None,
family: int = 0,
type: int = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_highlevel_open_tcp_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def _ip_to_gai_entry(self, ip: str) -> tuple[

async def getaddrinfo(
self,
host: str | bytes | None,
host: bytes | None,
port: bytes | str | int | None,
family: int = -1,
type: int = -1,
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_highlevel_ssl_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FakeHostnameResolver(trio.abc.HostnameResolver):

async def getaddrinfo(
self,
host: bytes | str | None,
host: bytes | None,
port: bytes | str | int | None,
family: int = 0,
type: int = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/trio/testing/_fake_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class FakeHostnameResolver(trio.abc.HostnameResolver):

async def getaddrinfo(
self,
host: bytes | str | None,
host: bytes | None,
port: bytes | str | int | None,
family: int = 0,
type: int = 0,
Expand Down

0 comments on commit 13ee1b0

Please sign in to comment.