-
Notifications
You must be signed in to change notification settings - Fork 1.1k
drivers/sensor/dht: Change the sequence for importing dht_readinto. #557
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
Conversation
Check the machine module first, then search in previous places.
I'm not sure what this achieves? One thing it does do is make the code bigger with the additional error message 😄
Probably best to just move all dht_readinto methods on the ports into machine, and then make this module just do from machine import dht_readinto unconditionally.
The intention is legacy, such that the 'new' dht.py works with previous versions of the firmwarem, at least for a while.
Oh, I see! Yes that makes sense then.
Probably good to add a comment then, why the older imports are there.
Also, except for the esp case, the port-specific cases can actually be combined to:
dht_readinto = __import__(sys.platform).dht_readinto
As @dpgeorge suggested. If the import fails, the error message is somewhat cryptic. It says: `AttributeError: no such attribute` But that's anyhow only a transitional state of the driver.
Squashed and merged in 0e25b10
Check the machine module first, then try the port specific places.