Skip to content

Commit 613dc4e

Browse files
authored
Flake8 fix errors in the other Python files (project-chip#27890)
1 parent ab4509c commit 613dc4e

File tree

11 files changed

+15
-37
lines changed

11 files changed

+15
-37
lines changed

.flake8

-18
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,3 @@ exclude = third_party
44
.*
55
out/*
66
./examples/common/QRCode/*
7-
# temporarily scan only directories with fixed files
8-
# TODO: Remove the paths below when all bugs are fixed
9-
build/chip/java/tests/*
10-
build/chip/linux/*
11-
build/config/linux/*
12-
credentials/fetch-paa-certs-from-dcl.py
13-
docs/_extensions/external_content.py
14-
examples/common/pigweed/rpc_console/py/chip_rpc/console.py
15-
examples/lighting-app/python/lighting.py
16-
src/app/zap_cluster_list.py
17-
src/controller/python/chip/yaml/__init__.py
18-
src/controller/python/chip/yaml/format_converter.py
19-
src/controller/python/chip/yaml/runner.py
20-
src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py
21-
src/lib/asn1/gen_asn1oid.py
22-
src/pybindings/pycontroller/build-chip-wheel.py
23-
src/pybindings/pycontroller/pychip/__init__.py
24-
src/setup_payload/python/generate_setup_payload.py

build/chip/linux/gen_gdbus_wrapper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def main(argv):
6565
] + extra_args + [options.input_file]
6666
subprocess.check_call(gdbus_args)
6767
sed_args = ["sed", "-i",
68-
"s/config\.h/BuildConfig.h/g", options.output_c]
68+
r"s/config\.h/BuildConfig.h/g", options.output_c]
6969
if sys.platform == "darwin":
7070
sed_args = ["sed", "-i", "",
71-
"s/config\.h/BuildConfig.h/g", options.output_c]
71+
r"s/config\.h/BuildConfig.h/g", options.output_c]
7272
subprocess.check_call(sed_args)
7373

7474
if options.output_h:

build/config/linux/pkg-config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def MatchesAnyRegexp(flag, list_of_regexps):
108108
"""Returns true if the first argument matches any regular expression in the
109109
given list."""
110110
for regexp in list_of_regexps:
111-
if regexp.search(flag) != None:
111+
if regexp.search(flag) is not None:
112112
return True
113113
return False
114114

@@ -145,7 +145,7 @@ def main():
145145

146146
# Make a list of regular expressions to strip out.
147147
strip_out = []
148-
if options.strip_out != None:
148+
if options.strip_out is not None:
149149
for regexp in options.strip_out:
150150
strip_out.append(re.compile(regexp))
151151

credentials/fetch-paa-certs-from-dcl.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import re
2727
import subprocess
2828
import sys
29-
from contextlib import nullcontext
3029

3130
import click
3231
import requests

docs/_extensions/external_content.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def adjust_includes(
8181

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

8787
# for files that are being copied modify reference to and out of /docs

examples/common/pigweed/rpc_console/py/chip_rpc/console.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ def write_to_output(data: bytes,
304304

305305
def _read_raw_serial(read: Callable[[], bytes], output):
306306
"""Continuously read and pass to output."""
307-
with ThreadPoolExecutor() as executor:
307+
with ThreadPoolExecutor() as _:
308308
while True:
309309
try:
310310
data = read()
311-
except Exception as exc: # pylint: disable=broad-except
311+
except Exception: # pylint: disable=broad-except
312312
continue
313313
if data:
314314
output(data)

examples/lighting-app/python/lighting.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
import textwrap
2222
import threading
2323
from cmd import Cmd
24-
from ctypes import CFUNCTYPE, c_char_p, c_int32, c_uint8
2524

26-
from chip.exceptions import ChipStackError
27-
from chip.server import GetLibraryHandle, NativeLibraryHandleMethodArguments, PostAttributeChangeCallback
28-
from dali.address import Broadcast, Short
25+
from chip.server import GetLibraryHandle, PostAttributeChangeCallback
26+
from dali.address import Broadcast
2927
from dali.driver.hid import tridonic
3028
from dali.gear.general import DAPC, Off, RecallMaxLevel
3129

@@ -206,7 +204,7 @@ def __init__(self):
206204

207205

208206
if __name__ == "__main__":
209-
l = Lighting()
207+
lighting = Lighting()
210208

211209
lightMgrCmd = LightingMgrCmd()
212210
print("Chip Lighting Device Shell")

src/app/zap_cluster_list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_cluster_sources(clusters: typing.Set[str],
2121
cluster_sources: typing.Set[str] = set()
2222

2323
for cluster in clusters:
24-
if not cluster in source_map:
24+
if cluster not in source_map:
2525
raise ValueError("Unhandled %s cluster: %s"
2626
" (hint: add to src/app/zap_cluster_list.py)" % (side, cluster))
2727

src/controller/python/chip/yaml/runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def __init__(self, test_step):
129129
raise ActionCreationError(f'Default cluster {test_step.cluster} {test_step.command}, not supported')
130130

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

135135

src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
# isort: off
1616

17-
from chip import ChipDeviceCtrl # Needed before chip.FabricAdmin
17+
from chip import ChipDeviceCtrl # Needed before chip.FabricAdmin # noqa: F401
1818
import chip.FabricAdmin # Needed before chip.CertificateAuthority
1919

2020
# isort: on
2121

2222
import chip.CertificateAuthority
2323
import chip.logging
2424
import chip.native
25-
from chip.ChipStack import *
25+
from chip.ChipStack import ChipStack
2626
from chip.yaml.runner import ReplTestRunner
2727
from matter_yamltests.runner import TestRunner
2828

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

4646
commission_device = False
4747
if len(certificate_authority_manager.activeCaList) == 0:
48-
if self._commission_on_network_dut == False:
48+
if self._commission_on_network_dut is False:
4949
raise Exception(
5050
'Provided repl storage does not contain certificate. Without commission_on_network_dut, there is no reachable DUT')
5151
certificate_authority_manager.NewCertificateAuthority()

src/setup_payload/python/generate_setup_payload.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import Base38
2323
from bitarray import bitarray
24-
from bitarray.util import ba2int
2524
from stdnum.verhoeff import calc_check_digit
2625

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

0 commit comments

Comments
 (0)