Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[other] Add to flake8 in workflow and fix python files (part #25193) #27890

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,3 @@ exclude = third_party
.*
out/*
./examples/common/QRCode/*
# temporarily scan only directories with fixed files
# TODO: Remove the paths below when all bugs are fixed
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
src/app/zap_cluster_list.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/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py
src/lib/asn1/gen_asn1oid.py
src/pybindings/pycontroller/build-chip-wheel.py
src/pybindings/pycontroller/pychip/__init__.py
src/setup_payload/python/generate_setup_payload.py
4 changes: 2 additions & 2 deletions build/chip/linux/gen_gdbus_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def main(argv):
] + extra_args + [options.input_file]
subprocess.check_call(gdbus_args)
sed_args = ["sed", "-i",
"s/config\.h/BuildConfig.h/g", options.output_c]
r"s/config\.h/BuildConfig.h/g", options.output_c]
if sys.platform == "darwin":
sed_args = ["sed", "-i", "",
"s/config\.h/BuildConfig.h/g", options.output_c]
r"s/config\.h/BuildConfig.h/g", options.output_c]
subprocess.check_call(sed_args)

if options.output_h:
Expand Down
4 changes: 2 additions & 2 deletions build/config/linux/pkg-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def MatchesAnyRegexp(flag, list_of_regexps):
"""Returns true if the first argument matches any regular expression in the
given list."""
for regexp in list_of_regexps:
if regexp.search(flag) != None:
if regexp.search(flag) is not None:
return True
return False

Expand Down Expand Up @@ -145,7 +145,7 @@ def main():

# Make a list of regular expressions to strip out.
strip_out = []
if options.strip_out != None:
if options.strip_out is not None:
for regexp in options.strip_out:
strip_out.append(re.compile(regexp))

Expand Down
1 change: 0 additions & 1 deletion credentials/fetch-paa-certs-from-dcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import re
import subprocess
import sys
from contextlib import nullcontext

import click
import requests
Expand Down
2 changes: 1 addition & 1 deletion docs/_extensions/external_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def adjust_includes(

def _adjust_path(path):
# ignore absolute paths, section links, hyperlinks and same folder
if path.startswith(("/", "#", "http", "www")) or not "/" in path:
if path.startswith(("/", "#", "http", "www")) or "/" not in path:
return path

# for files that are being copied modify reference to and out of /docs
Expand Down
4 changes: 2 additions & 2 deletions examples/common/pigweed/rpc_console/py/chip_rpc/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ def write_to_output(data: bytes,

def _read_raw_serial(read: Callable[[], bytes], output):
"""Continuously read and pass to output."""
with ThreadPoolExecutor() as executor:
with ThreadPoolExecutor() as _:
while True:
try:
data = read()
except Exception as exc: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
continue
if data:
output(data)
Expand Down
8 changes: 3 additions & 5 deletions examples/lighting-app/python/lighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
import textwrap
import threading
from cmd import Cmd
from ctypes import CFUNCTYPE, c_char_p, c_int32, c_uint8

from chip.exceptions import ChipStackError
from chip.server import GetLibraryHandle, NativeLibraryHandleMethodArguments, PostAttributeChangeCallback
from dali.address import Broadcast, Short
from chip.server import GetLibraryHandle, PostAttributeChangeCallback
from dali.address import Broadcast
from dali.driver.hid import tridonic
from dali.gear.general import DAPC, Off, RecallMaxLevel

Expand Down Expand Up @@ -206,7 +204,7 @@ def __init__(self):


if __name__ == "__main__":
l = Lighting()
lighting = Lighting()

lightMgrCmd = LightingMgrCmd()
print("Chip Lighting Device Shell")
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap_cluster_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_cluster_sources(clusters: typing.Set[str],
cluster_sources: typing.Set[str] = set()

for cluster in clusters:
if not cluster in source_map:
if cluster not in source_map:
raise ValueError("Unhandled %s cluster: %s"
" (hint: add to src/app/zap_cluster_list.py)" % (side, cluster))

Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/chip/yaml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, test_step):
raise ActionCreationError(f'Default cluster {test_step.cluster} {test_step.command}, not supported')

async def run_action(self, dev_ctrl: ChipDeviceController) -> _ActionResult:
resp = await _PSEUDO_CLUSTERS.execute(self._test_step)
_ = await _PSEUDO_CLUSTERS.execute(self._test_step)
return _ActionResult(status=_ActionStatus.SUCCESS, response=None)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

# isort: off

from chip import ChipDeviceCtrl # Needed before chip.FabricAdmin
from chip import ChipDeviceCtrl # Needed before chip.FabricAdmin # noqa: F401
import chip.FabricAdmin # Needed before chip.CertificateAuthority

# isort: on

import chip.CertificateAuthority
import chip.logging
import chip.native
from chip.ChipStack import *
from chip.ChipStack import ChipStack
from chip.yaml.runner import ReplTestRunner
from matter_yamltests.runner import TestRunner

Expand All @@ -45,7 +45,7 @@ async def start(self):

commission_device = False
if len(certificate_authority_manager.activeCaList) == 0:
if self._commission_on_network_dut == False:
if self._commission_on_network_dut is False:
raise Exception(
'Provided repl storage does not contain certificate. Without commission_on_network_dut, there is no reachable DUT')
certificate_authority_manager.NewCertificateAuthority()
Expand Down
1 change: 0 additions & 1 deletion src/setup_payload/python/generate_setup_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import Base38
from bitarray import bitarray
from bitarray.util import ba2int
from stdnum.verhoeff import calc_check_digit

# See section 5.1.4.1 Manual Pairing Code in the Matter specification v1.0
Expand Down