Skip to content

Commit 9bb1f50

Browse files
committed
pylint pleaser.
1 parent 38833a8 commit 9bb1f50

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

pymodbus/client/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __init__( # pylint: disable=too-many-arguments
9696
**kwargs: Any,
9797
) -> None:
9898
"""Initialize a client instance."""
99-
BaseTransport.__init__(self, framer, 0, "Client")
99+
BaseTransport.__init__(self)
100100
self.params = self._params()
101101
self.params.framer = framer
102102
self.params.timeout = float(timeout)

pymodbus/transport/base.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,20 @@ class BaseTransport:
3030
This class is not available in the pymodbus API, and should not be referenced in Applications.
3131
"""
3232

33-
def __init__( # pylint: disable=too-many-arguments
34-
self,
35-
framer: ModbusFramer,
36-
slaves: list[int],
37-
comm_name: str = "NO NAME",
38-
reconnect_delay: int = 0,
39-
reconnect_delay_max: int = 0,
40-
retries_send: int = 0,
41-
retry_on_empty: bool = False,
42-
timeout_connect: int = 10,
43-
timeout_comm: int = 5,
44-
on_connection_made: Callable[[str], None] | None = None,
45-
on_connection_lost: Callable[[str, Exception], None] | None = None,
46-
) -> None:
33+
def __init__(self) -> None:
4734
"""Initialize a transport instance."""
48-
# parameter variables
49-
self.framer = framer
50-
self.slaves = slaves
51-
self.comm_name = comm_name
52-
self.reconnect_delay = reconnect_delay
53-
self.reconnect_delay_max = reconnect_delay_max
54-
self.retries_send = retries_send
55-
self.retry_on_empty = retry_on_empty
56-
self.timeout_connect = timeout_connect
57-
self.timeout_comm = timeout_comm
58-
self.on_connection_made = on_connection_made
59-
self.on_connection_lost = on_connection_lost
35+
# parameter variables, overwritten in child classes
36+
self.framer: ModbusFramer | None = None
37+
self.slaves: list[int] = []
38+
self.comm_name: str = ""
39+
self.reconnect_delay: int = -1
40+
self.reconnect_delay_max: int = -1
41+
self.retries_send: int = -1
42+
self.retry_on_empty: int = -1
43+
self.timeout_connect: bool = None
44+
self.timeout_comm: int = -1
45+
self.on_connection_made: Callable[[str], None] = None
46+
self.on_connection_lost: Callable[[str, Exception], None] | None = None
6047

6148
# local variables
6249
self.reconnect_delay_current: int = 0
@@ -73,7 +60,7 @@ def connection_made(self, transport: Any):
7360
self.transport = transport
7461
Log.debug("Connected {}", self.comm_name)
7562
if self.on_connection_made:
76-
self.on_connection_made(self.comm_name)
63+
self.on_connection_made(self.comm_name) # pylint: disable=not-callable
7764

7865
def connection_lost(self, reason: Exception):
7966
"""Call from asyncio, when the connection is lost or closed.
@@ -83,7 +70,9 @@ def connection_lost(self, reason: Exception):
8370
self.transport = None
8471
Log.debug("Connection lost {} due to {}", self.comm_name, reason)
8572
if self.on_connection_lost:
86-
self.on_connection_lost(self.comm_name, reason)
73+
self.on_connection_lost( # pylint: disable=not-callable
74+
self.comm_name, reason
75+
)
8776

8877
def data_received(self, data: bytes):
8978
"""Call when some data is received.

0 commit comments

Comments
 (0)