Skip to content

Commit

Permalink
Flake8 fixes Python error files in the scripts directory
Browse files Browse the repository at this point in the history
  • Loading branch information
DamMicSzm authored and pull[bot] committed Sep 1, 2023
1 parent 7a9c4b3 commit 1416582
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 68 deletions.
21 changes: 0 additions & 21 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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
Expand All @@ -15,26 +14,6 @@ exclude = third_party
docs/_extensions/external_content.py
examples/common/pigweed/rpc_console/py/chip_rpc/console.py
examples/lighting-app/python/lighting.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/genio.py
scripts/build/builders/gn.py
scripts/build/builders/imx.py
scripts/build/builders/infineon.py
scripts/codegen.py
scripts/codepregen.py
scripts/error_table.py
scripts/examples/gn_to_cmakelists.py
scripts/flashing/bouffalolab_firmware_utils.py
scripts/flashing/cyw30739_firmware_utils.py
scripts/gen_chip_version.py
scripts/helpers/bloat_check.py
scripts/pregenerate/using_codegen.py
scripts/pregenerate/using_zap.py
scripts/run-clang-tidy-on-compile-commands.py
scripts/tools/check_zcl_file_sync.py
scripts/tools/convert_ini.py
scripts/tools/memory/memdf/__init__.py
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def BuildQorvoTarget():
TargetPart('qpg6105', board=QpgBoard.QPG6105),
])

# apps
# apps
target.AppendFixedTargets([
TargetPart('lock', app=QpgApp.LOCK),
TargetPart('light', app=QpgApp.LIGHT),
Expand Down
2 changes: 0 additions & 2 deletions scripts/build/builders/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ def generate(self):
title="Accepting NDK licenses @ tools",
)

app_dir = os.path.join(self.root, "examples/", self.app.AppName())

def stripSymbols(self):
output_libs_dir = os.path.join(
self.output_dir,
Expand Down
1 change: 0 additions & 1 deletion scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import logging
import os
import platform
from enum import Enum, auto

from .gn import GnBuilder
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/cc13x2x7_26x2x7.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def GnBuildArgs(self):
'ti_sysconfig_root="%s"' % os.environ['TI_SYSCONFIG_ROOT'],
]

if self.openthread_ftd == None:
if self.openthread_ftd is None:
pass
elif self.openthread_ftd:
args.append('chip_openthread_ftd=true')
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/genio.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def AppNamePrefix(self):
def FlashBundleName(self):
if self == GenioApp.LIGHT:
return 'lighting_app.flashbundle.txt'
elif self == GEnioApp.SHELL:
elif self == GenioApp.SHELL:
return 'shell.flashbundle.txt'
else:
raise Exception('Unknown app type: %r' % self)
Expand Down
1 change: 0 additions & 1 deletion scripts/build/builders/gn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import shlex

from .builder import Builder
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/builders/infineon.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ def build_outputs(self):
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()
}
8 changes: 4 additions & 4 deletions scripts/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ def main(log_level, generator, option, output_dir, dry_run, name_only, expected_
if expected_outputs:
with open(expected_outputs, 'rt') as fin:
expected = set()
for l in fin.readlines():
l = l.strip()
if l:
expected.add(l)
for line in fin.readlines():
line = line.strip()
if line:
expected.add(line)

if expected != storage.generated_paths:
logging.fatal("expected and generated files do not match.")
Expand Down
6 changes: 2 additions & 4 deletions scripts/codepregen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import enum
import itertools
import logging
import multiprocessing
Expand All @@ -25,8 +24,7 @@

try:
from pregenerate import FindPregenerationTargets, TargetFilter
except:
import os
except ImportError:
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from pregenerate import FindPregenerationTargets, TargetFilter

Expand All @@ -36,7 +34,7 @@
try:
import coloredlogs
_has_coloredlogs = True
except:
except ImportError:
_has_coloredlogs = False

# Supported log levels, mapping string values required for argument
Expand Down
1 change: 0 additions & 1 deletion scripts/error_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from enum import IntEnum
from operator import attrgetter
from pathlib import Path
from xml.etree.ElementInclude import include


@dataclass
Expand Down
6 changes: 3 additions & 3 deletions scripts/examples/gn_to_cmakelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def Escape(c):
return ''.join(map(Escape, a))


def RemoveByPrefix(l, prefixs):
ret = l
def RemoveByPrefix(list, prefixs):
ret = list
for pre in prefixs:
ret = [x for x in ret if not x.startswith(pre)]

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

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

# Mark uncompiled sources as uncompiled.
Expand Down
2 changes: 1 addition & 1 deletion scripts/flashing/bouffalolab_firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def actions(self):
continue

if value:
if value == True:
if value is True:
arg = ("--{}".format(key)).strip()
elif isinstance(value, pathlib.Path):
arg = ("--{}={}".format(key, os.path.join(os.getcwd(), str(value)))).strip()
Expand Down
1 change: 0 additions & 1 deletion scripts/flashing/cyw30739_firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
For `Flasher`, see the class documentation.
"""

import os
import sys

import firmware_utils
Expand Down
24 changes: 12 additions & 12 deletions scripts/gen_chip_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
import optparse
import sys

TEMPLATE = '''/*
TEMPLATE = r'''/*
*
* Copyright (c) 2020 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the \"License\");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an \"AS IS\" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
Expand Down Expand Up @@ -94,9 +94,9 @@
* \@endcode
*
*/
#define CHIP_VERSION_CODE_ENCODE(major, minor, patch) \\
((((major) & _CHIP_VERSION_CODE_MAJOR_MASK) << _CHIP_VERSION_CODE_MAJOR_SHIFT) | \\
(((minor) & _CHIP_VERSION_CODE_MINOR_MASK) << _CHIP_VERSION_CODE_MINOR_SHIFT) | \\
#define CHIP_VERSION_CODE_ENCODE(major, minor, patch) \
((((major) & _CHIP_VERSION_CODE_MAJOR_MASK) << _CHIP_VERSION_CODE_MAJOR_SHIFT) | \
(((minor) & _CHIP_VERSION_CODE_MINOR_MASK) << _CHIP_VERSION_CODE_MINOR_SHIFT) | \
(((patch) & _CHIP_VERSION_CODE_PATCH_MASK) << _CHIP_VERSION_CODE_PATCH_SHIFT))
/**
Expand Down Expand Up @@ -160,7 +160,7 @@
* The CHIP version extra component, as a quoted C string.
*
*/
#define CHIP_VERSION_EXTRA \"%(chip_extra)s\"
#define CHIP_VERSION_EXTRA "%(chip_extra)s"
/**
* \@def CHIP_VERSION_STRING
Expand All @@ -169,7 +169,7 @@
* The CHIP version, as a quoted C string.
*
*/
#define CHIP_VERSION_STRING \"%(chip_version)s\"
#define CHIP_VERSION_STRING "%(chip_version)s"
/**
* \@def CHIP_VERSION_CODE
Expand All @@ -191,10 +191,10 @@
* \@endcode
*
*/
#define CHIP_VERSION_CODE CHIP_VERSION_CODE_ENCODE( \\
CHIP_VERSION_MAJOR, \\
CHIP_VERSION_MINOR, \\
CHIP_VERSION_PATCH \\
#define CHIP_VERSION_CODE CHIP_VERSION_CODE_ENCODE( \
CHIP_VERSION_MAJOR, \
CHIP_VERSION_MINOR, \
CHIP_VERSION_PATCH \
)
#endif /* CHIP_VERSION_H_ */
Expand Down
2 changes: 1 addition & 1 deletion scripts/helpers/bloat_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def main():
# Output processed.
a.delete()

except Exception as e:
except Exception:
tb = traceback.format_exc()
logging.warning('Failed to process bloat report: %s', tb)

Expand Down
3 changes: 0 additions & 3 deletions scripts/pregenerate/using_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

import logging
import os
import shlex
import subprocess
from enum import Enum, auto

from .types import IdlFileType, InputIdlFile

Expand Down
2 changes: 0 additions & 2 deletions scripts/pregenerate/using_zap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import logging
import os
import shlex
import subprocess
from enum import Enum, auto

from .types import IdlFileType, InputIdlFile
Expand Down
14 changes: 7 additions & 7 deletions scripts/run-clang-tidy-on-compile-commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ def Check(self):
"Use -system-headers to display errors from system headers as well.",
]

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

if any(map(lambda s: s in l, skip_strings)):
if any(map(lambda s: s in line, skip_strings)):
continue

if not l:
if not line:
continue # no empty lines

logging.warning('TIDY %s: %s', self.file, l)
logging.warning('TIDY %s: %s', self.file, line)

if proc.returncode != 0:
if proc.returncode < 0:
Expand All @@ -168,7 +168,7 @@ def Check(self):
"Tidy %s ended with code %d", self.file, proc.returncode
)
return TidyResult(self.full_path, False)
except:
except Exception:
traceback.print_exc()
return TidyResult(self.full_path, False)

Expand Down Expand Up @@ -198,7 +198,7 @@ def find_darwin_gcc_sysroot():
if not line.startswith('Path: '):
continue
path = line[line.find(': ')+2:]
if not '/MacOSX.platform/' in path:
if '/MacOSX.platform/' not in path:
continue
logging.info("Found %s" % path)
return path
Expand Down

0 comments on commit 1416582

Please sign in to comment.