diff --git a/pymodbus/transport/transport.py b/pymodbus/transport/transport.py index be9b32cca1..b9a98da2e9 100644 --- a/pymodbus/transport/transport.py +++ b/pymodbus/transport/transport.py @@ -156,10 +156,10 @@ def __init__( self.is_server = is_server self.is_closing = False - self.transport: asyncio.BaseTransport = None - self.loop: asyncio.AbstractEventLoop = None + self.transport: asyncio.BaseTransport = None # type: ignore[assignment] + self.loop: asyncio.AbstractEventLoop = None # type: ignore[assignment] self.recv_buffer: bytes = b"" - self.call_create: Callable[[], Coroutine[Any, Any, Any]] = lambda: None + self.call_create: Callable[[], Coroutine[Any, Any, Any]] = lambda: None # type: ignore[assignment, return-value] if self.is_server: self.active_connections: dict[str, ModbusProtocol] = {} else: @@ -415,7 +415,7 @@ def transport_close(self, intern: bool = False, reconnect: bool = False) -> None if hasattr(self.transport, "abort"): self.transport.abort() self.transport.close() - self.transport = None + self.transport = None # type: ignore[assignment] self.recv_buffer = b"" if self.is_server: for _key, value in self.active_connections.items(): diff --git a/pymodbus/transport/transport_serial.py b/pymodbus/transport/transport_serial.py index 63c1affa5a..017c3687f7 100644 --- a/pymodbus/transport/transport_serial.py +++ b/pymodbus/transport/transport_serial.py @@ -51,7 +51,7 @@ def close(self, exc: Exception | None = None) -> None: else: self.async_loop.remove_reader(self.sync_serial.fileno()) self.sync_serial.close() - self.sync_serial = None + self.sync_serial = None # type: ignore[assignment] if exc: with contextlib.suppress(Exception): self._protocol.connection_lost(exc) diff --git a/pyproject.toml b/pyproject.toml index b781014c6a..c064943316 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -189,7 +189,7 @@ overgeneral-exceptions = "builtins.Exception" bad-functions = "map,input" [tool.mypy] -strict_optional = false +strict_optional = true show_error_codes = true local_partial_types = true strict_equality = true