diff --git a/examples/bluetooth/ble_simple_central.py b/examples/bluetooth/ble_simple_central.py index f6996366e..f0a3297d3 100644 --- a/examples/bluetooth/ble_simple_central.py +++ b/examples/bluetooth/ble_simple_central.py @@ -74,7 +74,7 @@ class BLESimpleCentral: def _irq(self, event, data): if event == _IRQ_SCAN_RESULT: addr_type, addr, adv_type, rssi, adv_data = data - if adv_type in (_ADV_IND, _ADV_DIRECT_IND,) and _UART_SERVICE_UUID in decode_services( + if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _UART_SERVICE_UUID in decode_services( adv_data ): # Found a potential device, remember it and stop scanning. @@ -97,14 +97,14 @@ class BLESimpleCentral: elif event == _IRQ_PERIPHERAL_CONNECT: # Connect successful. - conn_handle, addr_type, addr, = data + conn_handle, addr_type, addr = data if addr_type == self._addr_type and addr == self._addr: self._conn_handle = conn_handle self._ble.gattc_discover_services(self._conn_handle) elif event == _IRQ_PERIPHERAL_DISCONNECT: # Disconnect (either initiated by us or the remote end). - conn_handle, _, _, = data + conn_handle, _, _ = data if conn_handle == self._conn_handle: # If it was initiated by us, it'll already be reset. self._reset() diff --git a/examples/bluetooth/ble_simple_peripheral.py b/examples/bluetooth/ble_simple_peripheral.py index 08cd7fa98..f5e766192 100644 --- a/examples/bluetooth/ble_simple_peripheral.py +++ b/examples/bluetooth/ble_simple_peripheral.py @@ -23,7 +23,7 @@ _UART_RX = ( ) _UART_SERVICE = ( _UART_UUID, - (_UART_TX, _UART_RX,), + (_UART_TX, _UART_RX), ) @@ -32,22 +32,20 @@ class BLESimplePeripheral: self._ble = ble self._ble.active(True) self._ble.irq(handler=self._irq) - ((self._handle_tx, self._handle_rx,),) = self._ble.gatts_register_services( - (_UART_SERVICE,) - ) + ((self._handle_tx, self._handle_rx),) = self._ble.gatts_register_services((_UART_SERVICE,)) self._connections = set() self._write_callback = None - self._payload = advertising_payload(name=name, services=[_UART_UUID],) + self._payload = advertising_payload(name=name, services=[_UART_UUID]) self._advertise() def _irq(self, event, data): # Track connections so we can send notifications. if event == _IRQ_CENTRAL_CONNECT: - conn_handle, _, _, = data + conn_handle, _, _ = data print("New connection", conn_handle) self._connections.add(conn_handle) elif event == _IRQ_CENTRAL_DISCONNECT: - conn_handle, _, _, = data + conn_handle, _, _ = data print("Disconnected", conn_handle) self._connections.remove(conn_handle) # Start advertising again to allow a new connection. diff --git a/examples/bluetooth/ble_temperature.py b/examples/bluetooth/ble_temperature.py index 0e2da2239..001a26b11 100644 --- a/examples/bluetooth/ble_temperature.py +++ b/examples/bluetooth/ble_temperature.py @@ -46,15 +46,15 @@ class BLETemperature: def _irq(self, event, data): # Track connections so we can send notifications. if event == _IRQ_CENTRAL_CONNECT: - conn_handle, _, _, = data + conn_handle, _, _ = data self._connections.add(conn_handle) elif event == _IRQ_CENTRAL_DISCONNECT: - conn_handle, _, _, = data + conn_handle, _, _ = data self._connections.remove(conn_handle) # Start advertising again to allow a new connection. self._advertise() elif event == _IRQ_GATTS_INDICATE_DONE: - conn_handle, value_handle, status, = data + conn_handle, value_handle, status = data def set_temperature(self, temp_deg_c, notify=False, indicate=False): # Data is sint16 in degrees Celsius with a resolution of 0.01 degrees Celsius. diff --git a/examples/bluetooth/ble_temperature_central.py b/examples/bluetooth/ble_temperature_central.py index f9db225c1..798303417 100644 --- a/examples/bluetooth/ble_temperature_central.py +++ b/examples/bluetooth/ble_temperature_central.py @@ -87,7 +87,7 @@ class BLETemperatureCentral: def _irq(self, event, data): if event == _IRQ_SCAN_RESULT: addr_type, addr, adv_type, rssi, adv_data = data - if adv_type in (_ADV_IND, _ADV_DIRECT_IND,) and _ENV_SENSE_UUID in decode_services( + if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _ENV_SENSE_UUID in decode_services( adv_data ): # Found a potential device, remember it and stop scanning. @@ -110,14 +110,14 @@ class BLETemperatureCentral: elif event == _IRQ_PERIPHERAL_CONNECT: # Connect successful. - conn_handle, addr_type, addr, = data + conn_handle, addr_type, addr = data if addr_type == self._addr_type and addr == self._addr: self._conn_handle = conn_handle self._ble.gattc_discover_services(self._conn_handle) elif event == _IRQ_PERIPHERAL_DISCONNECT: # Disconnect (either initiated by us or the remote end). - conn_handle, _, _, = data + conn_handle, _, _ = data if conn_handle == self._conn_handle: # If it was initiated by us, it'll already be reset. self._reset() diff --git a/examples/bluetooth/ble_uart_peripheral.py b/examples/bluetooth/ble_uart_peripheral.py index cc8d589b0..59b35f7e6 100644 --- a/examples/bluetooth/ble_uart_peripheral.py +++ b/examples/bluetooth/ble_uart_peripheral.py @@ -20,7 +20,7 @@ _UART_RX = ( ) _UART_SERVICE = ( _UART_UUID, - (_UART_TX, _UART_RX,), + (_UART_TX, _UART_RX), ) # org.bluetooth.characteristic.gap.appearance.xml @@ -32,9 +32,7 @@ class BLEUART: self._ble = ble self._ble.active(True) self._ble.irq(handler=self._irq) - ((self._tx_handle, self._rx_handle,),) = self._ble.gatts_register_services( - (_UART_SERVICE,) - ) + ((self._tx_handle, self._rx_handle),) = self._ble.gatts_register_services((_UART_SERVICE,)) # Increase the size of the rx buffer and enable append mode. self._ble.gatts_set_buffer(self._rx_handle, rxbuf, True) self._connections = set() @@ -50,16 +48,16 @@ class BLEUART: def _irq(self, event, data): # Track connections so we can send notifications. if event == _IRQ_CENTRAL_CONNECT: - conn_handle, _, _, = data + conn_handle, _, _ = data self._connections.add(conn_handle) elif event == _IRQ_CENTRAL_DISCONNECT: - conn_handle, _, _, = data + conn_handle, _, _ = data if conn_handle in self._connections: self._connections.remove(conn_handle) # Start advertising again to allow a new connection. self._advertise() elif event == _IRQ_GATTS_WRITE: - conn_handle, value_handle, = data + conn_handle, value_handle = data if conn_handle in self._connections and value_handle == self._rx_handle: self._rx_buffer += self._ble.gatts_read(self._rx_handle) if self._handler: diff --git a/extmod/webrepl/manifest.py b/extmod/webrepl/manifest.py index 6ce7d8546..6eceb3eeb 100644 --- a/extmod/webrepl/manifest.py +++ b/extmod/webrepl/manifest.py @@ -1 +1 @@ -freeze(".", ("webrepl.py", "webrepl_setup.py", "websocket_helper.py",)) +freeze(".", ("webrepl.py", "webrepl_setup.py", "websocket_helper.py")) diff --git a/ports/cc3200/boards/make-pins.py b/ports/cc3200/boards/make-pins.py index a204561cf..0cf0d5656 100644 --- a/ports/cc3200/boards/make-pins.py +++ b/ports/cc3200/boards/make-pins.py @@ -216,7 +216,10 @@ def main(): default="cc3200_af.csv", ) parser.add_argument( - "-b", "--board", dest="board_filename", help="Specifies the board file", + "-b", + "--board", + dest="board_filename", + help="Specifies the board file", ) parser.add_argument( "-p", diff --git a/ports/nrf/boards/make-pins.py b/ports/nrf/boards/make-pins.py index 56c56ae5f..347ed15b2 100644 --- a/ports/nrf/boards/make-pins.py +++ b/ports/nrf/boards/make-pins.py @@ -381,7 +381,10 @@ def main(): default="build/pins_af.py", ) parser.add_argument( - "-b", "--board", dest="board_filename", help="Specifies the board file", + "-b", + "--board", + dest="board_filename", + help="Specifies the board file", ) parser.add_argument( "-p", diff --git a/ports/stm32/boards/make-pins.py b/ports/stm32/boards/make-pins.py index 692387f40..a91ed8a2c 100755 --- a/ports/stm32/boards/make-pins.py +++ b/ports/stm32/boards/make-pins.py @@ -515,7 +515,10 @@ def main(): action="store_true", ) parser.add_argument( - "-b", "--board", dest="board_filename", help="Specifies the board file", + "-b", + "--board", + dest="board_filename", + help="Specifies the board file", ) parser.add_argument( "-p", diff --git a/ports/teensy/make-pins.py b/ports/teensy/make-pins.py index ddefae852..4e46a8c24 100755 --- a/ports/teensy/make-pins.py +++ b/ports/teensy/make-pins.py @@ -370,7 +370,10 @@ def main(): default="build/pins_af.py", ) parser.add_argument( - "-b", "--board", dest="board_filename", help="Specifies the board file", + "-b", + "--board", + dest="board_filename", + help="Specifies the board file", ) parser.add_argument( "-p", diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py index d718da6e0..612f3d29a 100644 --- a/py/makemoduledefs.py +++ b/py/makemoduledefs.py @@ -17,7 +17,7 @@ pattern = re.compile(r"[\n;]\s*MP_REGISTER_MODULE\((.*?),\s*(.*?),\s*(.*?)\);", def find_c_file(obj_file, vpath): - """ Search vpaths for the c file that matches the provided object_file. + """Search vpaths for the c file that matches the provided object_file. :param str obj_file: object file to find the matching c file for :param List[str] vpath: List of base paths, similar to gcc vpath @@ -36,7 +36,7 @@ def find_c_file(obj_file, vpath): def find_module_registrations(c_file): - """ Find any MP_REGISTER_MODULE definitions in the provided c file. + """Find any MP_REGISTER_MODULE definitions in the provided c file. :param str c_file: path to c file to check :return: List[(module_name, obj_module, enabled_define)] @@ -52,7 +52,7 @@ def find_module_registrations(c_file): def generate_module_table_header(modules): - """ Generate header with module table entries for builtin modules. + """Generate header with module table entries for builtin modules. :param List[(module_name, obj_module, enabled_define)] modules: module defs :return: None diff --git a/tests/extmod/uasyncio_gather.py b/tests/extmod/uasyncio_gather.py index 2697a6278..0e2948b07 100644 --- a/tests/extmod/uasyncio_gather.py +++ b/tests/extmod/uasyncio_gather.py @@ -34,7 +34,7 @@ async def gather_task(): async def main(): # Simple gather with return values - print(await asyncio.gather(factorial("A", 2), factorial("B", 3), factorial("C", 4),)) + print(await asyncio.gather(factorial("A", 2), factorial("B", 3), factorial("C", 4))) # Cancel a multi gather # TODO doesn't work, Task should not forward cancellation from gather to sub-task diff --git a/tests/extmod/uctypes_le.py b/tests/extmod/uctypes_le.py index 23f2af982..f69da30b6 100644 --- a/tests/extmod/uctypes_le.py +++ b/tests/extmod/uctypes_le.py @@ -6,7 +6,7 @@ except ImportError: desc = { "s0": uctypes.UINT16 | 0, - "sub": (0, {"b0": uctypes.UINT8 | 0, "b1": uctypes.UINT8 | 1,}), + "sub": (0, {"b0": uctypes.UINT8 | 0, "b1": uctypes.UINT8 | 1}), "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2), "arr2": (uctypes.ARRAY | 0, 2, {"b": uctypes.UINT8 | 0}), "bitf0": uctypes.BFUINT16 | 0 | 0 << uctypes.BF_POS | 8 << uctypes.BF_LEN, diff --git a/tests/extmod/uctypes_native_le.py b/tests/extmod/uctypes_native_le.py index c161539c6..7958e5c22 100644 --- a/tests/extmod/uctypes_native_le.py +++ b/tests/extmod/uctypes_native_le.py @@ -16,7 +16,7 @@ if sys.byteorder != "little": desc = { "s0": uctypes.UINT16 | 0, - "sub": (0, {"b0": uctypes.UINT8 | 0, "b1": uctypes.UINT8 | 1,}), + "sub": (0, {"b0": uctypes.UINT8 | 0, "b1": uctypes.UINT8 | 1}), "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2), "arr2": (uctypes.ARRAY | 0, 2, {"b": uctypes.UINT8 | 0}), "bitf0": uctypes.BFUINT16 | 0 | 0 << uctypes.BF_POS | 8 << uctypes.BF_LEN, diff --git a/tests/extmod/uctypes_sizeof_native.py b/tests/extmod/uctypes_sizeof_native.py index 352c191e0..157e554b0 100644 --- a/tests/extmod/uctypes_sizeof_native.py +++ b/tests/extmod/uctypes_sizeof_native.py @@ -28,7 +28,7 @@ S5 = { "b": uctypes.UINT32 | 4, "c": uctypes.UINT8 | 8, "d": uctypes.UINT32 | 0, - "sub": (4, {"b0": uctypes.UINT8 | 0, "b1": uctypes.UINT8 | 1,}), + "sub": (4, {"b0": uctypes.UINT8 | 0, "b1": uctypes.UINT8 | 1}), } assert uctypes.sizeof(S5) == 12 diff --git a/tests/float/cmath_fun.py b/tests/float/cmath_fun.py index 15b72e7a6..39011733b 100644 --- a/tests/float/cmath_fun.py +++ b/tests/float/cmath_fun.py @@ -22,7 +22,7 @@ for r in base_values: test_values_non_zero.append(complex(r, -i)) if r != 0.0 and i != 0.0: test_values_non_zero.append(complex(-r, -i)) -test_values = [complex(0.0, 0.0),] + test_values_non_zero +test_values = [complex(0.0, 0.0)] + test_values_non_zero print(test_values) functions = [ diff --git a/tests/float/math_fun.py b/tests/float/math_fun.py index 7b6bb8648..0d443a475 100644 --- a/tests/float/math_fun.py +++ b/tests/float/math_fun.py @@ -62,10 +62,10 @@ binary_functions = [ copysign, [(23.0, 42.0), (-23.0, 42.0), (23.0, -42.0), (-23.0, -42.0), (1.0, 0.0), (1.0, -0.0)], ), - ("pow", pow, ((1.0, 0.0), (0.0, 1.0), (2.0, 0.5), (-3.0, 5.0), (-3.0, -4.0),)), - ("atan2", atan2, ((1.0, 0.0), (0.0, 1.0), (2.0, 0.5), (-3.0, 5.0), (-3.0, -4.0),)), - ("fmod", fmod, ((1.0, 1.0), (0.0, 1.0), (2.0, 0.5), (-3.0, 5.0), (-3.0, -4.0),)), - ("ldexp", ldexp, ((1.0, 0), (0.0, 1), (2.0, 2), (3.0, -2), (-3.0, -4),)), + ("pow", pow, ((1.0, 0.0), (0.0, 1.0), (2.0, 0.5), (-3.0, 5.0), (-3.0, -4.0))), + ("atan2", atan2, ((1.0, 0.0), (0.0, 1.0), (2.0, 0.5), (-3.0, 5.0), (-3.0, -4.0))), + ("fmod", fmod, ((1.0, 1.0), (0.0, 1.0), (2.0, 0.5), (-3.0, 5.0), (-3.0, -4.0))), + ("ldexp", ldexp, ((1.0, 0), (0.0, 1), (2.0, 2), (3.0, -2), (-3.0, -4))), ( "log", log, diff --git a/tests/float/math_fun_special.py b/tests/float/math_fun_special.py index c101a7e50..614470c0f 100644 --- a/tests/float/math_fun_special.py +++ b/tests/float/math_fun_special.py @@ -40,7 +40,7 @@ functions = [ ("erf", erf, test_values), ("erfc", erfc, test_values), ("gamma", gamma, pos_test_values), - ("lgamma", lgamma, pos_test_values + [50.0, 100.0,]), + ("lgamma", lgamma, pos_test_values + [50.0, 100.0]), ] for function_name, function, test_vals in functions: diff --git a/tools/mpy_ld.py b/tools/mpy_ld.py index 32bc176cb..774966a7f 100755 --- a/tools/mpy_ld.py +++ b/tools/mpy_ld.py @@ -908,7 +908,7 @@ def build_mpy(env, entry_offset, fmpy, native_qstr_vals, native_qstr_objs): # MPY: header out.write_bytes( bytearray( - [ord("M"), MPY_VERSION, env.arch.mpy_feature, MP_SMALL_INT_BITS, QSTR_WINDOW_SIZE,] + [ord("M"), MPY_VERSION, env.arch.mpy_feature, MP_SMALL_INT_BITS, QSTR_WINDOW_SIZE] ) )