scripts: Remove unused variables in all Python scripts
Discovered with pylint3.
Use the placeholder name '_' for unproblematic unused variables. It's
what I'm used to, and pylint knows not to flag it.
Python tip:
for i in range(n):
some_list.append(0)
can be replaced with
some_list += n*[0]
Similarly, 3*'\t' gives '\t\t\t'.
(Relevant here because pylint flagged the loop index as unused.)
To do integer division in Python 3, use // instead of /.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
diff --git a/scripts/gen_app_partitions.py b/scripts/gen_app_partitions.py
index 2ce38e1..99a10c3 100644
--- a/scripts/gen_app_partitions.py
+++ b/scripts/gen_app_partitions.py
@@ -128,7 +128,7 @@
def parse_obj_files(partitions):
# Iterate over all object files to find partitions
- for dirpath, dirs, files in os.walk(args.directory):
+ for dirpath, _, files in os.walk(args.directory):
for filename in files:
if re.match(".*\.obj$",filename):
fullname = os.path.join(dirpath, filename)
@@ -143,7 +143,7 @@
if isinstance(s, SymbolTableSection)]
for section in symbol_tbls:
- for nsym, symbol in enumerate(section.iter_symbols()):
+ for symbol in section.iter_symbols():
if symbol['st_shndx'] != "SHN_ABS":
continue
@@ -206,7 +206,6 @@
def main():
parse_args()
- linker_file = args.output
partitions = {}
if args.directory is not None: