pymodbus-dev / pymodbus

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

enable `mypy --check-untyped-defs` #2096

Closed alexrudd2 closed 3 months ago

alexrudd2 commented 3 months ago

image

When I started, there were over >150 mypy errors in untyped definitions. They have all been slowly solved.

Remaining ignores:

janiversen commented 3 months ago

The ascii_framer is not being removed.

Be very careful when you rework transaction, it has a lot of strange (but needed) code....and it seems I cut a little bit to deep, when removing a function in rtu_framer.

The request/response classes surely needs a refactoring, but that is not on my short list.

alexrudd2 commented 3 months ago

The ascii_framer is not being removed.

I meant the type error (which is now already gone).

Be very careful when you rework transaction, it has a lot of strange (but needed) code....and it seems I cut a little bit to deep, when removing a function in rtu_framer.

Yeah, your fixing the code satisfied mypy. I do not intend to do further changes right now. My goal of --no-untyped-defs is achieved with this PR.

alexrudd2 commented 3 months ago

The request/response classes surely needs a refactoring, but that is not on my short list.

I believe this is already mentioned in https://github.com/pymodbus-dev/pymodbus/issues/1034

janiversen commented 3 months ago

No #1034 is specifically about DIAG, my comment was about all the request/response classes.

I am f.x. convinced it would make the code simpler not to have separate a request and response class for each function code, but as wrote that is for later...right now my focus is the message layer, which is to followed by a new transaction layer with proper locking.

alexrudd2 commented 3 months ago

@laundmo has the typing situation improved for you with these recent changes?

For me all the mypy errors are cleared, and about 50% of the pyright ones.