Skip to content

Commit

Permalink
Remove kwargs client. (#2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Jul 19, 2024
1 parent 552c56e commit 72e3399
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 272 deletions.
20 changes: 13 additions & 7 deletions pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pymodbus.logging import Log
from pymodbus.pdu import ModbusRequest, ModbusResponse
from pymodbus.transaction import SyncModbusTransactionManager
from pymodbus.transport import CommParams
from pymodbus.transport import CommParams, CommType
from pymodbus.utilities import ModbusTransactionState


Expand All @@ -37,6 +37,7 @@ class ModbusBaseClient(ModbusClientMixin[Awaitable[ModbusResponse]]):
:param reconnect_delay_max: Maximum delay in seconds.milliseconds before reconnecting.
:param on_connect_callback: Will be called when connected/disconnected (bool parameter)
:param no_resend_on_retry: Do not resend request when retrying due to missing response.
:param comm_type: Type of communication (set by interface class)
:param kwargs: Experimental parameters.
.. tip::
Expand All @@ -49,7 +50,7 @@ class ModbusBaseClient(ModbusClientMixin[Awaitable[ModbusResponse]]):
**Application methods, common to all clients**:
"""

def __init__(
def __init__( # pylint: disable=too-many-arguments
self,
framer: FramerType,
timeout: float = 3,
Expand All @@ -59,16 +60,18 @@ def __init__(
reconnect_delay_max: float = 300,
on_connect_callback: Callable[[bool], None] | None = None,
no_resend_on_retry: bool = False,
comm_type: CommType | None = None,
source_address: tuple[str, int] | None = None,
**kwargs: Any,
) -> None:
"""Initialize a client instance."""
ModbusClientMixin.__init__(self) # type: ignore[arg-type]
self.ctx = ModbusClientProtocol(
framer,
CommParams(
comm_type=kwargs.get("CommType"),
comm_type=comm_type,
comm_name="comm",
source_address=kwargs.get("source_address", None),
source_address=source_address,
reconnect_delay=reconnect_delay,
reconnect_delay_max=reconnect_delay_max,
timeout_connect=timeout,
Expand Down Expand Up @@ -238,6 +241,7 @@ class ModbusBaseSyncClient(ModbusClientMixin[ModbusResponse]):
:param reconnect_delay: Minimum delay in seconds.milliseconds before reconnecting.
:param reconnect_delay_max: Maximum delay in seconds.milliseconds before reconnecting.
:param no_resend_on_retry: Do not resend request when retrying due to missing response.
:param source_address: source address of client
:param kwargs: Experimental parameters.
.. tip::
Expand All @@ -260,7 +264,7 @@ class _params:
reconnect_delay: int | None = None
source_address: tuple[str, int] | None = None

def __init__(
def __init__( # pylint: disable=too-many-arguments
self,
framer: FramerType,
timeout: float = 3,
Expand All @@ -270,14 +274,16 @@ def __init__(
reconnect_delay: float = 0.1,
reconnect_delay_max: float = 300.0,
no_resend_on_retry: bool = False,
comm_type: CommType | None = None,
source_address: tuple[str, int] | None = None,
**kwargs: Any,
) -> None:
"""Initialize a client instance."""
ModbusClientMixin.__init__(self) # type: ignore[arg-type]
self.comm_params = CommParams(
comm_type=kwargs.get("CommType"),
comm_type=comm_type,
comm_name="comm",
source_address=kwargs.get("source_address", None),
source_address=source_address,
reconnect_delay=reconnect_delay,
reconnect_delay_max=reconnect_delay_max,
timeout_connect=timeout,
Expand Down
Loading

0 comments on commit 72e3399

Please sign in to comment.