Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Jan 12, 2024
1 parent 0a3d903 commit 99ff65e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tests/cmd/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ async def handle_request(
last_metadata = metadata
print("REQUEST OBJECT :", request)
print("REQUEST METADATA:", metadata)
sum_x = sum(map(lambda p: p.x, request.points)) # type: ignore
sum_y = sum(map(lambda p: p.y, request.points)) # type: ignore
a = sum_x * sum_y - len(request.points) * sum(map(lambda p: p.x * p.y, request.points)) # type: ignore
b = sum_x * sum_x - len(request.points) * sum(map(lambda p: p.x**2, request.points)) # type: ignore
sum_x = sum(map(lambda p: p.x, request.points))
sum_y = sum(map(lambda p: p.y, request.points))
a = sum_x * sum_y - len(request.points) * sum(map(lambda p: p.x * p.y, request.points))
b = sum_x * sum_x - len(request.points) * sum(map(lambda p: p.x**2, request.points))
slope = a / b
y_intercept = (sum_y - slope * sum_x) / len(request.points)
response = PerformLinearLeastSquaresFit_1.Response(slope=slope, y_intercept=y_intercept)
Expand Down
6 changes: 5 additions & 1 deletion tests/cmd/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# This software is distributed under the terms of the MIT License.
# Author: Pavel Kirienko <pavel@opencyphal.org>

# Disable unused ignore warning for this file only because there appears to be no other way to make MyPy
# accept this file both on Windows and GNU/Linux.
# mypy: warn_unused_ignores=False

from typing import Any, Optional, Awaitable
import sys
import socket
Expand Down Expand Up @@ -319,7 +323,7 @@ async def _inject_error() -> None:
)
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
if sys.platform.lower().startswith("linux"):
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # type: ignore
sock.bind(("127.0.0.1", 0))
sock.sendto(bad_heartbeat, ("239.0.29.85", 9382))

Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def stdout_file() -> Iterator[Path]:
"""
s = sys.stdout
p = Path(tempfile.mktemp("stdout")).resolve()
sys.stdout = p.open("a+")
sys.stdout = p.open("a+") # pylint: disable=consider-using-with
yield p
sys.stdout = s

Expand All @@ -34,6 +34,6 @@ def stderr_file() -> Iterator[Path]:
"""
s = sys.stderr
p = Path(tempfile.mktemp("stderr")).resolve()
sys.stderr = p.open("a+")
sys.stderr = p.open("a+") # pylint: disable=consider-using-with
yield p
sys.stderr = s
1 change: 1 addition & 0 deletions yakut/cmd/orchestrate/_child.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2021 OpenCyphal
# This software is distributed under the terms of the MIT License.
# Author: Pavel Kirienko <pavel@opencyphal.org>
# pylint: disable=consider-using-with

from __future__ import annotations
import os
Expand Down
2 changes: 1 addition & 1 deletion yakut/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def main() -> None: # https://click.palletsprojects.com/en/8.1.x/exceptions/
sys.exit(status)


subcommand: Callable[..., Callable[..., Any]] = _click_main.command
subcommand: Callable[..., Callable[..., Any]] = _click_main.command # type: ignore


def asynchronous(*, interrupted_ok: bool = False) -> Callable[[Callable[..., Awaitable[Any]]], Callable[..., Any]]:
Expand Down

0 comments on commit 99ff65e

Please sign in to comment.