Skip to content

Commit

Permalink
Add to flake8 in workflow and fix python files
Browse files Browse the repository at this point in the history
  • Loading branch information
DamMicSzm committed Feb 23, 2023
1 parent b236bfb commit 823136e
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 9 deletions.
158 changes: 158 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,160 @@
[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/efr32/*
build/chip/java/tests/*
build/chip/linux/*
build/config/linux/*
credentials/fetch-paa-certs-from-dcl.py
docs/_extensions/external_content.py
examples/chef/chef.py
examples/chef/sample_app_util/zap_file_parser.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/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/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
7 changes: 7 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions scripts/build/builders/esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def IsCompatible(self, board: Esp32Board):
if board == Esp32Board.QEMU:
return self == Esp32App.TESTS
elif board == Esp32Board.M5Stack:
return self == Esp32App.ALL_CLUSTERS or self == Esp32App.ALL_CLUSTERS_MINIMAL or self == Esp32App.OTA_REQUESTOR or self == Esp32App.OTA_PROVIDER
return (self == Esp32App.ALL_CLUSTERS or self == Esp32App.ALL_CLUSTERS_MINIMAL or
self == Esp32App.OTA_REQUESTOR or self == Esp32App.OTA_PROVIDER)
elif board == Esp32Board.C3DevKit:
return self == Esp32App.ALL_CLUSTERS or self == Esp32App.ALL_CLUSTERS_MINIMAL
else:
Expand Down Expand Up @@ -244,5 +245,5 @@ def flashbundle(self):

with open(os.path.join(self.output_dir, self.app.FlashBundleName), 'r') as fp:
return {
l.strip(): os.path.join(self.output_dir, l.strip()) for l in fp.readlines() if l.strip()
line.strip(): os.path.join(self.output_dir, line.strip()) for line in fp.readlines() if line.strip()
}
10 changes: 5 additions & 5 deletions scripts/tools/generate_esp32_chip_factory_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import enum
import logging
import os
import shutil
import subprocess
import sys
from types import SimpleNamespace

Expand Down Expand Up @@ -198,7 +196,7 @@ def calendar_types_to_uint32(calendar_types):

def ishex(s):
try:
n = int(s, 16)
_ = int(s, 16)
return True
except ValueError:
return False
Expand Down Expand Up @@ -464,11 +462,13 @@ def any_base_int(s): return int(s, 0)
parser.add_argument('--mfg-date', help='Manufacturing date in format YYYY-MM-DD')
parser.add_argument('--serial-num', help='Serial number')
parser.add_argument('--rd-id-uid',
help='128-bit unique identifier for generating rotating device identifier, provide 32-byte hex string, e.g. "1234567890abcdef1234567890abcdef"')
help=('128-bit unique identifier for generating rotating device identifier, '
'provide 32-byte hex string, e.g. "1234567890abcdef1234567890abcdef"'))

# These will be used by DeviceInfoProvider
parser.add_argument('--calendar-types', nargs='+',
help='List of supported calendar types.\nSupported Calendar Types: Buddhist, Chinese, Coptic, Ethiopian, Gregorian, Hebrew, Indian, Islamic, Japanese, Korean, Persian, Taiwanese')
help=('List of supported calendar types.\nSupported Calendar Types: Buddhist, Chinese, Coptic, Ethiopian, '
'Gregorian, Hebrew, Indian, Islamic, Japanese, Korean, Persian, Taiwanese'))
parser.add_argument('--locales', nargs='+', help='List of supported locales, Language Tag as defined by BCP47, eg. en-US en-GB')
parser.add_argument('--fixed-labels', nargs='+',
help='List of fixed labels, eg: "0/orientation/up" "1/orientation/down" "2/orientation/down"')
Expand Down
3 changes: 1 addition & 2 deletions src/test_driver/esp32/run_qemu_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import os
import re
import subprocess
import sys

import click
import coloredlogs
Expand Down Expand Up @@ -147,7 +146,7 @@ def main(log_level, no_log_timestamps, image, file_image_list, qemu, verbose):
print("========== TEST OUTPUT END ============")

logging.info("Image %s PASSED", path)
except:
except Exception:
# make sure output is visible in stdout
print("========== TEST OUTPUT BEGIN ============")
print(output)
Expand Down

0 comments on commit 823136e

Please sign in to comment.