adafruit / Adafruit_CircuitPython_PCF8575

CircuitPython / Python library for Adafruit PCF8575 GPIO expanders
MIT License
1 stars 1 forks source link

read_pin does not return a boolean #6

Open rgov opened 1 year ago

rgov commented 1 year ago

The implementation of the adafruit_pcf8575.PCF8575.read_pin() is:

    def read_pin(self, pin: int) -> bool:
        return (self.read_gpio() >> pin) & 0x1

The result of the calculation is an int. A bool should be constructed from the result before being passed back to the caller. (Aside: Doesn't mypy catch this?)

Consequently the adafruit_pcf8575.DigitalInOut.value does not adhere to the digitalio.DigitalInOut interface.

This also applies to the PCF8574 implementation.

tekktrik commented 8 months ago

Hi, we actually don't utilize mypy at the moment, so types are not checked within the CI. I agree that it makes sense to return a bool to stay consistent. Are you interested in submitting a PR to fix it?