adafruit / Adafruit_Blinka_bleio

`_bleio` for Blinka based on `bleak`
58 stars 19 forks source link

as of bleak 0.11.0, is_connected is no longer async #33

Closed dhalbert closed 3 years ago

dhalbert commented 3 years ago

BleakClient.is_connected() became non-async in bleak 0.11.0, and it also became a property; the method version is deprecated.

The non-async aspect broke our current code. I've fixed that, and I've also pinned the bleak version to 0.11.0 because bleak's API is still subject to change. I'll track bleak and try to keep up with but it would be better not to break existing code right now.

Problem discovered by "OldCrow" in discord. Tested with the sample programs they were having trouble with.

dhalbert commented 3 years ago

@kattni @FoamyGuy pylint is reporting "duplicate code", which is a red herring in this case. I tried increasing min-similarity-lines, but the problem persists, even if I increase the value to thousands. I know it's reading .pylintrc, because I turned on ignore-imports due to another specious warning, and that was effective. Do you have any suggestions? Thanks.

************* Module _bleio.adapter_
_bleio/adapter_.py:1:0: R0801: Similar lines in 2 files
==_bleio.characteristic:112
==_bleio.descriptor:93
            read_perm=read_perm,
            write_perm=write_perm,
            max_length=max_length,
            fixed_length=fixed_length,
            initial_value=initial_value,
        ) (duplicate-code)
_bleio/adapter_.py:1:0: R0801: Similar lines in 2 files
==_bleio.characteristic:61
==_bleio.descriptor:47
        self._read_perm = read_perm
        self._write_perm = write_perm
        self._max_length = max_length
        self._fixed_length = fixed_length
        self._initial_value = initial_value (duplicate-code)

------------------------------------
Your code has been rated at 10.00/10
# Ignore imports when computing similarities.
ignore-imports=yes

# Minimum lines number of a similarity.
min-similarity-lines=10
kattni commented 3 years ago

@dhalbert If you don't change jobs=2 to jobs=1, it ignores changes to the min-similarity-lines. So it doesn't matter what you increased it to if you don't update jobs to less than 2.

min-similarity-lines should be 12. That is what we increased it to across the libraries. Did it get missed here?

dhalbert commented 3 years ago

Thanks for the tip! This is a Blinka library, so I think it wasn't part of any sweep. I had to add all the SPDX info, pyproject.toml, etc. myself last night.

dhalbert commented 3 years ago

Ready for review now; tested with a pulse oximeter. I had to do an extensive rework of the source organization to remove pylint circular import warnings: several files with mutual references were merged into a new common.py. Also, I noted that requirements.txt was being ignored for the bleak version requirements, so I added that to setup.py. I'm still confused about when requirements.txt is useful.