Skip to content

Commit

Permalink
top: Update Python formatting to black "2023 stable style".
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmo committed Feb 2, 2023
1 parent fe2a833 commit 8b27482
Show file tree
Hide file tree
Showing 75 changed files with 207 additions and 122 deletions.
1 change: 0 additions & 1 deletion examples/SDdatalogger/datalogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# loop
while True:

# wait for interrupt
# this reduces power consumption while waiting for switch press
pyb.wfi()
Expand Down
2 changes: 0 additions & 2 deletions examples/asmsum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@micropython.asm_thumb
def asm_sum_words(r0, r1):

# r0 = len
# r1 = ptr
# r2 = sum
Expand All @@ -25,7 +24,6 @@ def asm_sum_words(r0, r1):

@micropython.asm_thumb
def asm_sum_bytes(r0, r1):

# r0 = len
# r1 = ptr
# r2 = sum
Expand Down
1 change: 1 addition & 0 deletions examples/bluetooth/ble_uart_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
else:
_timer = None


# Batch writes into 50ms intervals.
def schedule_in(handler, delay_ms):
def _wrap(_arg):
Expand Down
1 change: 1 addition & 0 deletions examples/conwaylife.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
lcd = pyb.LCD("x")
lcd.light(1)


# do 1 iteration of Conway's Game of Life
def conway_step():
for x in range(128): # loop over x coordinates
Expand Down
1 change: 1 addition & 0 deletions examples/rp2/pio_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from machine import Pin
import rp2


# Define an empty program that uses a single set pin.
@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
def prog():
Expand Down
1 change: 1 addition & 0 deletions examples/rp2/pio_uart_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def uart_tx():
sm.active(1)
uarts.append(sm)


# We can print characters from each UART by pushing them to the TX FIFO
def pio_uart_print(sm, s):
for c in s:
Expand Down
1 change: 1 addition & 0 deletions extmod/uasyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"StreamWriter": "stream",
}


# Lazy loader, effectively does:
# global attr
# from .mod import attr
Expand Down
2 changes: 2 additions & 0 deletions extmod/uasyncio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TimeoutError(Exception):
################################################################################
# Sleep functions


# "Yield" once, then raise StopIteration
class SingletonGenerator:
def __init__(self):
Expand Down Expand Up @@ -132,6 +133,7 @@ def wait_io_event(self, dt):
################################################################################
# Main run loop


# Ensure the awaitable is a task
def _promote_to_task(aw):
return aw if isinstance(aw, Task) else create_task(aw)
Expand Down
1 change: 1 addition & 0 deletions extmod/uasyncio/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import core


# Event class for primitive events that can be waited on, set, and cleared
class Event:
def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions extmod/uasyncio/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import core


# Lock class for primitive mutex capability
class Lock:
def __init__(self):
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/boards/UM_FEATHERS2/modules/feathers2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

# Helper functions


# LED & Ambient Light Sensor control
def set_led(state):
l = Pin(LED, Pin.OUT)
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/boards/UM_FEATHERS2NEO/modules/feathers2neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
DAC1 = const(17)
DAC2 = const(18)


# Helper functions
def set_pixel_power(state):
"""Enable or Disable power to the onboard NeoPixel to either show colour, or to reduce power for deep sleep."""
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/boards/UM_FEATHERS3/modules/feathers3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

# Helper functions


# LED & Ambient Light Sensor control
def led_set(state):
"""Set the state of the BLUE LED on IO13"""
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/boards/UM_PROS3/modules/pros3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
I2C_SDA = const(8)
I2C_SCL = const(9)


# Helper functions
def set_ldo2_power(state):
"""Enable or Disable power to the second LDO"""
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/boards/UM_TINYPICO/modules/tinypico.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

# Helper functions


# Get a *rough* estimate of the current battery voltage
# If the battery is not present, the charge IC will still report it's trying to charge at X voltage
# so it will still show a voltage.
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/boards/UM_TINYS3/modules/tinys3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
I2C_SDA = const(8)
I2C_SCL = const(9)


# Helper functions
def set_pixel_power(state):
"""Enable or Disable power to the onboard NeoPixel to either show colour, or to reduce power for deep sleep."""
Expand Down
1 change: 0 additions & 1 deletion ports/esp8266/makeimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
md5 = hashlib.md5()

with open(sys.argv[3], "wb") as fout:

with open(sys.argv[1], "rb") as f:
data_flash = f.read()
fout.write(data_flash)
Expand Down
1 change: 0 additions & 1 deletion ports/esp8266/modules/port_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


def main():

ROM = uctypes.bytearray_at(0x40200000, 16)
fid = esp.flash_id()

Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/boards/make-flexram-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"""
ocram_min_size = 0x00010000 # 64 KB


# Value parser
def mimxrt_default_parser(defines_file, features_file, ld_script):
with open(ld_script, "r") as input_file:
Expand Down
1 change: 0 additions & 1 deletion ports/nrf/examples/powerup.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def loop(self):
self.old_speed = 0

while True:

time.sleep_ms(100)

# read out new angle
Expand Down
1 change: 0 additions & 1 deletion ports/stm32/boards/NUCLEO_WB55/rfcore_makefirmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def get_details(release_notes, filename):


def main(src_path, dest_path):

# Load the release note to parse for important details
with open(os.path.join(src_path, _RELEASE_NOTES), "rb") as f:
release_notes = f.read()
Expand Down
1 change: 0 additions & 1 deletion ports/stm32/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ def print_af_hdr(self, af_const_filename):

def print_af_defs(self, af_defs_filename, cmp_strings):
with open(af_defs_filename, "wt") as af_defs_file:

STATIC_AF_TOKENS = {}
for named_pin in self.cpu_pins:
for af in named_pin.pin().alt_fn:
Expand Down
1 change: 1 addition & 0 deletions ports/stm32/make-stmconst.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def convert_bytes_to_str(b):

# end compatibility code


# given a list of (name,regex) pairs, find the first one that matches the given line
def re_match_first(regexs, line):
for name, regex in regexs:
Expand Down
1 change: 1 addition & 0 deletions py/makeqstrdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
"zip",
]


# this must match the equivalent function in qstr.c
def compute_hash(qstr, bytes_hash):
hash = 5381
Expand Down
1 change: 1 addition & 0 deletions tests/esp32/esp32_idf_heap_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
print("SKIP")
raise SystemExit


# region tuple is: (size, free, largest free, min free)
# we check that each region's size is > 0 and that the free amounts are smaller than the size
def chk_heap(kind, regions):
Expand Down
1 change: 1 addition & 0 deletions tests/extmod/framebuf_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def foo(self):
fb2.blit(fb, 0, 0)
print(bytes(fb2))


# Test that blitting something that isn't a subclass fails with TypeError.
class NotAFrameBuf:
pass
Expand Down
3 changes: 3 additions & 0 deletions tests/extmod/uasyncio_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
print("SKIP")
raise SystemExit


# main task raising an exception
async def main():
print("main start")
Expand All @@ -21,6 +22,7 @@ async def main():
except ValueError as er:
print("ValueError", er.args[0])


# sub-task raising an exception
async def task():
print("task start")
Expand All @@ -40,6 +42,7 @@ async def main():
except ValueError as er:
print("ValueError", er.args[0])


# main task raising an exception with sub-task not yet scheduled
# TODO not currently working, task is never scheduled
async def task():
Expand Down
1 change: 0 additions & 1 deletion tests/extmod/vfs_fat_fileio1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class RAMFS:

SEC_SIZE = 512

def __init__(self, blocks):
Expand Down
1 change: 0 additions & 1 deletion tests/extmod/vfs_fat_fileio2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class RAMFS:

SEC_SIZE = 512

def __init__(self, blocks):
Expand Down
1 change: 0 additions & 1 deletion tests/extmod/vfs_fat_more.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class RAMFS:

SEC_SIZE = 512

def __init__(self, blocks):
Expand Down
1 change: 0 additions & 1 deletion tests/extmod/vfs_fat_oldproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class RAMFS_OLD:

SEC_SIZE = 512

def __init__(self, blocks):
Expand Down
1 change: 0 additions & 1 deletion tests/extmod/vfs_fat_ramdisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class RAMFS:

SEC_SIZE = 512

def __init__(self, blocks):
Expand Down
1 change: 0 additions & 1 deletion tests/extmod/vfs_fat_ramdisklarge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class RAMBDevSparse:

SEC_SIZE = 512

def __init__(self, blocks):
Expand Down
1 change: 1 addition & 0 deletions tests/extmod/websocket_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
print("SKIP")
raise SystemExit


# put raw data in the stream and do a websocket read
def ws_read(msg, sz):
ws = uwebsocket.websocket(uio.BytesIO(msg))
Expand Down
1 change: 1 addition & 0 deletions tests/import/module_getattr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
except AttributeError:
pass


# define __getattr__
def __getattr__(attr):
if attr == "does_not_exist":
Expand Down
2 changes: 0 additions & 2 deletions tests/inlineasm/asmsum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@micropython.asm_thumb
def asm_sum_words(r0, r1):

# r0 = len
# r1 = ptr
# r2 = sum
Expand All @@ -25,7 +24,6 @@ def asm_sum_words(r0, r1):

@micropython.asm_thumb
def asm_sum_bytes(r0, r1):

# r0 = len
# r1 = ptr
# r2 = sum
Expand Down
4 changes: 4 additions & 0 deletions tests/micropython/const2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@

print(globals()["X"])


# function name that matches a constant
def X():
print("function X", X)


globals()["X"]()


# arguments that match a constant
def f(X, *Y, **Z):
pass


f(1)


# class name that matches a constant
class X:
def f(self):
Expand All @@ -33,6 +36,7 @@ def f(self):

globals()["X"]().f()


# constant within a class
class A:
C1 = const(4)
Expand Down
2 changes: 2 additions & 0 deletions tests/micropython/heapalloc_yield_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import micropython


# Yielding from a function generator
def sub_gen(a):
for i in range(a):
Expand All @@ -18,6 +19,7 @@ def gen(g):
print(next(g))
micropython.heap_unlock()


# Yielding from a user iterator
class G:
def __init__(self):
Expand Down
3 changes: 3 additions & 0 deletions tests/micropython/native_closure.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# test native emitter can handle closures correctly


# basic closure
@micropython.native
def f():
Expand All @@ -15,6 +16,7 @@ def g():

print(f()())


# closing over an argument
@micropython.native
def f(x):
Expand All @@ -28,6 +30,7 @@ def g():

print(f(2)())


# closing over an argument and a normal local
@micropython.native
def f(x):
Expand Down
Loading

0 comments on commit 8b27482

Please sign in to comment.