Skip to content

Commit df5f24c

Browse files
authored
Ignore all remaining implicit optional (#1888)
1 parent a9288ab commit df5f24c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pymodbus/transport/transport.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def __init__(
156156
self.is_server = is_server
157157
self.is_closing = False
158158

159-
self.transport: asyncio.BaseTransport = None
160-
self.loop: asyncio.AbstractEventLoop = None
159+
self.transport: asyncio.BaseTransport = None # type: ignore[assignment]
160+
self.loop: asyncio.AbstractEventLoop = None # type: ignore[assignment]
161161
self.recv_buffer: bytes = b""
162-
self.call_create: Callable[[], Coroutine[Any, Any, Any]] = lambda: None
162+
self.call_create: Callable[[], Coroutine[Any, Any, Any]] = lambda: None # type: ignore[assignment, return-value]
163163
if self.is_server:
164164
self.active_connections: dict[str, ModbusProtocol] = {}
165165
else:
@@ -413,7 +413,7 @@ def transport_close(self, intern: bool = False, reconnect: bool = False) -> None
413413
self.is_closing = True
414414
if self.transport:
415415
self.transport.close()
416-
self.transport = None
416+
self.transport = None # type: ignore[assignment]
417417
self.recv_buffer = b""
418418
if self.is_server:
419419
for _key, value in self.active_connections.items():
@@ -515,7 +515,7 @@ def __init__(self, protocol: ModbusProtocol, listen: int | None = None) -> None:
515515
asyncio.DatagramTransport.__init__(self)
516516
asyncio.Transport.__init__(self)
517517
self.protocol: ModbusProtocol = protocol
518-
self.other_modem: NullModem = None
518+
self.other_modem: NullModem = None # type: ignore[assignment]
519519
self.listen = listen
520520
self.manipulator: Callable[[bytes], list[bytes]] | None = None
521521
self._is_closing = False
@@ -589,9 +589,9 @@ def close(self) -> None:
589589
with suppress(KeyError):
590590
del self.connections[self]
591591
if self.other_modem:
592-
self.other_modem.other_modem = None
592+
self.other_modem.other_modem = None # type: ignore[assignment]
593593
self.other_modem.close()
594-
self.other_modem = None
594+
self.other_modem = None # type: ignore[assignment]
595595
if self.protocol:
596596
self.protocol.connection_lost(None)
597597

pymodbus/transport/transport_serial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def close(self, exc: Exception | None = None) -> None:
5151
else:
5252
self.async_loop.remove_reader(self.sync_serial.fileno())
5353
self.sync_serial.close()
54-
self.sync_serial = None
54+
self.sync_serial = None # type: ignore[assignment]
5555
if exc:
5656
with contextlib.suppress(Exception):
5757
self._protocol.connection_lost(exc)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ overgeneral-exceptions = "builtins.Exception"
189189
bad-functions = "map,input"
190190

191191
[tool.mypy]
192-
strict_optional = false
192+
strict_optional = true
193193
show_error_codes = true
194194
local_partial_types = true
195195
strict_equality = true

0 commit comments

Comments
 (0)