diff --git a/.flake8 b/.flake8 index 28e6208b8c07ee..ffa2c947f01391 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,161 @@ [flake8] max-line-length = 132 +exclude = third_party + .* + out/* + scripts/idl/* + ./examples/common/QRCode/* + # temporarily scan only directories with fixed files + # TODO: Remove the paths below when all bugs are fixed + src/tools/chip-cert/* + src/test_driver/openiotsdk/* + src/test_driver/mbed/* + src/test_driver/linux-cirque/* + src/test_driver/esp32/* + src/test_driver/efr32/* + build/chip/java/tests/* + build/chip/linux/* + build/config/linux/* + credentials/fetch-paa-certs-from-dcl.py + docs/_extensions/external_content.py + examples/common/pigweed/rpc_console/py/chip_rpc/console.py + examples/lighting-app/python/lighting.py + examples/platform/mbed/ota/generate_ota_list_image.py + examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py + scripts/build/build/target.py + scripts/build/build/targets.py + scripts/build/builders/android.py + scripts/build/builders/bouffalolab.py + scripts/build/builders/cc13x2x7_26x2x7.py + scripts/build/builders/efr32.py + scripts/build/builders/esp32.py + scripts/build/builders/genio.py + scripts/build/builders/gn.py + scripts/build/builders/imx.py + scripts/build/builders/infineon.py + scripts/build/builders/nrf.py + scripts/build/test.py + scripts/codegen.py + scripts/codepregen.py + scripts/error_table.py + scripts/examples/gn_to_cmakelists.py + scripts/examples/tests/test.py + scripts/flashing/bouffalolab_firmware_utils.py + scripts/flashing/cyw30739_firmware_utils.py + scripts/flashing/nrfconnect_firmware_utils.py + scripts/gen_chip_version.py + scripts/gen_test_driver.py + scripts/helpers/bloat_check.py + scripts/pregenerate/using_codegen.py + scripts/pregenerate/using_zap.py + scripts/py_matter_idl/examples/matter_idl_plugin/__init__.py + scripts/py_matter_idl/matter_idl/generators/__init__.py + scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py + scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py + scripts/py_matter_idl/matter_idl/generators/java/__init__.py + scripts/py_matter_idl/matter_idl/generators/types.py + scripts/py_matter_idl/matter_idl/lint/__init__.py + scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py + scripts/py_matter_idl/matter_idl/lint/types.py + scripts/py_matter_idl/matter_idl/matter_idl_parser.py + scripts/py_matter_idl/matter_idl/matter_idl_types.py + scripts/py_matter_idl/matter_idl/test_generators.py + scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py + scripts/py_matter_idl/matter_idl/test_xml_parser.py + scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py + scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py + scripts/py_matter_yamltests/matter_yamltests/constraints.py + scripts/py_matter_yamltests/matter_yamltests/definitions.py + scripts/py_matter_yamltests/matter_yamltests/fixes.py + scripts/py_matter_yamltests/matter_yamltests/parser.py + scripts/py_matter_yamltests/matter_yamltests/pics_checker.py + scripts/py_matter_yamltests/matter_yamltests/pseudo_clusters/pseudo_clusters.py + scripts/py_matter_yamltests/matter_yamltests/yaml_loader.py + scripts/py_matter_yamltests/test_pics_checker.py + scripts/py_matter_yamltests/test_spec_definitions.py + scripts/py_matter_yamltests/test_yaml_loader.py + scripts/py_matter_yamltests/test_yaml_parser.py + scripts/run-clang-tidy-on-compile-commands.py + scripts/setup/nrfconnect/update_ncs.py + scripts/tests/chiptest/__init__.py + scripts/tests/chiptest/runner.py + scripts/tests/chiptest/test_definition.py + scripts/tests/chiptest/yamltest_with_chip_repl_tester.py + scripts/tests/java/base.py + scripts/tests/java/commissioning_test.py + scripts/tests/java/discover_test.py + scripts/tests/run_java_test.py + scripts/tests/run_python_test.py + scripts/tests/run_test_suite.py + scripts/tools/check_zcl_file_sync.py + scripts/tools/convert_ini.py + scripts/tools/generate_esp32_chip_factory_bin.py + scripts/tools/memory/memdf/__init__.py + scripts/tools/memory/report_summary.py + scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py + scripts/tools/nrfconnect/nrfconnect_generate_partition.py + scripts/tools/nrfconnect/tests/test_generate_factory_data.py + scripts/tools/nxp/factory_data_generator/custom.py + scripts/tools/nxp/factory_data_generator/default.py + scripts/tools/nxp/factory_data_generator/generate.py + scripts/tools/silabs/FactoryDataProvider.py + scripts/tools/telink/mfg_tool.py + scripts/tools/zap/generate.py + scripts/tools/zap/prune_outputs.py + scripts/tools/zap/test_generate.py + scripts/tools/zap/version_update.py + scripts/tools/zap/zap_download.py + scripts/tools/zap_convert_all.py + src/app/ota_image_tool.py + src/app/tests/suites/certification/information.py + src/app/zap_cluster_list.py + src/controller/python/build-chip-wheel.py + src/controller/python/chip-device-ctrl.py + src/controller/python/chip/CertificateAuthority.py + src/controller/python/chip/ChipBleUtility.py + src/controller/python/chip/ChipBluezMgr.py + src/controller/python/chip/ChipCommissionableNodeCtrl.py + src/controller/python/chip/ChipCoreBluetoothMgr.py + src/controller/python/chip/ChipDeviceCtrl.py + src/controller/python/chip/ChipReplStartup.py + src/controller/python/chip/ChipStack.py + src/controller/python/chip/ChipUtility.py + src/controller/python/chip/FabricAdmin.py + src/controller/python/chip/ble/scan_devices.py + src/controller/python/chip/clusters/Attribute.py + src/controller/python/chip/clusters/CHIPClusters.py + src/controller/python/chip/clusters/ClusterObjects.py + src/controller/python/chip/clusters/Command.py + src/controller/python/chip/clusters/Objects.py + src/controller/python/chip/clusters/__init__.py + src/controller/python/chip/discovery/__init__.py + src/controller/python/chip/interaction_model/__init__.py + src/controller/python/chip/interaction_model/delegate.py + src/controller/python/chip/internal/commissioner.py + src/controller/python/chip/setup_payload/setup_payload.py + src/controller/python/chip/storage/__init__.py + src/controller/python/chip/tlv/__init__.py + src/controller/python/chip/utils/CommissioningBuildingBlocks.py + src/controller/python/chip/yaml/__init__.py + src/controller/python/chip/yaml/format_converter.py + src/controller/python/chip/yaml/runner.py + src/controller/python/test/test_scripts/base.py + src/controller/python/test/test_scripts/cluster_objects.py + src/controller/python/test/test_scripts/mobile-device-test.py + src/controller/python/test/test_scripts/network_commissioning.py + src/controller/python/test/unit_tests/test_cluster_objects.py + src/controller/python/test/unit_tests/test_tlv.py + src/lib/asn1/gen_asn1oid.py + src/pybindings/pycontroller/build-chip-wheel.py + src/pybindings/pycontroller/pychip/__init__.py + src/python_testing/TC_ACE_1_3.py + src/python_testing/TC_ACE_1_4.py + src/python_testing/TC_CGEN_2_4.py + src/python_testing/TC_DA_1_7.py + src/python_testing/TC_RR_1_1.py + src/python_testing/TC_SC_3_6.py + src/python_testing/TC_TestEventTrigger.py + src/python_testing/hello_test.py + src/python_testing/matter_testing_support.py + src/setup_payload/python/generate_setup_payload.py + src/setup_payload/tests/run_python_setup_payload_gen_test.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8f2fe9fc73af67..089642b7c28914 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -214,3 +214,10 @@ jobs: if: always() run: | git grep -n 'emberAfWriteAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/af.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' ':(exclude)examples/common/pigweed/rpc_services/Attributes.h' ':(exclude)src/app/util/attribute-table.h' ':(exclude)src/app/util/ember-compatibility-functions.cpp' && exit 1 || exit 0 + + # Run python Linter (flake8) and verify python files + # ignore some style errors, restyler should do that + - name: Check for errors using flake8 Python linter + if: always() + run: | + flake8 --extend-ignore=E501,W391 diff --git a/examples/chef/chef.py b/examples/chef/chef.py index cdd4a61a5c2d6c..bc4c820974ed83 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import hashlib import json import optparse import os @@ -23,7 +22,7 @@ import sys import tarfile import textwrap -from typing import Any, Dict, Sequence +from typing import Any, Dict import constants import stateful_shell @@ -280,7 +279,8 @@ def main() -> int: Notes: - Whenever you change a device type, make sure to also use options -zbe - - Be careful if you have more than one device connected. The script assumes you have only one device connected and might flash the wrong one\ + - Be careful if you have more than one device connected. + The script assumes you have only one device connected and might flash the wrong one """) parser = optparse.OptionParser(usage=usage) @@ -313,9 +313,13 @@ def main() -> int: 'linux', 'silabs-thread', 'ameba'], metavar="TARGET", default="esp32") - parser.add_option("-r", "--rpc", help="enables Pigweed RPC interface. Enabling RPC disables the shell interface. Your sdkconfig configurations will be reverted to default. Default is PW RPC off. When enabling or disabling this flag, on the first build force a clean build with -c", + parser.add_option("-r", "--rpc", + help=("enables Pigweed RPC interface. Enabling RPC disables the shell interface. " + "Your sdkconfig configurations will be reverted to default. Default is PW RPC off. " + "When enabling or disabling this flag, on the first build force a clean build with -c"), action="store_true", dest="do_rpc", default=False) - parser.add_option("-a", "--automated_test_stamp", help="provide the additional stamp \"branch:commit_id\" as the software version string for automated tests.", + parser.add_option("-a", "--automated_test_stamp", + help="provide the additional stamp \"branch:commit_id\" as the software version string for automated tests.", action="store_true", dest="do_automated_test_stamp") parser.add_option("-v", "--vid", dest="vid", type=int, help="specifies the Vendor ID. Default is 0xFFF1", metavar="VID", default=0xFFF1) @@ -325,22 +329,31 @@ def main() -> int: help="specifies the Product Name. Default is TEST_PRODUCT", default="TEST_PRODUCT") parser.add_option("", "--rpc_console", help="Opens PW RPC Console", action="store_true", dest="do_rpc_console") - parser.add_option("-y", "--tty", help="Enumerated USB tty/serial interface enumerated for your physical device. E.g.: /dev/ACM0", + parser.add_option("-y", "--tty", + help="Enumerated USB tty/serial interface enumerated for your physical device. E.g.: /dev/ACM0", dest="tty", metavar="TTY", default=None) - # Build CD params. - parser.add_option("", "--build_all", help="For use in CD only. Builds and bundles all chef examples for the specified platform. Chef exits after completion.", + parser.add_option("", "--build_all", + help=("For use in CD only. Builds and bundles all chef examples for " + "the specified platform. Chef exits after completion."), dest="build_all", action="store_true") parser.add_option("", "--dry_run", help="Display list of target builds of the --build_all command without building them.", dest="dry_run", action="store_true") - parser.add_option("", "--build_exclude", help="For use with --build_all. Build labels to exclude. Accepts a regex pattern. Mutually exclusive with --build_include.", + parser.add_option("", "--build_exclude", + help=("For use with --build_all. Build labels to exclude. " + "Accepts a regex pattern. Mutually exclusive with --build_include."), dest="build_exclude") - parser.add_option("", "--build_include", help="For use with --build_all. Build labels to include. Accepts a regex pattern. Mutually exclusive with --build_exclude.", + parser.add_option("", "--build_include", + help=("For use with --build_all. Build labels to include. " + "Accepts a regex pattern. Mutually exclusive with --build_exclude."), dest="build_include") - parser.add_option("-k", "--keep_going", help="For use in CD only. Continues building all sample apps in the event of an error.", + parser.add_option("-k", "--keep_going", + help="For use in CD only. Continues building all sample apps in the event of an error.", dest="keep_going", action="store_true") - parser.add_option( - "", "--ci", help="Builds Chef examples defined in cicd_config. Uses specified target from -t. Chef exits after completion.", dest="ci", action="store_true") + parser.add_option("", "--ci", + help=("Builds Chef examples defined in cicd_config. " + "Uses specified target from -t. Chef exits after completion."), + dest="ci", action="store_true") parser.add_option( "", "--enable_ipv4", help="Enable IPv4 mDNS. Only applicable to platforms that can support IPV4 (e.g, Linux, ESP32)", action="store_true", default=False) @@ -452,14 +465,12 @@ def main() -> int: flush_print( 'Path for esp32 SDK was not found. Make sure esp32.IDF_PATH is set on your config.yaml file') exit(1) - plat_folder = os.path.normpath(f"{_CHEF_SCRIPT_PATH}/esp32") shell.run_cmd(f'source {config["esp32"]["IDF_PATH"]}/export.sh') elif options.build_target == "nrfconnect": if config['nrfconnect']['ZEPHYR_BASE'] is None: flush_print( 'Path for nrfconnect SDK was not found. Make sure nrfconnect.ZEPHYR_BASE is set on your config.yaml file') exit(1) - plat_folder = os.path.normpath(f"{_CHEF_SCRIPT_PATH}/nrfconnect") shell.run_cmd( f'source {config["nrfconnect"]["ZEPHYR_BASE"]}/zephyr-env.sh') shell.run_cmd("export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb") @@ -532,7 +543,8 @@ def main() -> int: shell.run_cmd(f"rm -rf {gen_dir}") shell.run_cmd(f"mkdir -p {gen_dir}") shell.run_cmd( - f"{_REPO_BASE_PATH}/scripts/tools/zap/generate.py {_CHEF_SCRIPT_PATH}/devices/{options.sample_device_type_name}.zap -o {gen_dir}") + f"{_REPO_BASE_PATH}/scripts/tools/zap/generate.py " + f"{_CHEF_SCRIPT_PATH}/devices/{options.sample_device_type_name}.zap -o {gen_dir}") # af-gen-event.h is not generated shell.run_cmd(f"touch {gen_dir}/af-gen-event.h") @@ -545,7 +557,8 @@ def main() -> int: shell.run_cmd( f"export SDKCONFIG_DEFAULTS={_CHEF_SCRIPT_PATH}/esp32/sdkconfig_rpc.defaults") shell.run_cmd( - f"[ -f {_CHEF_SCRIPT_PATH}/esp32/sdkconfig ] || cp {_CHEF_SCRIPT_PATH}/esp32/sdkconfig_rpc.defaults {_CHEF_SCRIPT_PATH}/esp32/sdkconfig") + f"[ -f {_CHEF_SCRIPT_PATH}/esp32/sdkconfig ] || cp " + f"{_CHEF_SCRIPT_PATH}/esp32/sdkconfig_rpc.defaults {_CHEF_SCRIPT_PATH}/esp32/sdkconfig") else: flush_print(f"RPC PW on {options.build_target} not supported") @@ -555,7 +568,8 @@ def main() -> int: shell.run_cmd( f"export SDKCONFIG_DEFAULTS={_CHEF_SCRIPT_PATH}/esp32/sdkconfig.defaults") shell.run_cmd( - f"[ -f {_CHEF_SCRIPT_PATH}/esp32/sdkconfig ] || cp {_CHEF_SCRIPT_PATH}/esp32/sdkconfig.defaults {_CHEF_SCRIPT_PATH}/esp32/sdkconfig") + f"[ -f {_CHEF_SCRIPT_PATH}/esp32/sdkconfig ] || cp " + f"{_CHEF_SCRIPT_PATH}/esp32/sdkconfig.defaults {_CHEF_SCRIPT_PATH}/esp32/sdkconfig") # # Menuconfig @@ -586,7 +600,7 @@ def main() -> int: if options.do_automated_test_stamp: branch = "" for branch_text in shell.run_cmd("git branch", return_cmd_output=True).split("\n"): - match_texts = re.findall("\* (.*)", branch_text) + match_texts = re.findall(r"\* (.*)", branch_text) if match_texts: branch = match_texts[0] break @@ -597,7 +611,8 @@ def main() -> int: if len(sw_ver_string) >= 64: truncated_sw_ver_string = f"""{branch[:22]}:{commit_id}""" flush_print( - f"""Truncate the software version string from \"{sw_ver_string}\" to \"{truncated_sw_ver_string}\" due to 64 bytes limitation""") + f"Truncate the software version string from \"{sw_ver_string}\" to " + f"\"{truncated_sw_ver_string}\" due to 64 bytes limitation") sw_ver_string = truncated_sw_ver_string flush_print("Building...") @@ -620,14 +635,15 @@ def main() -> int: shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/esp32") if options.enable_ipv4: shell.run_cmd( - f"sed -i 's/CONFIG_DISABLE_IPV4=y/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/g' sdkconfig ") + "sed -i 's/CONFIG_DISABLE_IPV4=y/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/g' sdkconfig ") else: shell.run_cmd( - f"sed -i 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ") + "sed -i 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ") shell.run_cmd("idf.py build") shell.run_cmd("idf.py build flashing_script") shell.run_cmd( - f"(cd build/ && tar cJvf $(git rev-parse HEAD)-{options.sample_device_type_name}.tar.xz --files-from=chip-shell.flashbundle.txt)") + f"(cd build/ && tar cJvf $(git rev-parse HEAD)-{options.sample_device_type_name}.tar.xz " + f"--files-from=chip-shell.flashbundle.txt)") shell.run_cmd( f"cp build/$(git rev-parse HEAD)-{options.sample_device_type_name}.tar.xz {_CHEF_SCRIPT_PATH}") elif options.build_target == "nrfconnect": @@ -668,15 +684,17 @@ def main() -> int: shell.run_cmd( f"cd {config['ameba']['AMEBA_SDK']}/project/realtek_amebaD_va0_example/GCC-RELEASE") if options.do_clean: - shell.run_cmd(f"rm -rf out") + shell.run_cmd("rm -rf out") shell.run_cmd( - f"./build.sh {config['ameba']['MATTER_SDK']} ninja {config['ameba']['AMEBA_SDK']}/project/realtek_amebaD_va0_example/GCC-RELEASE/out chef-app") + f"./build.sh {config['ameba']['MATTER_SDK']} ninja " + f"{config['ameba']['AMEBA_SDK']}/project/realtek_amebaD_va0_example/GCC-RELEASE/out chef-app") shell.run_cmd("ninja -C out") elif config['ameba']['MODEL'] == 'Z2': shell.run_cmd( f"cd {config['ameba']['AMEBA_SDK']}/project/realtek_amebaz2_v0_example/GCC-RELEASE") shell.run_cmd("rm -f project_include.mk") - with open(f"{config['ameba']['AMEBA_SDK']}/project/realtek_amebaz2_v0_example/GCC-RELEASE/project_include.mk", "w") as f: + cmd = f"{config['ameba']['AMEBA_SDK']}/project/realtek_amebaz2_v0_example/GCC-RELEASE/project_include.mk" + with open(cmd, "w") as f: f.write(textwrap.dedent(f"""\ SAMPLE_NAME = {options.sample_device_type_name} CHEF_FLAGS = @@ -702,7 +720,10 @@ def main() -> int: 'chip_shell_cmd_server = false', 'chip_build_libshell = true', 'chip_config_network_layer_ble = false', - f'target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\\"{str(options.pname)}\\""]', + (f'target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", ' + f'"CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", ' + f'"CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}", ' + f'"CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\\"{str(options.pname)}\\""]'), ]) uname_resp = shell.run_cmd("uname -m", return_cmd_output=True) @@ -758,7 +779,7 @@ def main() -> int: sample_name = "{options.sample_device_type_name}" """)) if options.do_clean: - shell.run_cmd(f"rm -rf out") + shell.run_cmd("rm -rf out") shell.run_cmd("gn gen out") shell.run_cmd("ninja -C out") @@ -799,14 +820,20 @@ def main() -> int: shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/ameba") shell.run_cmd( f"cd {config['ameba']['AMEBA_SDK']}/tools/AmebaD/Image_Tool_Linux") - shell.run_cmd( - f"{config['ameba']['AMEBA_SDK']}/tools/AmebaD/Image_Tool_Linux/flash.sh {config['ameba']['TTY']} {config['ameba']['AMEBA_SDK']}/project/realtek_amebaD_va0_example/GCC-RELEASE/out", raise_on_returncode=False) + shell.run_cmd(( + f"{config['ameba']['AMEBA_SDK']}/tools/AmebaD/Image_Tool_Linux/flash.sh " + f"{config['ameba']['TTY']} {config['ameba']['AMEBA_SDK']}" + f"/project/realtek_amebaD_va0_example/GCC-RELEASE/out" + ), raise_on_returncode=False) else: shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/ameba") shell.run_cmd( f"cd {config['ameba']['AMEBA_SDK']}/tools/AmebaZ2/Image_Tool_Linux") - shell.run_cmd( - f"{config['ameba']['AMEBA_SDK']}/tools/AmebaZ2/Image_Tool_Linux/flash.sh {config['ameba']['TTY']} {config['ameba']['AMEBA_SDK']}/project/realtek_amebaz2_v0_example/GCC-RELEASE/application_is/Debug/bin", raise_on_returncode=False) + shell.run_cmd(( + f"{config['ameba']['AMEBA_SDK']}/tools/AmebaZ2/Image_Tool_Linux/flash.sh " + f"{config['ameba']['TTY']} {config['ameba']['AMEBA_SDK']}" + f"/project/realtek_amebaz2_v0_example/GCC-RELEASE/application_is/Debug/bin" + ), raise_on_returncode=False) # # Terminal interaction @@ -817,21 +844,24 @@ def main() -> int: if options.build_target == "esp32": if config['esp32']['TTY'] is None: flush_print( - 'The path for the serial enumeration for esp32 is not set. Make sure esp32.TTY is set on your config.yaml file') + 'The path for the serial enumeration for esp32 is not set. ' + 'Make sure esp32.TTY is set on your config.yaml file') exit(1) shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/esp32") shell.run_cmd(f"idf.py -p {config['esp32']['TTY']} monitor") elif options.build_target == "nrfconnect": if config['nrfconnect']['TTY'] is None: flush_print( - 'The path for the serial enumeration for nordic is not set. Make sure nrfconnect.TTY is set on your config.yaml file') + 'The path for the serial enumeration for nordic is not set. ' + 'Make sure nrfconnect.TTY is set on your config.yaml file') exit(1) shell.run_cmd("killall screen") shell.run_cmd(f"screen {config['nrfconnect']['TTY']} 115200") elif (options.build_target == "silabs-thread"): if config['silabs-thread']['TTY'] is None: flush_print( - 'The path for the serial enumeration for silabs-thread is not set. Make sure silabs-thread.TTY is set on your config.yaml file') + 'The path for the serial enumeration for silabs-thread is not set. ' + 'Make sure silabs-thread.TTY is set on your config.yaml file') exit(1) shell.run_cmd("killall screen") @@ -864,14 +894,16 @@ def main() -> int: if (sys.platform == "linux") or (sys.platform == "linux2"): if (config['silabs-thread']['TTY'] is None): flush_print( - 'The path for the serial enumeration for silabs-thread is not set. Make sure silabs-thread.TTY is set on your config.yaml file') + 'The path for the serial enumeration for silabs-thread is not set. ' + 'Make sure silabs-thread.TTY is set on your config.yaml file') exit(1) shell.run_cmd( f"python3 -m chip_rpc.console --device {config['silabs-thread']['TTY']} -b 115200") elif sys.platform == "darwin": if (config['silabs-thread']['CU'] is None): flush_print( - 'The path for the serial enumeration for silabs-thread is not set. Make sure silabs-thread.CU is set on your config.yaml file') + 'The path for the serial enumeration for silabs-thread is not set. ' + 'Make sure silabs-thread.CU is set on your config.yaml file') exit(1) shell.run_cmd( f"python3 -m chip_rpc.console --device {config['silabs-thread']['CU']} -b 115200") diff --git a/examples/chef/sample_app_util/zap_file_parser.py b/examples/chef/sample_app_util/zap_file_parser.py index fddc5c9e8efcd2..6f186e86e27155 100644 --- a/examples/chef/sample_app_util/zap_file_parser.py +++ b/examples/chef/sample_app_util/zap_file_parser.py @@ -35,7 +35,7 @@ import json import os import re -from typing import Dict, List, Literal, Optional, Sequence, TypedDict, Union +from typing import Dict, List, Optional, Sequence, TypedDict, Union try: import yaml @@ -154,7 +154,8 @@ def _convert_metadata_to_hashable_digest(metadata_input: Sequence[Dict[str, Endp for cluster_type in ["client_clusters", "server_clusters"]: for cluster_key in list(endpoint_obj[cluster_type].keys()): cluster_id = _get_id(cluster_key) - endpoint_obj[cluster_type][cluster_id] = endpoint_obj[cluster_type].pop(cluster_key) + endpoint_obj[cluster_type][cluster_id] = endpoint_obj[cluster_type].pop( + cluster_key) cluster_obj = endpoint_obj[cluster_type][cluster_id] # Replace attribute names @@ -162,12 +163,14 @@ def _convert_metadata_to_hashable_digest(metadata_input: Sequence[Dict[str, Endp attribute_keys = list(cluster_obj["attributes"]) for attribute_key in attribute_keys: attribute_id = _get_id(attribute_key) - attribute_obj[attribute_id] = attribute_obj.pop(attribute_key) + attribute_obj[attribute_id] = attribute_obj.pop( + attribute_key) # Replace command names if "commands" in cluster_obj: command_keys = cluster_obj["commands"] - cluster_obj["commands"] = [_get_id(x) for x in command_keys] + cluster_obj["commands"] = [ + _get_id(x) for x in command_keys] cluster_obj["commands"].sort() return json.dumps(metadata, sort_keys=True) @@ -277,7 +280,8 @@ def generate_metadata( if not cluster["enabled"]: continue - cluster_ref = _convert_metadata_name(cluster["name"], cluster["code"]) + cluster_ref = _convert_metadata_name( + cluster["name"], cluster["code"]) if include_commands: cluster_obj: ClusterType = {"attributes": {}, "commands": []} @@ -288,7 +292,8 @@ def generate_metadata( attribute_allowed = ( attribute_allow_list is None or str(attribute["code"]) in attribute_allow_list) if attribute["included"] and attribute_allowed: - attribute_ref = _convert_metadata_name(attribute["name"], attribute["code"]) + attribute_ref = _convert_metadata_name( + attribute["name"], attribute["code"]) value = _read_value(attribute["defaultValue"]) cluster_obj["attributes"][attribute_ref] = value @@ -298,7 +303,8 @@ def generate_metadata( if include_commands: for command in cluster["commands"]: - command_ref = _convert_metadata_name(command["name"], command["code"]) + command_ref = _convert_metadata_name( + command["name"], command["code"]) if cluster["side"] == "client" and command["outgoing"] == 1: cluster_obj["commands"].append(command_ref) elif cluster["side"] == "server" and command["incoming"] == 1: