pigweed.json: Switch Python formatter to black
Bug: b/261025545
Change-Id: I1a57294277a5882707689d99884c8d06e12ab55b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/experimental/+/191130
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Erik Gilling <konkers@google.com>
diff --git a/WORKSPACE b/WORKSPACE
index 039c2c8..4b133d8 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -75,8 +75,6 @@
load(
"@pigweed//pw_env_setup/bazel/cipd_setup:cipd_rules.bzl",
"cipd_client_repository",
- "cipd_repository",
- "pigweed_deps",
)
cipd_client_repository()
diff --git a/applications/tls_example/time_injection/generate_time_code.py b/applications/tls_example/time_injection/generate_time_code.py
index 85094fe..cef9fca 100644
--- a/applications/tls_example/time_injection/generate_time_code.py
+++ b/applications/tls_example/time_injection/generate_time_code.py
@@ -88,8 +88,11 @@
header.write(FUNCTION)
header.write("\n")
- subprocess.run([
- "clang-format",
- "-i",
- args.out,
- ], check=True)
+ subprocess.run(
+ [
+ "clang-format",
+ "-i",
+ args.out,
+ ],
+ check=True,
+ )
diff --git a/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py b/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py
index cd3290b..53a9684 100644
--- a/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py
+++ b/applications/tls_example/trust_store/py/trust_store_generation/generate_trust_store.py
@@ -72,19 +72,21 @@
"""Setup argparse."""
parser = argparse.ArgumentParser()
parser.add_argument("out", help="output header")
- parser.add_argument("--root_cert",
- "-r",
- help="root CA certificate",
- action="append")
+ parser.add_argument(
+ "--root_cert", "-r", help="root CA certificate", action="append"
+ )
return parser.parse_args()
def generate_c_array_declaration(data, var_name):
"""Generate a C array declaration for a byte data"""
- return "".join([
- f'const unsigned char {var_name}[] = {{',
- " ".join([f'0x{b:x},' for b in data]), "};"
- ])
+ return "".join(
+ [
+ f'const unsigned char {var_name}[] = {{',
+ " ".join([f'0x{b:x},' for b in data]),
+ "};",
+ ]
+ )
def load_certificate_file(file):
@@ -114,11 +116,13 @@
header.write(LICENSE_HEADER)
header.write('#include "pw_span/span.h"\n\n')
certs = args.root_cert if args.root_cert else []
- cert_collection_array = "".join([
- "const ",
- "pw::span<const unsigned char>",
- "kRootCerts[] = {",
- ])
+ cert_collection_array = "".join(
+ [
+ "const ",
+ "pw::span<const unsigned char>",
+ "kRootCerts[] = {",
+ ]
+ )
header.write("namespace {\n\n")
for i, cert in enumerate(certs):
var_name = f'kRootCACert_{i}'
@@ -136,11 +140,14 @@
header.write(ROOT_CERT_API_FUNC)
header.write("\n\n")
- subprocess.run([
- "clang-format",
- "-i",
- args.out,
- ], check=True)
+ subprocess.run(
+ [
+ "clang-format",
+ "-i",
+ args.out,
+ ],
+ check=True,
+ )
if __name__ == "__main__":
diff --git a/pigweed.json b/pigweed.json
index a4d8182..1d504ae 100644
--- a/pigweed.json
+++ b/pigweed.json
@@ -41,6 +41,7 @@
},
"pw_presubmit": {
"format": {
+ "python_formatter": "black",
"exclude": [
"\\bthird_party/",
"^patches\\.json$"
diff --git a/pw_graphics/py/pw_graphics/png2cc.py b/pw_graphics/py/pw_graphics/png2cc.py
index fbf1119..d4e1a0a 100755
--- a/pw_graphics/py/pw_graphics/png2cc.py
+++ b/pw_graphics/py/pw_graphics/png2cc.py
@@ -33,7 +33,9 @@
# Load templates automatically from pw_graphics/templates
loader=DictLoader(jinja_templates),
# Raise errors if variables are undefined in templates
- undefined=make_logging_undefined(logger=logging.getLogger(__package__), ),
+ undefined=make_logging_undefined(
+ logger=logging.getLogger(__package__),
+ ),
# Trim whitespace in templates
trim_blocks=True,
lstrip_blocks=True,
@@ -44,31 +46,27 @@
"""Setup argparse."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('IMAGE', type=Path, help="Input image. ")
- parser.add_argument('-W',
- '--sprite-width',
- type=int,
- required=True,
- help='Sprite width.')
- parser.add_argument('-H',
- '--sprite-height',
- type=int,
- required=True,
- help='Sprite height.')
- parser.add_argument('--output-mode',
- default='rgb565',
- choices=['rgb565', 'font'],
- help='')
+ parser.add_argument(
+ '-W', '--sprite-width', type=int, required=True, help='Sprite width.'
+ )
+ parser.add_argument(
+ '-H', '--sprite-height', type=int, required=True, help='Sprite height.'
+ )
+ parser.add_argument(
+ '--output-mode', default='rgb565', choices=['rgb565', 'font'], help=''
+ )
parser.add_argument(
'--transparent-color',
default='255,0,255',
- help='Comma separated r,g,b values to use as transparent.')
+ help='Comma separated r,g,b values to use as transparent.',
+ )
return parser.parse_args()
def rgb8888to565(rgba8888):
- red = ((rgba8888 & 0xFF0000) >> 16)
- green = ((rgba8888 & 0xFF00) >> 8)
- blue = ((rgba8888 & 0xFF))
+ red = (rgba8888 & 0xFF0000) >> 16
+ green = (rgba8888 & 0xFF00) >> 8
+ blue = rgba8888 & 0xFF
return rgb565(red, green, blue)
@@ -98,7 +96,8 @@
hex_g = f"{pix[1]:02x}"
hex_b = f"{pix[2]:02x}"
sprite_data[-1].append(
- f"{hex_rgb565:#04x}, // #{hex_r}{hex_g}{hex_b}\n")
+ f"{hex_rgb565:#04x}, // #{hex_r}{hex_g}{hex_b}\n"
+ )
return sprite_data
@@ -160,13 +159,21 @@
tile_height = max(tile_height, 1)
if args.output_mode == 'rgb565':
- sprite_data = render_rgb565_header(alpha_composite, tile_width,
- tile_height, sprite_width,
- sprite_height)
+ sprite_data = render_rgb565_header(
+ alpha_composite,
+ tile_width,
+ tile_height,
+ sprite_width,
+ sprite_height,
+ )
elif args.output_mode == 'font':
- sprite_data = render_font_header(alpha_composite, tile_width,
- tile_height, sprite_width,
- sprite_height)
+ sprite_data = render_font_header(
+ alpha_composite,
+ tile_width,
+ tile_height,
+ sprite_width,
+ sprite_height,
+ )
template = jinja_env.get_template(args.output_mode + '.jinja')
out_path.write_text(
@@ -177,7 +184,8 @@
sprite_height=sprite_height,
transparent_color=f"{transparent_color_int:#04x}",
count=len(sprite_data),
- ))
+ )
+ )
if __name__ == '__main__':
diff --git a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/stm32f769i_detector.py b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/stm32f769i_detector.py
index 6db17fb..73093b8 100644
--- a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/stm32f769i_detector.py
+++ b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/stm32f769i_detector.py
@@ -24,13 +24,14 @@
# Vendor/device ID to search for in USB devices.
# Note the STM32F429I-DISC1 and the STM32F769I-DISC0 have the same vendor/model.
_ST_VENDOR_ID = 0x0483
-_DISCOVERY_MODEL_ID = 0x374b
+_DISCOVERY_MODEL_ID = 0x374B
_LOG = logging.getLogger('stm32f769i_detector')
class BoardInfo(typing.NamedTuple):
"""Information about a connected dev board."""
+
dev_name: str
serial_number: Optional[str]
@@ -42,8 +43,8 @@
for dev in all_devs:
if dev.vid == _ST_VENDOR_ID and dev.pid == _DISCOVERY_MODEL_ID:
boards.append(
- BoardInfo(dev_name=dev.device,
- serial_number=dev.serial_number))
+ BoardInfo(dev_name=dev.device, serial_number=dev.serial_number)
+ )
return boards
@@ -53,18 +54,14 @@
# Try to use pw_cli logs, else default to something reasonable.
try:
import pw_cli.log # pylint: disable=import-outside-toplevel
+
pw_cli.log.install()
except ImportError:
- coloredlogs.install(level='INFO',
- level_styles={
- 'debug': {
- 'color': 244
- },
- 'error': {
- 'color': 'red'
- }
- },
- fmt='%(asctime)s %(levelname)s | %(message)s')
+ coloredlogs.install(
+ level='INFO',
+ level_styles={'debug': {'color': 244}, 'error': {'color': 'red'}},
+ fmt='%(asctime)s %(levelname)s | %(message)s',
+ )
boards = detect_boards()
if not boards:
diff --git a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_client.py b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_client.py
index e10b8c8..e123bf0 100755
--- a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_client.py
+++ b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_client.py
@@ -27,9 +27,9 @@
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('binary', help='The target test binary to run')
- parser.add_argument('--server-port',
- type=int,
- help='Port the test server is located on')
+ parser.add_argument(
+ '--server-port', type=int, help='Port the test server is located on'
+ )
return parser.parse_args()
diff --git a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_runner.py b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_runner.py
index 066b3e1..bca3eaf 100755
--- a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_runner.py
+++ b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_runner.py
@@ -34,8 +34,8 @@
# Path to scripts provided by openocd.
_OPENOCD_SCRIPTS_DIR = os.path.join(
- os.getenv('PW_PIGWEED_CIPD_INSTALL_DIR', ''), 'share', 'openocd',
- 'scripts')
+ os.getenv('PW_PIGWEED_CIPD_INSTALL_DIR', ''), 'share', 'openocd', 'scripts'
+)
_LOG = logging.getLogger('unit_test_runner')
@@ -65,32 +65,43 @@
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('binary', help='The target test binary to run')
- parser.add_argument('--openocd-config',
- default=_OPENOCD_CONFIG,
- help='Path to openocd configuration file')
- parser.add_argument('--stlink-serial',
- default=None,
- help='The serial number of the stlink to use when '
- 'flashing the target device')
- parser.add_argument('--port',
- default=None,
- help='The name of the serial port to connect to when '
- 'running tests')
- parser.add_argument('--baud',
- type=int,
- default=115200,
- help='Target baud rate to use for serial communication'
- ' with target device')
- parser.add_argument('--test-timeout',
- type=float,
- default=5.0,
- help='Maximum communication delay in seconds before a '
- 'test is considered unresponsive and aborted')
- parser.add_argument('--verbose',
- '-v',
- dest='verbose',
- action="store_true",
- help='Output additional logs as the script runs')
+ parser.add_argument(
+ '--openocd-config',
+ default=_OPENOCD_CONFIG,
+ help='Path to openocd configuration file',
+ )
+ parser.add_argument(
+ '--stlink-serial',
+ default=None,
+ help='The serial number of the stlink to use when '
+ 'flashing the target device',
+ )
+ parser.add_argument(
+ '--port',
+ default=None,
+ help='The name of the serial port to connect to when ' 'running tests',
+ )
+ parser.add_argument(
+ '--baud',
+ type=int,
+ default=115200,
+ help='Target baud rate to use for serial communication'
+ ' with target device',
+ )
+ parser.add_argument(
+ '--test-timeout',
+ type=float,
+ default=5.0,
+ help='Maximum communication delay in seconds before a '
+ 'test is considered unresponsive and aborted',
+ )
+ parser.add_argument(
+ '--verbose',
+ '-v',
+ dest='verbose',
+ action="store_true",
+ help='Output additional logs as the script runs',
+ )
return parser.parse_args()
@@ -111,8 +122,17 @@
flash_tool = os.getenv('OPENOCD_PATH', default_flasher)
cmd = [
- flash_tool, '-s', _OPENOCD_SCRIPTS_DIR, '-f', openocd_config, '-c',
- 'init', '-c', 'reset run', '-c', 'exit'
+ flash_tool,
+ '-s',
+ _OPENOCD_SCRIPTS_DIR,
+ '-f',
+ openocd_config,
+ '-c',
+ 'init',
+ '-c',
+ 'reset run',
+ '-c',
+ 'exit',
]
_LOG.debug('Resetting device')
@@ -122,10 +142,9 @@
# Disable GDB port to support multi-device testing.
env['PW_GDB_PORT'] = 'disabled'
- process = subprocess.run(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env=env)
+ process = subprocess.run(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env
+ )
if process.returncode:
log_subprocess_output(logging.ERROR, process.stdout)
raise TestingFailure('Failed to reset target device')
@@ -142,9 +161,9 @@
"""
serial_data = bytearray()
- device = serial.Serial(baudrate=baud_rate,
- port=port,
- timeout=_FLASH_TIMEOUT)
+ device = serial.Serial(
+ baudrate=baud_rate, port=port, timeout=_FLASH_TIMEOUT
+ )
if not device.is_open:
raise TestingFailure('Failed to open device')
@@ -175,8 +194,11 @@
# Try to trim captured results to only contain most recent test run.
test_start_index = serial_data.rfind(_TESTS_STARTING_STRING)
- return serial_data if test_start_index == -1 else serial_data[
- test_start_index:]
+ return (
+ serial_data
+ if test_start_index == -1
+ else serial_data[test_start_index:]
+ )
def flash_device(binary, openocd_config, stlink_serial):
@@ -188,8 +210,13 @@
openocd_command = ' '.join(['program', binary, 'reset', 'exit'])
cmd = [
- flash_tool, '-s', _OPENOCD_SCRIPTS_DIR, '-f', openocd_config, '-c',
- openocd_command
+ flash_tool,
+ '-s',
+ _OPENOCD_SCRIPTS_DIR,
+ '-f',
+ openocd_config,
+ '-c',
+ openocd_command,
]
_LOG.info('Flashing firmware to device')
@@ -199,10 +226,9 @@
# Disable GDB port to support multi-device testing.
env['PW_GDB_PORT'] = 'disabled'
- process = subprocess.run(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env=env)
+ process = subprocess.run(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env
+ )
if process.returncode:
log_subprocess_output(logging.ERROR, process.stdout)
raise TestingFailure('Failed to flash target device')
@@ -236,12 +262,9 @@
dest.append(read_serial(port, baud_rate, test_timeout))
-def run_device_test(binary,
- test_timeout,
- openocd_config,
- baud,
- stlink_serial=None,
- port=None) -> bool:
+def run_device_test(
+ binary, test_timeout, openocd_config, baud, stlink_serial=None, port=None
+) -> bool:
"""Flashes, runs, and checks an on-device test binary.
Returns true on test pass.
@@ -265,8 +288,9 @@
# correctly relative to the start of capturing device output.
result: List[bytes] = []
threaded_reader_args = (result, port, baud, test_timeout)
- read_thread = threading.Thread(target=_threaded_test_reader,
- args=threaded_reader_args)
+ read_thread = threading.Thread(
+ target=_threaded_test_reader, args=threaded_reader_args
+ )
read_thread.start()
_LOG.info('Running test')
flash_device(binary, openocd_config, stlink_serial)
@@ -287,22 +311,24 @@
# Try to use pw_cli logs, else default to something reasonable.
try:
import pw_cli.log # pylint: disable=import-outside-toplevel
+
log_level = logging.DEBUG if args.verbose else logging.INFO
pw_cli.log.install(level=log_level)
except ImportError:
- coloredlogs.install(level='DEBUG' if args.verbose else 'INFO',
- level_styles={
- 'debug': {
- 'color': 244
- },
- 'error': {
- 'color': 'red'
- }
- },
- fmt='%(asctime)s %(levelname)s | %(message)s')
+ coloredlogs.install(
+ level='DEBUG' if args.verbose else 'INFO',
+ level_styles={'debug': {'color': 244}, 'error': {'color': 'red'}},
+ fmt='%(asctime)s %(levelname)s | %(message)s',
+ )
- if run_device_test(args.binary, args.test_timeout, args.openocd_config,
- args.baud, args.stlink_serial, args.port):
+ if run_device_test(
+ args.binary,
+ args.test_timeout,
+ args.openocd_config,
+ args.baud,
+ args.stlink_serial,
+ args.port,
+ ):
sys.exit(0)
else:
sys.exit(1)
diff --git a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_server.py b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_server.py
index 4fa8d31..0e1ded5 100644
--- a/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_server.py
+++ b/targets/stm32f769i_disc0/py/stm32f769i_disc0_utils/unit_test_server.py
@@ -36,18 +36,24 @@
"""Parses command-line arguments."""
parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('--server-port',
- type=int,
- default=8080,
- help='Port to launch the pw_target_runner_server on')
- parser.add_argument('--server-config',
- type=argparse.FileType('r'),
- help='Path to server config file')
- parser.add_argument('--verbose',
- '-v',
- dest='verbose',
- action="store_true",
- help='Output additional logs as the script runs')
+ parser.add_argument(
+ '--server-port',
+ type=int,
+ default=8080,
+ help='Port to launch the pw_target_runner_server on',
+ )
+ parser.add_argument(
+ '--server-config',
+ type=argparse.FileType('r'),
+ help='Path to server config file',
+ )
+ parser.add_argument(
+ '--verbose',
+ '-v',
+ dest='verbose',
+ action="store_true",
+ help='Output additional logs as the script runs',
+ )
return parser.parse_args()
@@ -75,17 +81,23 @@
_LOG.debug('Found %d attached devices', len(boards))
for board in boards:
test_runner_args = [
- '--stlink-serial', board.serial_number, '--port', board.dev_name
+ '--stlink-serial',
+ board.serial_number,
+ '--port',
+ board.dev_name,
]
config_file.write(
- generate_runner(_TEST_RUNNER_COMMAND,
- test_runner_args).encode('utf-8'))
+ generate_runner(_TEST_RUNNER_COMMAND, test_runner_args).encode(
+ 'utf-8'
+ )
+ )
config_file.flush()
return config_file
-def launch_server(server_config: Optional[IO[bytes]],
- server_port: Optional[int]) -> int:
+def launch_server(
+ server_config: Optional[IO[bytes]], server_port: Optional[int]
+) -> int:
"""Launch a device test server with the provided arguments."""
if server_config is None:
# Auto-detect attached boards if no config is provided.
diff --git a/tools/pigweed_experimental_tools/experimental_packages.py b/tools/pigweed_experimental_tools/experimental_packages.py
index 81a0482..6d86d8f 100644
--- a/tools/pigweed_experimental_tools/experimental_packages.py
+++ b/tools/pigweed_experimental_tools/experimental_packages.py
@@ -16,24 +16,31 @@
import sys
from pw_package import package_manager
+
# These modules register themselves so must be imported despite appearing
# unused.
-from pw_package.packages import arduino_core # pylint: disable=unused-import
-from pw_package.packages import boringssl # pylint: disable=unused-import
-from pw_package.packages import chromium_verifier # pylint: disable=unused-import
-from pw_package.packages import crlset # pylint: disable=unused-import
-from pw_package.packages import freertos # pylint: disable=unused-import
-from pw_package.packages import googletest # pylint: disable=unused-import
-from pw_package.packages import mbedtls # pylint: disable=unused-import
-from pw_package.packages import micro_ecc # pylint: disable=unused-import
-from pw_package.packages import nanopb
-from pw_package.packages import pico_sdk # pylint: disable=unused-import
-from pw_package.packages import protobuf # pylint: disable=unused-import
-from pw_package.packages import smartfusion_mss # pylint: disable=unused-import
-from pw_package.packages import stm32cube # pylint: disable=unused-import
-from pigweed_experimental_tools.packages import imgui # pylint: disable=unused-import
-from pigweed_experimental_tools.packages import glfw # pylint: disable=unused-import
-from pigweed_experimental_tools.packages import pico_tool # pylint: disable=unused-import
+# pylint: disable=unused-import
+from pw_package.packages import (
+ arduino_core,
+ boringssl,
+ chromium_verifier,
+ crlset,
+ freertos,
+ googletest,
+ mbedtls,
+ micro_ecc,
+ nanopb,
+ pico_sdk,
+ protobuf,
+ smartfusion_mss,
+ stm32cube,
+)
+
+from pigweed_experimental_tools.packages import (
+ imgui,
+ glfw,
+ pico_tool,
+)
def initialize():
diff --git a/tools/pigweed_experimental_tools/packages/glfw.py b/tools/pigweed_experimental_tools/packages/glfw.py
index 10dfa95..6af2919 100644
--- a/tools/pigweed_experimental_tools/packages/glfw.py
+++ b/tools/pigweed_experimental_tools/packages/glfw.py
@@ -24,6 +24,7 @@
class Glfw(pw_package.package_manager.Package):
"""Install and check status of Glfw."""
+
def __init__(self, *args, **kwargs):
super().__init__(*args, name='glfw', **kwargs)
@@ -38,23 +39,35 @@
downloads = {
'Linux': {
- 'url': ('https://github.com/glfw/glfw/releases/download/3.3.8/'
- 'glfw-3.3.8.zip'),
- 'sha256sum': ('4d025083cc4a3dd1f91ab9b9ba4f5807'
- '193823e565a5bcf4be202669d9911ea6'),
+ 'url': (
+ 'https://github.com/glfw/glfw/releases/download/3.3.8/'
+ 'glfw-3.3.8.zip'
+ ),
+ 'sha256sum': (
+ '4d025083cc4a3dd1f91ab9b9ba4f5807'
+ '193823e565a5bcf4be202669d9911ea6'
+ ),
},
'Darwin': {
- 'url': ('https://github.com/glfw/glfw/releases/download/3.3.8/'
- 'glfw-3.3.8.bin.MACOS.zip'),
- 'sha256sum': ('dc1fc3d3e7763b9de66f7cbb86c4ba3a'
- '82118441a15f64045a61cfcdedda88d2'),
+ 'url': (
+ 'https://github.com/glfw/glfw/releases/download/3.3.8/'
+ 'glfw-3.3.8.bin.MACOS.zip'
+ ),
+ 'sha256sum': (
+ 'dc1fc3d3e7763b9de66f7cbb86c4ba3a'
+ '82118441a15f64045a61cfcdedda88d2'
+ ),
},
'Windows': {
- 'url': ('https://github.com/glfw/glfw/releases/download/3.3.8/'
- 'glfw-3.3.8.bin.WIN64.zip'),
- 'sha256sum': ('7851c068b63c3cebf11a3b52c9e7dbdb'
- '6159afe32666b0aad268e4a258a9bdd1'),
- }
+ 'url': (
+ 'https://github.com/glfw/glfw/releases/download/3.3.8/'
+ 'glfw-3.3.8.bin.WIN64.zip'
+ ),
+ 'sha256sum': (
+ '7851c068b63c3cebf11a3b52c9e7dbdb'
+ '6159afe32666b0aad268e4a258a9bdd1'
+ ),
+ },
}
host_os = platform.system()
@@ -62,13 +75,15 @@
sha256sum = downloads[host_os]['sha256sum']
glfw_zip = file_operations.download_to_cache(
- url=url, expected_sha256sum=sha256sum, cache_directory=path)
+ url=url, expected_sha256sum=sha256sum, cache_directory=path
+ )
_extracted_files = file_operations.extract_archive(
glfw_zip,
dest_dir=str(path),
cache_dir=str(path),
- remove_single_toplevel_folder=True)
+ remove_single_toplevel_folder=True,
+ )
def info(self, path: Path) -> Sequence[str]:
return (
diff --git a/tools/pigweed_experimental_tools/packages/imgui.py b/tools/pigweed_experimental_tools/packages/imgui.py
index af4ff1f..741e42b 100644
--- a/tools/pigweed_experimental_tools/packages/imgui.py
+++ b/tools/pigweed_experimental_tools/packages/imgui.py
@@ -22,12 +22,15 @@
class Imgui(pw_package.git_repo.GitRepo):
"""Install and check status of Imgui."""
+
def __init__(self, *args, **kwargs):
- super().__init__(*args,
- name='imgui',
- url='https://github.com/ocornut/imgui.git',
- commit='ced92d9c52398f10fa152f78f52d0ca51d5d1d5b',
- **kwargs)
+ super().__init__(
+ *args,
+ name='imgui',
+ url='https://github.com/ocornut/imgui.git',
+ commit='ced92d9c52398f10fa152f78f52d0ca51d5d1d5b',
+ **kwargs,
+ )
self._allow_use_in_downstream = True
def info(self, path: pathlib.Path) -> Sequence[str]:
diff --git a/tools/pigweed_experimental_tools/packages/pico_tool.py b/tools/pigweed_experimental_tools/packages/pico_tool.py
index 62dcc15..de2af40 100644
--- a/tools/pigweed_experimental_tools/packages/pico_tool.py
+++ b/tools/pigweed_experimental_tools/packages/pico_tool.py
@@ -41,6 +41,7 @@
class PicoTool(pw_package.package_manager.Package):
"""Install and check status of PicoTool."""
+
def __init__(self, *args, **kwargs):
super().__init__(*args, name='picotool', **kwargs)
@@ -65,10 +66,12 @@
with change_working_dir(path) as _picotool_repo:
for command in commands:
_LOG.info('==> %s', command)
- subprocess.run(shlex.split(command),
- env=env,
- capture_output=True,
- check=True)
+ subprocess.run(
+ shlex.split(command),
+ env=env,
+ capture_output=True,
+ check=True,
+ )
picotool_bin = path / 'out/picotool'
_LOG.info('Done! picotool binary located at:')
diff --git a/tools/pigweed_experimental_tools/presubmit_checks.py b/tools/pigweed_experimental_tools/presubmit_checks.py
index f3033c1..de70458 100755
--- a/tools/pigweed_experimental_tools/presubmit_checks.py
+++ b/tools/pigweed_experimental_tools/presubmit_checks.py
@@ -25,8 +25,10 @@
try:
import pw_cli.log
except ImportError:
- print('ERROR: Activate the environment before running presubmits!',
- file=sys.stderr)
+ print(
+ 'ERROR: Activate the environment before running presubmits!',
+ file=sys.stderr,
+ )
sys.exit(2)
import pw_presubmit
@@ -52,7 +54,8 @@
print(
'ERROR: The presubmit checks must be run in the sample project\'s root'
' directory',
- file=sys.stderr)
+ file=sys.stderr,
+ )
sys.exit(2)
PIGWEED_ROOT = PROJECT_ROOT / 'third_party' / 'pigweed'
@@ -64,7 +67,8 @@
# Rerun the build if files with these extensions change.
_BUILD_EXTENSIONS = frozenset(
- ['.rst', '.gn', '.gni', *format_code.C_FORMAT.extensions])
+ ['.rst', '.gn', '.gni', *format_code.C_FORMAT.extensions]
+)
#
@@ -85,21 +89,23 @@
teensy_build = build.GnGenNinja(
name='teensy_build',
- packages=('teensy', ),
+ packages=('teensy',),
gn_args=dict(
pw_arduino_build_CORE_PATH=lambda ctx: '"{}"'.format(
- str(ctx.package_root)),
+ str(ctx.package_root)
+ ),
pw_arduino_build_CORE_NAME='"teensy"',
pw_arduino_build_PACKAGE_NAME='"avr/1.58.1"',
pw_arduino_build_BOARD='"teensy41"',
pw_arduino_build_MENU_OPTIONS=(
- '["menu.usb.serial", "menu.keys.en-us", "menu.opt.o2std"]'),
+ '["menu.usb.serial", "menu.keys.en-us", "menu.opt.o2std"]'
+ ),
),
)
pico_build = build.GnGenNinja(
name='pico_build',
- packages=('pico_sdk', ),
+ packages=('pico_sdk',),
gn_args=dict(
PICO_SRC_DIR=_package_root_arg('pico_sdk'),
dir_pw_third_party_freertos='"//third_party/freertos/Source"',
@@ -108,7 +114,7 @@
stm32cube_f4_build = build.GnGenNinja(
name='stm32cube_f4_build',
- packages=('stm32cube_f4', ),
+ packages=('stm32cube_f4',),
gn_args=dict(
dir_pw_third_party_stm32cube_f4=_package_root_arg('stm32cube_f4'),
dir_pw_third_party_freertos='"//third_party/freertos/Source"',
@@ -117,7 +123,7 @@
stm32cube_f7_build = build.GnGenNinja(
name='stm32cube_f7_build',
- packages=('stm32cube_f7', ),
+ packages=('stm32cube_f7',),
gn_args=dict(
dir_pw_third_party_stm32cube_f7=_package_root_arg('stm32cube_f7'),
dir_pw_third_party_freertos='"//third_party/freertos/Source"',
@@ -130,7 +136,8 @@
dir_pw_third_party_freertos='"//third_party/freertos/Source"',
pw_MIMXRT595_EVK_SDK=_package_root_arg("SDK_2_12_1_EVK-MIMXRT595"),
pw_target_mimxrt595_evk_MANIFEST=_package_root_arg(
- "SDK_2_12_1_EVK-MIMXRT595/EVK-MIMXRT595_manifest_v3_10.xml"),
+ "SDK_2_12_1_EVK-MIMXRT595/EVK-MIMXRT595_manifest_v3_10.xml"
+ ),
pw_third_party_mcuxpresso_SDK="//targets/mimxrt595_evk:mimxrt595_sdk",
),
)
@@ -157,7 +164,8 @@
_LOG.error('There are uncommitted changes in the %s repo!', repo.name)
if changes:
_LOG.warning(
- 'Commit or stash pending changes before running the presubmit.')
+ 'Commit or stash pending changes before running the presubmit.'
+ )
raise PresubmitFailure
@@ -250,7 +258,8 @@
parser.add_argument(
'--install',
action='store_true',
- help='Install the presubmit as a Git pre-push hook and exit.')
+ help='Install the presubmit as a Git pre-push hook and exit.',
+ )
return run(**vars(parser.parse_args()))