Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ line-length = 100
"SLF001",
"TRY003"
]

[tool.ty.rules]
unused-type-ignore-comment = "error"
4 changes: 2 additions & 2 deletions src/anycorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _create_sockets( # noqa: C901, PLR0912
for bind in binds:
binding: Any = None
if bind.startswith("unix:"):
sock = socket.socket(socket.AF_UNIX, type_) # type: ignore[attr-defined]
sock = socket.socket(socket.AF_UNIX, type_)
binding = bind[5:]
with contextlib.suppress(FileNotFoundError):
if stat.S_ISSOCK(pathlib.Path(binding).stat().st_mode):
Expand All @@ -288,7 +288,7 @@ def _create_sockets( # noqa: C901, PLR0912

if self.workers > 1:
with contextlib.suppress(AttributeError):
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) # type: ignore[attr-defined]
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
binding = (host, port)

sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Expand Down
2 changes: 1 addition & 1 deletion src/anycorn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def repr_socket_addr(family: int, address: tuple) -> str:
return f"{address[0]}:{address[1]}"
if family == socket.AF_INET6:
return f"[{address[0]}]:{address[1]}"
if family == socket.AF_UNIX: # type: ignore[unresolved-attribute]
if family == socket.AF_UNIX:
return f"unix:{address}"
return f"{address}"

Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_create_sockets_unix(monkeypatch: MonkeyPatch) -> None:
config.bind = ["unix:/tmp/anycorn.sock"]
sockets = config.create_sockets()
sock = sockets.insecure_sockets[0]
mock_socket.assert_called_with(socket.AF_UNIX, socket.SOCK_STREAM) # type: ignore[unresolved-attribute]
mock_socket.assert_called_with(socket.AF_UNIX, socket.SOCK_STREAM)
sock.setsockopt.assert_called_with(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # type: ignore[attr-defined]
sock.bind.assert_called_with("/tmp/anycorn.sock") # type: ignore[attr-defined] # noqa: S108
sock.setblocking.assert_called_with(False) # type: ignore[attr-defined] # noqa: FBT003
Expand Down
Loading