Skip to content

Commit

Permalink
pylint pleaser.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Apr 19, 2023
1 parent 38833a8 commit 9bb1f50
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__( # pylint: disable=too-many-arguments
**kwargs: Any,
) -> None:
"""Initialize a client instance."""
BaseTransport.__init__(self, framer, 0, "Client")
BaseTransport.__init__(self)
self.params = self._params()
self.params.framer = framer
self.params.timeout = float(timeout)
Expand Down
45 changes: 17 additions & 28 deletions pymodbus/transport/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,20 @@ class BaseTransport:
This class is not available in the pymodbus API, and should not be referenced in Applications.
"""

def __init__( # pylint: disable=too-many-arguments
self,
framer: ModbusFramer,
slaves: list[int],
comm_name: str = "NO NAME",
reconnect_delay: int = 0,
reconnect_delay_max: int = 0,
retries_send: int = 0,
retry_on_empty: bool = False,
timeout_connect: int = 10,
timeout_comm: int = 5,
on_connection_made: Callable[[str], None] | None = None,
on_connection_lost: Callable[[str, Exception], None] | None = None,
) -> None:
def __init__(self) -> None:
"""Initialize a transport instance."""
# parameter variables
self.framer = framer
self.slaves = slaves
self.comm_name = comm_name
self.reconnect_delay = reconnect_delay
self.reconnect_delay_max = reconnect_delay_max
self.retries_send = retries_send
self.retry_on_empty = retry_on_empty
self.timeout_connect = timeout_connect
self.timeout_comm = timeout_comm
self.on_connection_made = on_connection_made
self.on_connection_lost = on_connection_lost
# parameter variables, overwritten in child classes
self.framer: ModbusFramer | None = None
self.slaves: list[int] = []
self.comm_name: str = ""
self.reconnect_delay: int = -1
self.reconnect_delay_max: int = -1
self.retries_send: int = -1
self.retry_on_empty: int = -1
self.timeout_connect: bool = None
self.timeout_comm: int = -1
self.on_connection_made: Callable[[str], None] = None
self.on_connection_lost: Callable[[str, Exception], None] | None = None

# local variables
self.reconnect_delay_current: int = 0
Expand All @@ -73,7 +60,7 @@ def connection_made(self, transport: Any):
self.transport = transport
Log.debug("Connected {}", self.comm_name)
if self.on_connection_made:
self.on_connection_made(self.comm_name)
self.on_connection_made(self.comm_name) # pylint: disable=not-callable

def connection_lost(self, reason: Exception):
"""Call from asyncio, when the connection is lost or closed.
Expand All @@ -83,7 +70,9 @@ def connection_lost(self, reason: Exception):
self.transport = None
Log.debug("Connection lost {} due to {}", self.comm_name, reason)
if self.on_connection_lost:
self.on_connection_lost(self.comm_name, reason)
self.on_connection_lost( # pylint: disable=not-callable
self.comm_name, reason
)

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

0 comments on commit 9bb1f50

Please sign in to comment.