Fix linting and type errors for CI
- Use X | None syntax instead of Optional[X] (UP045) - Sort imports in dashboard app (I001) - Remove unnecessary UTF-8 encoding argument (UP012) - Add 'from err' to exception re-raises (B904) - Remove unused imports in integration tests (F401) - Fix useless expression in test (B018) - Cast **1.5 result to float in LDO model (mypy no-any-return) - Use functools.partial instead of lambda in server (mypy misc)
This commit is contained in:
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from functools import partial
|
||||
from typing import Protocol, runtime_checkable
|
||||
|
||||
__all__ = ["InstrumentServer", "SCPIDevice"]
|
||||
@@ -132,8 +133,9 @@ class InstrumentServer:
|
||||
self._running = True
|
||||
|
||||
for port, instrument in self._instruments.items():
|
||||
handler = partial(self._handle_client, instrument=instrument, port=port)
|
||||
server = await asyncio.start_server(
|
||||
lambda r, w, inst=instrument, p=port: self._handle_client(r, w, inst, p),
|
||||
handler,
|
||||
self._host,
|
||||
port,
|
||||
)
|
||||
@@ -216,7 +218,7 @@ class InstrumentServer:
|
||||
|
||||
# Send response with newline terminator
|
||||
if response:
|
||||
writer.write(f"{response}\n".encode("utf-8"))
|
||||
writer.write(f"{response}\n".encode())
|
||||
await writer.drain()
|
||||
logger.debug("Port %d sent: %s", port, response)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user