ShayBox / Riden

A python library for Riden RD power supplies
MIT License
49 stars 13 forks source link

fix: typing hints #10

Open rpoisel opened 1 year ago

rpoisel commented 1 year ago

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.

ShayBox commented 1 year ago

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.

rpoisel commented 1 year ago

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.