Fix mypy pre-commit hook on windows (#1081)

This commit is contained in:
Steven B.
2024-07-25 09:11:48 +01:00
committed by GitHub
parent 1c83675e57
commit 7416e855f1
2 changed files with 18 additions and 3 deletions

View File

@@ -209,7 +209,8 @@ class _DiscoverProtocol(asyncio.DatagramProtocol):
except OSError as ex: # WSL does not support SO_REUSEADDR, see #246
_LOGGER.debug("Unable to set SO_REUSEADDR: %s", ex)
if self.interface is not None:
# windows does not support SO_BINDTODEVICE
if self.interface is not None and hasattr(socket, "SO_BINDTODEVICE"):
sock.setsockopt(
socket.SOL_SOCKET, socket.SO_BINDTODEVICE, self.interface.encode()
)