Skip to content

Commit 1101412

Browse files
DamMicSzmpull[bot]
authored andcommitted
Flake8 fixes Python error files in the scripts directory
1 parent 3badf33 commit 1101412

19 files changed

+34
-68
lines changed

.flake8

-21
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ max-line-length = 132
33
exclude = third_party
44
.*
55
out/*
6-
scripts/idl/*
76
./examples/common/QRCode/*
87
# temporarily scan only directories with fixed files
98
# TODO: Remove the paths below when all bugs are fixed
@@ -15,26 +14,6 @@ exclude = third_party
1514
docs/_extensions/external_content.py
1615
examples/common/pigweed/rpc_console/py/chip_rpc/console.py
1716
examples/lighting-app/python/lighting.py
18-
scripts/build/build/target.py
19-
scripts/build/build/targets.py
20-
scripts/build/builders/android.py
21-
scripts/build/builders/bouffalolab.py
22-
scripts/build/builders/cc13x2x7_26x2x7.py
23-
scripts/build/builders/genio.py
24-
scripts/build/builders/gn.py
25-
scripts/build/builders/imx.py
26-
scripts/build/builders/infineon.py
27-
scripts/codegen.py
28-
scripts/codepregen.py
29-
scripts/error_table.py
30-
scripts/examples/gn_to_cmakelists.py
31-
scripts/flashing/bouffalolab_firmware_utils.py
32-
scripts/flashing/cyw30739_firmware_utils.py
33-
scripts/gen_chip_version.py
34-
scripts/helpers/bloat_check.py
35-
scripts/pregenerate/using_codegen.py
36-
scripts/pregenerate/using_zap.py
37-
scripts/run-clang-tidy-on-compile-commands.py
3817
scripts/tools/check_zcl_file_sync.py
3918
scripts/tools/convert_ini.py
4019
scripts/tools/memory/memdf/__init__.py

scripts/build/build/targets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def BuildQorvoTarget():
543543
TargetPart('qpg6105', board=QpgBoard.QPG6105),
544544
])
545545

546-
# apps
546+
# apps
547547
target.AppendFixedTargets([
548548
TargetPart('lock', app=QpgApp.LOCK),
549549
TargetPart('light', app=QpgApp.LIGHT),

scripts/build/builders/android.py

-2
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,6 @@ def generate(self):
396396
title="Accepting NDK licenses @ tools",
397397
)
398398

399-
app_dir = os.path.join(self.root, "examples/", self.app.AppName())
400-
401399
def stripSymbols(self):
402400
output_libs_dir = os.path.join(
403401
self.output_dir,

scripts/build/builders/bouffalolab.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import logging
1616
import os
17-
import platform
1817
from enum import Enum, auto
1918

2019
from .gn import GnBuilder

scripts/build/builders/cc13x2x7_26x2x7.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def GnBuildArgs(self):
8181
'ti_sysconfig_root="%s"' % os.environ['TI_SYSCONFIG_ROOT'],
8282
]
8383

84-
if self.openthread_ftd == None:
84+
if self.openthread_ftd is None:
8585
pass
8686
elif self.openthread_ftd:
8787
args.append('chip_openthread_ftd=true')

scripts/build/builders/genio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def AppNamePrefix(self):
2727
def FlashBundleName(self):
2828
if self == GenioApp.LIGHT:
2929
return 'lighting_app.flashbundle.txt'
30-
elif self == GEnioApp.SHELL:
30+
elif self == GenioApp.SHELL:
3131
return 'shell.flashbundle.txt'
3232
else:
3333
raise Exception('Unknown app type: %r' % self)

scripts/build/builders/gn.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
1615
import shlex
1716

1817
from .builder import Builder

scripts/build/builders/infineon.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ def build_outputs(self):
111111
def flashbundle(self):
112112
with open(os.path.join(self.output_dir, self.app.FlashBundleName()), 'r') as fp:
113113
return {
114-
l.strip(): os.path.join(self.output_dir, l.strip()) for l in fp.readlines() if l.strip()
114+
line.strip(): os.path.join(self.output_dir, line.strip()) for line in fp.readlines() if line.strip()
115115
}

scripts/codegen.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ def main(log_level, generator, option, output_dir, dry_run, name_only, expected_
152152
if expected_outputs:
153153
with open(expected_outputs, 'rt') as fin:
154154
expected = set()
155-
for l in fin.readlines():
156-
l = l.strip()
157-
if l:
158-
expected.add(l)
155+
for line in fin.readlines():
156+
line = line.strip()
157+
if line:
158+
expected.add(line)
159159

160160
if expected != storage.generated_paths:
161161
logging.fatal("expected and generated files do not match.")

scripts/codepregen.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import enum
1817
import itertools
1918
import logging
2019
import multiprocessing
@@ -25,8 +24,7 @@
2524

2625
try:
2726
from pregenerate import FindPregenerationTargets, TargetFilter
28-
except:
29-
import os
27+
except ImportError:
3028
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
3129
from pregenerate import FindPregenerationTargets, TargetFilter
3230

@@ -36,7 +34,7 @@
3634
try:
3735
import coloredlogs
3836
_has_coloredlogs = True
39-
except:
37+
except ImportError:
4038
_has_coloredlogs = False
4139

4240
# Supported log levels, mapping string values required for argument

scripts/error_table.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from enum import IntEnum
2929
from operator import attrgetter
3030
from pathlib import Path
31-
from xml.etree.ElementInclude import include
3231

3332

3433
@dataclass

scripts/examples/gn_to_cmakelists.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def Escape(c):
7676
return ''.join(map(Escape, a))
7777

7878

79-
def RemoveByPrefix(l, prefixs):
80-
ret = l
79+
def RemoveByPrefix(list, prefixs):
80+
ret = list
8181
for pre in prefixs:
8282
ret = [x for x in ret if not x.startswith(pre)]
8383

@@ -450,7 +450,7 @@ def WriteCopy(out, target, project, sources, synthetic_dependencies):
450450

451451
def WriteCompilerFlags(out, target, project, sources):
452452
# Hack, set linker language to c if no c or cxx files present.
453-
if not 'c' in sources and not 'cxx' in sources:
453+
if 'c' not in sources and 'cxx' not in sources:
454454
SetCurrentTargetProperty(out, 'LINKER_LANGUAGE', ['C'])
455455

456456
# Mark uncompiled sources as uncompiled.

scripts/flashing/bouffalolab_firmware_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def actions(self):
207207
continue
208208

209209
if value:
210-
if value == True:
210+
if value is True:
211211
arg = ("--{}".format(key)).strip()
212212
elif isinstance(value, pathlib.Path):
213213
arg = ("--{}={}".format(key, os.path.join(os.getcwd(), str(value)))).strip()

scripts/flashing/cyw30739_firmware_utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
For `Flasher`, see the class documentation.
2020
"""
2121

22-
import os
2322
import sys
2423

2524
import firmware_utils

scripts/gen_chip_version.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
import optparse
1818
import sys
1919

20-
TEMPLATE = '''/*
20+
TEMPLATE = r'''/*
2121
*
2222
* Copyright (c) 2020 Project CHIP Authors
2323
* All rights reserved.
2424
*
25-
* Licensed under the Apache License, Version 2.0 (the \"License\");
25+
* Licensed under the Apache License, Version 2.0 (the "License");
2626
* you may not use this file except in compliance with the License.
2727
* You may obtain a copy of the License at
2828
*
2929
* http://www.apache.org/licenses/LICENSE-2.0
3030
*
3131
* Unless required by applicable law or agreed to in writing, software
32-
* distributed under the License is distributed on an \"AS IS\" BASIS,
32+
* distributed under the License is distributed on an "AS IS" BASIS,
3333
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3434
* See the License for the specific language governing permissions and
3535
* limitations under the License.
@@ -94,9 +94,9 @@
9494
* \@endcode
9595
*
9696
*/
97-
#define CHIP_VERSION_CODE_ENCODE(major, minor, patch) \\
98-
((((major) & _CHIP_VERSION_CODE_MAJOR_MASK) << _CHIP_VERSION_CODE_MAJOR_SHIFT) | \\
99-
(((minor) & _CHIP_VERSION_CODE_MINOR_MASK) << _CHIP_VERSION_CODE_MINOR_SHIFT) | \\
97+
#define CHIP_VERSION_CODE_ENCODE(major, minor, patch) \
98+
((((major) & _CHIP_VERSION_CODE_MAJOR_MASK) << _CHIP_VERSION_CODE_MAJOR_SHIFT) | \
99+
(((minor) & _CHIP_VERSION_CODE_MINOR_MASK) << _CHIP_VERSION_CODE_MINOR_SHIFT) | \
100100
(((patch) & _CHIP_VERSION_CODE_PATCH_MASK) << _CHIP_VERSION_CODE_PATCH_SHIFT))
101101
102102
/**
@@ -160,7 +160,7 @@
160160
* The CHIP version extra component, as a quoted C string.
161161
*
162162
*/
163-
#define CHIP_VERSION_EXTRA \"%(chip_extra)s\"
163+
#define CHIP_VERSION_EXTRA "%(chip_extra)s"
164164
165165
/**
166166
* \@def CHIP_VERSION_STRING
@@ -169,7 +169,7 @@
169169
* The CHIP version, as a quoted C string.
170170
*
171171
*/
172-
#define CHIP_VERSION_STRING \"%(chip_version)s\"
172+
#define CHIP_VERSION_STRING "%(chip_version)s"
173173
174174
/**
175175
* \@def CHIP_VERSION_CODE
@@ -191,10 +191,10 @@
191191
* \@endcode
192192
*
193193
*/
194-
#define CHIP_VERSION_CODE CHIP_VERSION_CODE_ENCODE( \\
195-
CHIP_VERSION_MAJOR, \\
196-
CHIP_VERSION_MINOR, \\
197-
CHIP_VERSION_PATCH \\
194+
#define CHIP_VERSION_CODE CHIP_VERSION_CODE_ENCODE( \
195+
CHIP_VERSION_MAJOR, \
196+
CHIP_VERSION_MINOR, \
197+
CHIP_VERSION_PATCH \
198198
)
199199
200200
#endif /* CHIP_VERSION_H_ */

scripts/helpers/bloat_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def main():
357357
# Output processed.
358358
a.delete()
359359

360-
except Exception as e:
360+
except Exception:
361361
tb = traceback.format_exc()
362362
logging.warning('Failed to process bloat report: %s', tb)
363363

scripts/pregenerate/using_codegen.py

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

1515
import logging
1616
import os
17-
import shlex
18-
import subprocess
19-
from enum import Enum, auto
2017

2118
from .types import IdlFileType, InputIdlFile
2219

scripts/pregenerate/using_zap.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
import logging
1616
import os
17-
import shlex
18-
import subprocess
1917
from enum import Enum, auto
2018

2119
from .types import IdlFileType, InputIdlFile

scripts/run-clang-tidy-on-compile-commands.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,16 @@ def Check(self):
147147
"Use -system-headers to display errors from system headers as well.",
148148
]
149149

150-
for l in err.decode('utf-8').split('\n'):
151-
l = l.strip()
150+
for line in err.decode('utf-8').split('\n'):
151+
line = line.strip()
152152

153-
if any(map(lambda s: s in l, skip_strings)):
153+
if any(map(lambda s: s in line, skip_strings)):
154154
continue
155155

156-
if not l:
156+
if not line:
157157
continue # no empty lines
158158

159-
logging.warning('TIDY %s: %s', self.file, l)
159+
logging.warning('TIDY %s: %s', self.file, line)
160160

161161
if proc.returncode != 0:
162162
if proc.returncode < 0:
@@ -168,7 +168,7 @@ def Check(self):
168168
"Tidy %s ended with code %d", self.file, proc.returncode
169169
)
170170
return TidyResult(self.full_path, False)
171-
except:
171+
except Exception:
172172
traceback.print_exc()
173173
return TidyResult(self.full_path, False)
174174

@@ -198,7 +198,7 @@ def find_darwin_gcc_sysroot():
198198
if not line.startswith('Path: '):
199199
continue
200200
path = line[line.find(': ')+2:]
201-
if not '/MacOSX.platform/' in path:
201+
if '/MacOSX.platform/' not in path:
202202
continue
203203
logging.info("Found %s" % path)
204204
return path

0 commit comments

Comments
 (0)