Skip to content

Commit

Permalink
solve more mypy issues with client (#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 authored Feb 14, 2024
1 parent c7c0802 commit be326f7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _handle_response(self, reply, **_kwargs):

def build_response(self, tid):
"""Return a deferred response for the current request."""
my_future = asyncio.Future()
my_future: asyncio.Future = asyncio.Future()
if not self.transport:
self.raise_future(my_future, ConnectionException("Client is not connected"))
else:
Expand Down
6 changes: 5 additions & 1 deletion pymodbus/client/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ async def run():
Please refer to :ref:`Pymodbus internals` for advanced usage.
"""

socket: socket.socket | None

def __init__(
self,
host: str,
Expand Down Expand Up @@ -131,6 +133,8 @@ async def run():
Remark: There are no automatic reconnect as with AsyncModbusTcpClient
"""

socket: socket.socket | None

def __init__(
self,
host: str,
Expand Down Expand Up @@ -219,7 +223,7 @@ def recv(self, size):
else:
recv_size = size

data = []
data: list[bytes] = []
data_length = 0
time_ = time.time()
end = time_ + timeout
Expand Down
2 changes: 2 additions & 0 deletions pymodbus/client/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ async def run():
Remark: There are no automatic reconnect as with AsyncModbusUdpClient
"""

socket: socket.socket | None

def __init__(
self,
host: str,
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, owner):
self.running = False
self.receive_queue = asyncio.Queue()
self.handler_task = None # coroutine to be run on asyncio loop
self.framer: ModbusFramer = None
self.framer: ModbusFramer

def _log_exception(self):
"""Show log exception."""
Expand Down

0 comments on commit be326f7

Please sign in to comment.