python-trio / trio-typing

Type hints for Trio and related projects
Other
27 stars 13 forks source link

Updated type annotations for getaddrinfo() #62

Closed agronholm closed 1 year ago

agronholm commented 2 years ago

Unless trio does something differently, the argument and return types should match those of socket.getaddrinfo(). In particular, that function does not accept bytearrays as host.

oremanj commented 1 year ago

The most current typeshed stubs are

def getaddrinfo(
    host: bytearray | bytes | str | None,
    port: str | int | None,
    family: int = ...,
    type: int = ...,
    proto: int = ...,
    flags: int = ...,
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...

I think the ones in trio-typing were copied from an earlier version. The bytearray difference doesn't really matter because mypy will promote bytearray to bytes regardless of what the stubs say. The more-specific return type matches upstream. Will land this with a format fix.