pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.16k stars 891 forks source link

Improve types for client #2032

Closed alexrudd2 closed 4 months ago

alexrudd2 commented 4 months ago

Solve another 9 errors with mypy --check-untyped-defs

alexrudd2 commented 4 months ago

I do wonder why it does not complain on line 225-229, it is exactly the same issue (recv returns bytes)...that just goes to show how (sorry for the expression) how incompetent and dangerous these checkers can be :-)

Actually, the situation is more complicated :)

https://github.com/pymodbus-dev/pymodbus/blob/a152762c247301152051bfad59dd2ab0ffab781c/pymodbus/client/base.py#L401-L406 does not seem correct.

If I keep adding type hints (mostly bytes), the type checkers eventually find this: https://github.com/pymodbus-dev/pymodbus/blob/a152762c247301152051bfad59dd2ab0ffab781c/pymodbus/client/serial.py#L230-L232

Quite similar to https://github.com/pymodbus-dev/pymodbus/pull/2031, but I do not see the full picture yet. Hence not (yet) annotating recv().

janiversen commented 4 months ago

The recv() is an old relict, which I thought was removed long time ago....the very old code v2x had that for testing reasons I think.

janiversen commented 4 months ago

The _in_waiting() looks OK to me, but it the linters do not agree......

alexrudd2 commented 4 months ago

Down to 58!