Closed Ferroin closed 4 years ago
hiya, if you'd like to submit a PR for an update, we'd love to have one - note that this code must be able to run on CircuitPython boards that have very limited RAM
@Ferroin That would be awesome to add! Let me know if you have any questions on how to do it or test it.
@tannewt Testing should be the only issue (I'm a bit out of practice with Python in general, but that shouldn't be a problem for something like this). I've never worked with CircuitPython myself (as mentioned in the issue description, this was prompted by a PR for Netdata to add a data collector that uses this module), so I'm not sure where exactly the best place to begin would be.
Here is a guide on how to use the sensor: https://learn.adafruit.com/adafruit-am2320-temperature-humidity-i2c-sensor/python-circuitpython
Adding the custom exceptions should be the same as CPython so it's ok to only test in CPython with Blinka.
Prompted by: https://github.com/netdata/netdata/pull/7024
This module appears to directly raise
ValueError
andRuntimeError
under specific circumstances. While both are technically accurate, they necessitate use of overly broadexcept
clauses when dealing with error handling for the module, which makes it difficult to verify that code using the module is actually correct and can't accidentally hide other errors. TheRuntimeError
usage is particularly problematic, as it's very rare in the core language to ever catch aRuntimeError
, so any code that catches one tends to look rather out of place to many people.I would suggest switching to the same methodology that's used by much of the Python ecosystem of defining local sub-classes of
Exception
(or whatever specific error makes sense) and raising those instead of directly raising built-in exception types.