Closed dglaude closed 3 years ago
@dglaude I know that we have done something like that (putting the i2c import in the i2c class) a few times before and just put a pylint ignore on that line.
I believe @kattni has the hardware to test this, so it is best that she test this option. I prefer not to blindly propose a change.
@dglaude You may be able to move from adafruit_bus_device.i2c_device import I2CDevice
into the PM25_I2C
class. https://github.com/adafruit/Adafruit_CircuitPython_PM25/blob/f70830bcf712e3f74c4756ed663b4fd17029c9a3/adafruit_pm25.py#L122 Then it would only be imported if using I2C. It may require a pylint: disable=
for an import in the "wrong" place. I can test the changes if you'd like to put in a PR.
I have been trying that in #7 but black is not happy yet and is not telling me exactly why. (and then I will have to keep pylint happy too) As I don't have a local pylint/black install, I think I will give up for now.
@dglaude if you have pip3
, you can install black
and pylint
just with:
pip3 install --user black pylint
. You may not need the --user
, and if you are on Windows, it may be pip
instead of pip3
.
Thanks, I will read this guide: https://learn.adafruit.com/improve-your-code-with-pylint/overview I have already the right pylint exclude, now I need to figure out what black want from me.
Should be solved with #7 . This require testing with I2C air quality sensor, but it works in UART and I2C without sensor.
The Pull Request #8 might solve this a better way than #7 However, as a package, the way to import and use is a bit different. I am no expert in "import ... as ..." that could limit this issue.
Please consider the best option, also @kattni if some learn guide use this, you may want to sync. Finally @gadgetoid has plan to see if he can bring improvement from Pimoroni UART only library. He might want to do that after the merge.
When using the UART sensor, you don't need the adafruit_bus_device library.
However, the following line in the library import what is required for the I2C version:
from adafruit_bus_device.i2c_device import I2CDevice
No big deal, and I have no clue how to do things better because all my idea seems to be worse that current situation (like putting the import on the I2C side or separating the two). Also I don't have the I2C version to test, so I could not really test a change on that side.
But it could be an improvement for user of UART sensor.