Skip to content

Conversation

phlogistonjohn
Copy link
Collaborator

It seems that a recent mypy release is now determining that certain family types (not AF_INET, or AF_INET6) may return an address tupe with the first element type being an int rather than a str. The (expanded) revealed type is:

tuple[
    socket.AddressFamily,
    socket.SocketKind,
    builtins.int,
    builtins.str,
    Union[
        tuple[builtins.str, builtins.int],
        tuple[builtins.str, builtins.int, builtins.int, builtins.int],
        tuple[builtins.int, builtins.bytes]
    ]
]

This change ensures that we only check the family values we care about and use a type assertion for those families where we expect the address value to be a str.

FWIW I could not find any documentation for what families have an integer in the first element of the addr tuple. Looking at the python sources it seems like it could be AF_NETLINK, AF_QIPCRTR, AF_VSOCK - all families I have never seen in the wild before :-)

It seems that a recent mypy release is now determining that certain
family types (not AF_INET, or AF_INET6) may return an address tupe
with the first element type being an int rather than a str. The
(expanded) revealed type is:
```
tuple[
    socket.AddressFamily,
    socket.SocketKind,
    builtins.int,
    builtins.str,
    Union[
        tuple[builtins.str, builtins.int],
        tuple[builtins.str, builtins.int, builtins.int, builtins.int],
        tuple[builtins.int, builtins.bytes]
    ]
]
```

This change ensures that we only check the family values we care about
and use a type assertion for those families where we expect the address
value to be a str.

FWIW I could not find any documentation for what families have an
integer in the first element of the addr tuple. Looking at the python
sources it seems like it could be AF_NETLINK, AF_QIPCRTR, AF_VSOCK -
all families I have never seen in the wild before :-)

Signed-off-by: John Mulligan <[email protected]>
Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix itself lgtm.

See below for a comment on the existing address lookup logic.

Copy link
Collaborator

@avanthakkar avanthakkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mergify mergify bot merged commit aa9a005 into samba-in-kubernetes:master Feb 13, 2025
9 checks passed
@phlogistonjohn phlogistonjohn deleted the jjm-fix-ci-fail branch March 4, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants