Skip to content

Commit 0665907

Browse files
committed
all: Update Python code to conform to latest black formatting.
Updating to Black v20.8b1 there are two changes that affect the code in this repository: - If there is a trailing comma in a list (eg [], () or function call) then that list is now written out with one line per element. So remove such trailing commas where the list should stay on one line. - Spaces at the start of """ doc strings are removed. Signed-off-by: Damien George <damien@micropython.org>
1 parent 0c7354a commit 0665907

19 files changed

Lines changed: 50 additions & 42 deletions

examples/bluetooth/ble_simple_central.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _reset(self):
7474
def _irq(self, event, data):
7575
if event == _IRQ_SCAN_RESULT:
7676
addr_type, addr, adv_type, rssi, adv_data = data
77-
if adv_type in (_ADV_IND, _ADV_DIRECT_IND,) and _UART_SERVICE_UUID in decode_services(
77+
if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _UART_SERVICE_UUID in decode_services(
7878
adv_data
7979
):
8080
# Found a potential device, remember it and stop scanning.
@@ -97,14 +97,14 @@ def _irq(self, event, data):
9797

9898
elif event == _IRQ_PERIPHERAL_CONNECT:
9999
# Connect successful.
100-
conn_handle, addr_type, addr, = data
100+
conn_handle, addr_type, addr = data
101101
if addr_type == self._addr_type and addr == self._addr:
102102
self._conn_handle = conn_handle
103103
self._ble.gattc_discover_services(self._conn_handle)
104104

105105
elif event == _IRQ_PERIPHERAL_DISCONNECT:
106106
# Disconnect (either initiated by us or the remote end).
107-
conn_handle, _, _, = data
107+
conn_handle, _, _ = data
108108
if conn_handle == self._conn_handle:
109109
# If it was initiated by us, it'll already be reset.
110110
self._reset()

examples/bluetooth/ble_simple_peripheral.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424
_UART_SERVICE = (
2525
_UART_UUID,
26-
(_UART_TX, _UART_RX,),
26+
(_UART_TX, _UART_RX),
2727
)
2828

2929

@@ -32,22 +32,20 @@ def __init__(self, ble, name="mpy-uart"):
3232
self._ble = ble
3333
self._ble.active(True)
3434
self._ble.irq(handler=self._irq)
35-
((self._handle_tx, self._handle_rx,),) = self._ble.gatts_register_services(
36-
(_UART_SERVICE,)
37-
)
35+
((self._handle_tx, self._handle_rx),) = self._ble.gatts_register_services((_UART_SERVICE,))
3836
self._connections = set()
3937
self._write_callback = None
40-
self._payload = advertising_payload(name=name, services=[_UART_UUID],)
38+
self._payload = advertising_payload(name=name, services=[_UART_UUID])
4139
self._advertise()
4240

4341
def _irq(self, event, data):
4442
# Track connections so we can send notifications.
4543
if event == _IRQ_CENTRAL_CONNECT:
46-
conn_handle, _, _, = data
44+
conn_handle, _, _ = data
4745
print("New connection", conn_handle)
4846
self._connections.add(conn_handle)
4947
elif event == _IRQ_CENTRAL_DISCONNECT:
50-
conn_handle, _, _, = data
48+
conn_handle, _, _ = data
5149
print("Disconnected", conn_handle)
5250
self._connections.remove(conn_handle)
5351
# Start advertising again to allow a new connection.

examples/bluetooth/ble_temperature.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def __init__(self, ble, name="mpy-temp"):
4646
def _irq(self, event, data):
4747
# Track connections so we can send notifications.
4848
if event == _IRQ_CENTRAL_CONNECT:
49-
conn_handle, _, _, = data
49+
conn_handle, _, _ = data
5050
self._connections.add(conn_handle)
5151
elif event == _IRQ_CENTRAL_DISCONNECT:
52-
conn_handle, _, _, = data
52+
conn_handle, _, _ = data
5353
self._connections.remove(conn_handle)
5454
# Start advertising again to allow a new connection.
5555
self._advertise()
5656
elif event == _IRQ_GATTS_INDICATE_DONE:
57-
conn_handle, value_handle, status, = data
57+
conn_handle, value_handle, status = data
5858

5959
def set_temperature(self, temp_deg_c, notify=False, indicate=False):
6060
# Data is sint16 in degrees Celsius with a resolution of 0.01 degrees Celsius.

examples/bluetooth/ble_temperature_central.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _reset(self):
8787
def _irq(self, event, data):
8888
if event == _IRQ_SCAN_RESULT:
8989
addr_type, addr, adv_type, rssi, adv_data = data
90-
if adv_type in (_ADV_IND, _ADV_DIRECT_IND,) and _ENV_SENSE_UUID in decode_services(
90+
if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _ENV_SENSE_UUID in decode_services(
9191
adv_data
9292
):
9393
# Found a potential device, remember it and stop scanning.
@@ -110,14 +110,14 @@ def _irq(self, event, data):
110110

111111
elif event == _IRQ_PERIPHERAL_CONNECT:
112112
# Connect successful.
113-
conn_handle, addr_type, addr, = data
113+
conn_handle, addr_type, addr = data
114114
if addr_type == self._addr_type and addr == self._addr:
115115
self._conn_handle = conn_handle
116116
self._ble.gattc_discover_services(self._conn_handle)
117117

118118
elif event == _IRQ_PERIPHERAL_DISCONNECT:
119119
# Disconnect (either initiated by us or the remote end).
120-
conn_handle, _, _, = data
120+
conn_handle, _, _ = data
121121
if conn_handle == self._conn_handle:
122122
# If it was initiated by us, it'll already be reset.
123123
self._reset()

examples/bluetooth/ble_uart_peripheral.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121
_UART_SERVICE = (
2222
_UART_UUID,
23-
(_UART_TX, _UART_RX,),
23+
(_UART_TX, _UART_RX),
2424
)
2525

2626
# org.bluetooth.characteristic.gap.appearance.xml
@@ -32,9 +32,7 @@ def __init__(self, ble, name="mpy-uart", rxbuf=100):
3232
self._ble = ble
3333
self._ble.active(True)
3434
self._ble.irq(handler=self._irq)
35-
((self._tx_handle, self._rx_handle,),) = self._ble.gatts_register_services(
36-
(_UART_SERVICE,)
37-
)
35+
((self._tx_handle, self._rx_handle),) = self._ble.gatts_register_services((_UART_SERVICE,))
3836
# Increase the size of the rx buffer and enable append mode.
3937
self._ble.gatts_set_buffer(self._rx_handle, rxbuf, True)
4038
self._connections = set()
@@ -50,16 +48,16 @@ def irq(self, handler):
5048
def _irq(self, event, data):
5149
# Track connections so we can send notifications.
5250
if event == _IRQ_CENTRAL_CONNECT:
53-
conn_handle, _, _, = data
51+
conn_handle, _, _ = data
5452
self._connections.add(conn_handle)
5553
elif event == _IRQ_CENTRAL_DISCONNECT:
56-
conn_handle, _, _, = data
54+
conn_handle, _, _ = data
5755
if conn_handle in self._connections:
5856
self._connections.remove(conn_handle)
5957
# Start advertising again to allow a new connection.
6058
self._advertise()
6159
elif event == _IRQ_GATTS_WRITE:
62-
conn_handle, value_handle, = data
60+
conn_handle, value_handle = data
6361
if conn_handle in self._connections and value_handle == self._rx_handle:
6462
self._rx_buffer += self._ble.gatts_read(self._rx_handle)
6563
if self._handler:

extmod/webrepl/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
freeze(".", ("webrepl.py", "webrepl_setup.py", "websocket_helper.py",))
1+
freeze(".", ("webrepl.py", "webrepl_setup.py", "websocket_helper.py"))

ports/cc3200/boards/make-pins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ def main():
216216
default="cc3200_af.csv",
217217
)
218218
parser.add_argument(
219-
"-b", "--board", dest="board_filename", help="Specifies the board file",
219+
"-b",
220+
"--board",
221+
dest="board_filename",
222+
help="Specifies the board file",
220223
)
221224
parser.add_argument(
222225
"-p",

ports/nrf/boards/make-pins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,10 @@ def main():
381381
default="build/pins_af.py",
382382
)
383383
parser.add_argument(
384-
"-b", "--board", dest="board_filename", help="Specifies the board file",
384+
"-b",
385+
"--board",
386+
dest="board_filename",
387+
help="Specifies the board file",
385388
)
386389
parser.add_argument(
387390
"-p",

ports/stm32/boards/make-pins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,10 @@ def main():
515515
action="store_true",
516516
)
517517
parser.add_argument(
518-
"-b", "--board", dest="board_filename", help="Specifies the board file",
518+
"-b",
519+
"--board",
520+
dest="board_filename",
521+
help="Specifies the board file",
519522
)
520523
parser.add_argument(
521524
"-p",

ports/teensy/make-pins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ def main():
370370
default="build/pins_af.py",
371371
)
372372
parser.add_argument(
373-
"-b", "--board", dest="board_filename", help="Specifies the board file",
373+
"-b",
374+
"--board",
375+
dest="board_filename",
376+
help="Specifies the board file",
374377
)
375378
parser.add_argument(
376379
"-p",

0 commit comments

Comments
 (0)