Closed as not planned
Description
The ModbusTcpClient had a signature change between 3.6 and 3.7 for the port parameter.
see
https://github.com/pymodbus-dev/pymodbus/blob/v3.6.9/pymodbus/client/tcp.py#L61
def __init__(
self,
host: str,
port: int = 502,
framer: Framer = Framer.SOCKET,
source_address: tuple[str, int] | None = None,
**kwargs: Any,
) -> None:
vs
https://github.com/pymodbus-dev/pymodbus/blob/v3.7.0/pymodbus/client/tcp.py#L61
def __init__( # pylint: disable=too-many-arguments
self,
host: str,
framer: FramerType = FramerType.SOCKET,
port: int = 502,
name: str = "comm",
source_address: tuple[str, int] | None = None,
reconnect_delay: float = 0.1,
reconnect_delay_max: float = 300,
timeout: float = 3,
retries: int = 3,
on_connect_callback: Callable[[bool], None] | None = None,
) -> None:
This results in the following error if using positional arguments for port.
Traceback (most recent call last):
File "main.py", line 13, in <module>
client = ModbusTcpClient('localhost', 5502)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "../pymodbus/client/tcp.py", line 158, in __init__
super().__init__(framer, retries)
File "../pymodbus/client/base.py", line 190, in __init__
self.framer: ModbusFramer = FRAMER_NAME_TO_CLASS.get(
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object is not callable
Reverting to 3.6.9 or using kwargs resolves the issue.
Metadata
Metadata
Assignees
Labels
No labels