Originally, black_bindings found each contiguous "//|" block and sent
it to black independently. This was slower than it needed to be.
Instead, swap the comment prefix: when running black, take off
"//|" prefixes and put "##|" prefixes on all un-prefixed lines.
Then, after black is run, do the opposite operation
This more than doubles the overall speed of "pre-commit run --all",
from 3m20s to 55s CPU time on my local machine (32.5s to under 10s
"elapsed" time)
It also causes a small amount of churn in the bindings, because
black now sees enough context to know whether one 'def' follows another
or ends the 'def's in a 'class'. In the latter case, it adds an extra
newline, which becomes a "//|" line.
I'm less sure why a trailing comma was omitted before down in
rp2pio/StateMachine.c but let's roll with it.
This pulls all common functionality into `shared-bindings` and keeps
platform-specific code inside `nrf`. Additionally, this performs most
validation in the `shared-bindings` site.
The only validation that occurs inside platform-specific `common-hal`
code is related to timeout limits that are platform-specific.
Additionally, all documentation is now inside the `shared-bindings`
directory.
Signed-off-by: Sean Cross <sean@xobs.io>
With this patch, the exception can now be caught:
import microcontroller
import watchdog
import time
wdt = microcontroller.watchdog
wdt.timeout = 5
while True:
wdt.mode = watchdog.WatchDogMode.RAISE
print("Starting loop -- should exit after five seconds")
try:
while True:
time.sleep(10)
# pass # This also works for a spinloop
except watchdog.WatchDogTimeout as e:
print("Watchdog Expired (PASS)")
except Exception as e:
print("Other exception (FAIL)")
print("Exited loop")
This prints:
Starting loop -- should exit after five seconds
Watchdog Expired (PASS)
Starting loop -- should exit after five seconds
Watchdog Expired (PASS)
Starting loop -- should exit after five seconds
Watchdog Expired (PASS)
Signed-off-by: Sean Cross <sean@xobs.io>