Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore all remaining implicit optional #1888

Merged
merged 5 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pymodbus/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -413,7 +413,7 @@ def transport_close(self, intern: bool = False, reconnect: bool = False) -> None
self.is_closing = True
if self.transport:
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():
Expand Down Expand Up @@ -515,7 +515,7 @@ def __init__(self, protocol: ModbusProtocol, listen: int | None = None) -> None:
asyncio.DatagramTransport.__init__(self)
asyncio.Transport.__init__(self)
self.protocol: ModbusProtocol = protocol
self.other_modem: NullModem = None
self.other_modem: NullModem = None # type: ignore[assignment]
self.listen = listen
self.manipulator: Callable[[bytes], list[bytes]] | None = None
self._is_closing = False
Expand Down Expand Up @@ -589,9 +589,9 @@ def close(self) -> None:
with suppress(KeyError):
del self.connections[self]
if self.other_modem:
self.other_modem.other_modem = None
self.other_modem.other_modem = None # type: ignore[assignment]
self.other_modem.close()
self.other_modem = None
self.other_modem = None # type: ignore[assignment]
if self.protocol:
self.protocol.connection_lost(None)

Expand Down
2 changes: 1 addition & 1 deletion pymodbus/transport/transport_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down