Skip to content

read_pin does not return a boolean #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rgov opened this issue Oct 31, 2023 · 1 comment · Fixed by #8
Closed

read_pin does not return a boolean #6

rgov opened this issue Oct 31, 2023 · 1 comment · Fixed by #8

Comments

@rgov
Copy link
Contributor

rgov commented Oct 31, 2023

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
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants