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

Socket address type should be updated elsewhere #13472

Open
victorlin opened this issue Feb 7, 2025 · 0 comments
Open

Socket address type should be updated elsewhere #13472

victorlin opened this issue Feb 7, 2025 · 0 comments

Comments

@victorlin
Copy link

#13344 / #13372 updated the return value of socket.getaddrinfo to include tuple[int, bytes]:

typeshed/stdlib/socket.pyi

Lines 1402 to 1405 in 80dba41

# The 5th tuple item is the socket address, for IP4, IP6, or IP6 if Python is compiled with --disable-ipv6, respectively.
def getaddrinfo(
host: bytes | str | None, port: bytes | str | int | None, family: int = 0, type: int = 0, proto: int = 0, flags: int = 0
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]: ...

I think it should be updated elsewhere too, such as the internal counterpart:

typeshed/stdlib/_socket.pyi

Lines 807 to 815 in 80dba41

# the 5th tuple item is an address
def getaddrinfo(
host: bytes | str | None,
port: bytes | str | int | None,
family: int = ...,
type: int = ...,
proto: int = ...,
flags: int = ...,
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...

and possibly the type for the sockaddr argument in getnameinfo, though I haven't tested if a tuple[int, bytes] is actually valid there (stdlib docs are unclear):

def getnameinfo(sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int, /) -> tuple[str, str]: ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant