Skip to content

read_pin does not return a boolean #6

Closed
@rgov

Description

@rgov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions