Skip to content

Socket address type should be updated elsewhere #13472

Open
@victorlin

Description

#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]: ...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: false negativeType checkers do not report an error, but should

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions