Riden icon indicating copy to clipboard operation
Riden copied to clipboard

fix: typing hints

Open rpoisel opened this issue 2 years ago • 2 comments

First of all: thanks for this package. It really saved me some time. :+1:

I fixed the typing hints according to the error messages displayed by pyright.

If you want, we could also change all set_* and get_* methods to @property and @property.setter to make it a bit more pythonic. But this, I would do in a separate PR.

rpoisel avatar Aug 03 '23 07:08 rpoisel

The typing hints are useful, but I see no reason to have separate single and multiple methods. It's a breaking change to replace an overloaded parameter that's only used within the update method, and assert the response length matches the request length. As far as I'm aware the modbus library should already error at register bounds or fill in missing data

It's been awhile since I made this, but I don't believe getters and setter properties support parameters to overload the cache state from update.

ShayBox avatar Aug 03 '23 07:08 ShayBox

The typing hints are useful, but I see no reason to have separate single and multiple methods. It's a breaking change to replace an overloaded parameter that's only used within the update method, and assert the response length matches the request length. As far as I'm aware the modbus library should already error at register bounds or fill in missing data

Okay, well, then I will make this 100% interface compatible and distinguish between the types inside the read/write method's implementation if necessary.

It's been awhile since I made this, but I don't believe getters and setter properties support parameters to overload the cache state from update.

The idea is to replace only the get_/set_ methods with getters/setters properties. This is more syntactic sugar than an actual change in the implementation. The update() method would stay the same and any caching could be preserved. However, there is not much to win here, so I'll leave that as it is.

rpoisel avatar Aug 03 '23 08:08 rpoisel