Skip to content

Commit 620fd0c

Browse files
committed
early return
1 parent abfeac4 commit 620fd0c

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

pymodbus_repl/client/mclient.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,27 @@ def _wrapper(*args, **kwargs):
8181
_Base = object
8282

8383

84-
class ExtendedRequestSupport(_Base): # pylint: disable=(too-many-public-methods
84+
class ExtendedRequestSupport(_Base): # pylint: disable=too-many-public-methods
8585
"""Extended request support."""
8686

8787
@staticmethod
8888
def _process_exception(resp, **kwargs):
8989
"""Set internal process exception."""
9090
if "slave" not in kwargs:
91-
err = {"message": "Broadcast message, ignoring errors!!!"}
92-
else:
93-
if isinstance(resp, ExceptionResponse): # pylint: disable=else-if-used
94-
err = {
95-
"original_function_code": f"{resp.original_code} ({hex(resp.original_code)})",
96-
"error_function_code": f"{resp.function_code} ({hex(resp.function_code)})",
97-
"exception code": resp.exception_code,
98-
"message": ExceptionResponse.decode(resp.exception_code),
99-
}
100-
elif isinstance(resp, ModbusIOException):
101-
err = {
102-
"original_function_code": f"{resp.fcode} ({hex(resp.fcode)})",
103-
"error": resp.message,
104-
}
105-
else:
106-
err = {"error": str(resp)}
107-
return err
91+
return {"message": "Broadcast message, ignoring errors!!!"}
92+
if isinstance(resp, ExceptionResponse): # pylint: disable=else-if-used
93+
return {
94+
"original_function_code": f"{resp.original_code} ({hex(resp.original_code)})",
95+
"error_function_code": f"{resp.function_code} ({hex(resp.function_code)})",
96+
"exception code": resp.exception_code,
97+
"message": ExceptionResponse.decode(resp.exception_code),
98+
}
99+
if isinstance(resp, ModbusIOException):
100+
return {
101+
"original_function_code": f"{resp.fcode} ({hex(resp.fcode)})",
102+
"error": resp.message,
103+
}
104+
return {"error": str(resp)}
108105

109106
def read_coils(self, address, count=1, slave=0, **kwargs):
110107
"""Read `count` coils from a given slave starting at `address`.

0 commit comments

Comments
 (0)