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

Updated type annotations for getaddrinfo() #62

Merged
merged 2 commits into from
Mar 28, 2023
Merged

Conversation

agronholm
Copy link
Contributor

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.

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
Copy link
Member

oremanj commented Mar 28, 2023

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.

@oremanj oremanj merged commit 73ba636 into master Mar 28, 2023
@oremanj oremanj deleted the fix-getaddrinfo-types branch March 28, 2023 23:48
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

Successfully merging this pull request may close these issues.

None yet

2 participants