Skip to content

Commit 7ca7967

Browse files
committed
style: reformat code with ruff, fix mypy type issues
1 parent 9fbb35e commit 7ca7967

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/wokwi_client/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
from pathlib import Path
6-
from typing import Any, Optional
6+
from typing import Any, Optional, Union
77

88
from .__version__ import get_version
99
from .constants import DEFAULT_WS_URL
@@ -193,7 +193,7 @@ async def serial_monitor_cat(self, decode_utf8: bool = True, errors: str = "repl
193193
else:
194194
print(line, end="", flush=True)
195195

196-
async def serial_write(self, data: bytes | str | list[int]) -> None:
196+
async def serial_write(self, data: Union[bytes, str, list[int]]) -> None:
197197
"""Write data to the simulation serial monitor interface."""
198198
await write_serial(self._transport, data)
199199

@@ -222,7 +222,9 @@ async def listen_pin(self, part: str, pin: str, listen: bool = True) -> Response
222222
"""
223223
return await pin_listen(self._transport, part=part, pin=pin, listen=listen)
224224

225-
async def set_control(self, part: str, control: str, value: int | bool | float) -> ResponseMessage:
225+
async def set_control(
226+
self, part: str, control: str, value: Union[int, bool, float]
227+
) -> ResponseMessage:
226228
"""Set a control value (e.g. simulate button press).
227229
228230
Args:

src/wokwi_client/control.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
#
1212
# SPDX-License-Identifier: MIT
1313

14+
from typing import Union
15+
1416
from .protocol_types import ResponseMessage
1517
from .transport import Transport
1618

1719

1820
async def set_control(
19-
transport: Transport, *, part: str, control: str, value: int | bool | float
21+
transport: Transport, *, part: str, control: str, value: Union[int, bool, float]
2022
) -> ResponseMessage:
2123
"""Set a control value on a part (e.g. simulate button press/release).
2224

src/wokwi_client/pins.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
from .transport import Transport
1616

1717

18-
async def pin_read(
19-
transport: Transport, *, part: str, pin: str
20-
) -> ResponseMessage:
18+
async def pin_read(transport: Transport, *, part: str, pin: str) -> ResponseMessage:
2119
"""Read the state of a pin.
2220
2321
Args:
@@ -44,6 +42,4 @@ async def pin_listen(
4442
listen: True to start listening, False to stop.
4543
"""
4644

47-
return await transport.request(
48-
"pin:listen", {"part": part, "pin": pin, "listen": listen}
49-
)
45+
return await transport.request("pin:listen", {"part": part, "pin": pin, "listen": listen})

src/wokwi_client/serial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
from collections.abc import AsyncGenerator, Iterable
5+
from collections.abc import AsyncGenerator
6+
from typing import Union
67

78
from .event_queue import EventQueue
89
from .transport import Transport
@@ -16,7 +17,7 @@ async def monitor_lines(transport: Transport) -> AsyncGenerator[bytes, None]:
1617
yield bytes(event_msg["payload"]["bytes"])
1718

1819

19-
async def write_serial(transport: Transport, data: bytes | str | Iterable[int]) -> None:
20+
async def write_serial(transport: Transport, data: Union[bytes, str, list[int]]) -> None:
2021
"""Write data to the serial monitor.
2122
2223
Accepts bytes, str (encoded as utf-8), or an iterable of integer byte values.

0 commit comments

Comments
 (0)