Skip to content

Commit

Permalink
Improve client types (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 authored Feb 10, 2024
1 parent 4d44f79 commit e8b3e11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def execute(self, request: ModbusRequest | None = None):
# ----------------------------------------------------------------------- #
# Merged client methods
# ----------------------------------------------------------------------- #
async def async_execute(self, request=None) -> ModbusResponse:
async def async_execute(self, request) -> ModbusResponse:
"""Execute requests asynchronously."""
request.transaction_id = self.transaction.getNextTID()
packet = self.framer.buildPacket(request)
Expand Down Expand Up @@ -186,7 +186,7 @@ def callback_data(self, data: bytes, addr: tuple | None = None) -> int:
self.framer.processIncomingPacket(data, self._handle_response, slave=0)
return len(data)

async def connect(self):
async def connect(self) -> bool: # type: ignore[empty-body]
"""Connect to the modbus remote host."""

def raise_future(self, my_future, exc):
Expand Down Expand Up @@ -241,7 +241,7 @@ async def __aenter__(self):
return self

async def __aexit__(self, klass, value, traceback):
"""Implement the client with exit block."""
"""Implement the client with aexit block."""
self.close()

def __str__(self):
Expand Down Expand Up @@ -414,7 +414,7 @@ def get_address_family(cls, address):
return socket.AF_INET
return socket.AF_INET6

def connect(self):
def connect(self) -> bool: # type: ignore[empty-body]
"""Connect to other end, overwritten."""

def close(self):
Expand Down
1 change: 1 addition & 0 deletions test/sub_client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ async def test_client_build_response():
with pytest.raises(ConnectionException):
await client.build_response(0)


async def test_client_mixin_execute():
"""Test dummy execute for both sync and async."""
client = ModbusClientMixin()
Expand Down

0 comments on commit e8b3e11

Please sign in to comment.