Skip to content

Commit af6bf8e

Browse files
fpistmmassonal
authored andcommitted
fix: error and warning raised by flake8
Signed-off-by: Frederic Pillon <[email protected]> Signed-off-by: Alexis Masson <[email protected]>
1 parent 7656e46 commit af6bf8e

12 files changed

+46
-22
lines changed

Diff for: cmake/scripts/.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

Diff for: cmake/scripts/ccwrapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
shargs = parser.parse_args()
2424

25-
logline = re.compile("^\.* .+$") # a series of dots, a space, a filename
25+
logline = re.compile(r"^\.* .+$") # a series of dots, a space, a filename
2626

2727

2828
proc = subprocess.run(shargs.cmd, capture_output=True, encoding="ascii")

Diff for: cmake/scripts/cmake_core.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env python3
22

33
import argparse
4-
import sys
54
from pathlib import Path
65
from jinja2 import Environment, FileSystemLoader
7-
from cmake_gen import *
6+
from cmake_gen import config_for_bareflat, render
87

98
script_path = Path(__file__).parent.resolve()
109

Diff for: cmake/scripts/cmake_easy_setup.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
print(
4747
"""
4848
Warning: you did not specify which board you were targeting;
49-
please review the generated CMakeLists.txt to remove the placeholder value before calling `cmake`.
49+
please review the generated CMakeLists.txt to remove the placeholder
50+
value before calling `cmake`.
5051
"""
5152
)
5253

@@ -121,8 +122,20 @@ def get_boards(boardstxt):
121122
libpaths[line["location"]] = pathlib.Path(line["dir"])
122123

123124
# platform lib path is already known, obviously, since that's where this script resides
124-
userlibs = pathlib.Path(libpaths["user"]).resolve()
125-
libs = [u.name for u in userlibs.iterdir() if u.is_dir()]
125+
userlibs = pathlib.Path(libpaths["user"])
126+
if userlibs.exists():
127+
userlibs = userlibs.resolve()
128+
libs = [u.name for u in userlibs.iterdir() if u.is_dir()]
129+
else:
130+
print(
131+
f"""Warning: Cannot find {userlibs}.
132+
This has likely to do with your arduino-cli configuration.
133+
Please refer to the following link for setup details:
134+
https://arduino.github.io/arduino-cli/0.26/getting-started/#create-a-configuration-file
135+
"""
136+
)
137+
libs = list()
138+
126139
corepath = pathlib.Path(__file__).parent.parent.parent.resolve()
127140

128141
j2_env = Environment(

Diff for: cmake/scripts/cmake_libs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
from pathlib import Path
55
from jinja2 import Environment, FileSystemLoader
6-
from cmake_gen import *
6+
from cmake_gen import autoconfig, render
77

88
script_path = Path(__file__).parent.resolve()
99

Diff for: cmake/scripts/cmake_updater_hook.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env python3
22

33
"""
4-
This file centralizes all the operations needed to regenerate the CMakeLists.txt scattered along this repo.
4+
This file centralizes all the operations needed to regenerate the CMakeLists.txt
5+
scattered along this repo.
56
Hint: it would be a good practice to run it before committing...
67
"""
78

Diff for: cmake/scripts/cmake_variant.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
from pathlib import Path
55
from jinja2 import Environment, FileSystemLoader
6-
from cmake_gen import *
6+
from cmake_gen import config_for_bareflat, render
77

88
script_path = Path(__file__).parent.resolve()
99

Diff for: cmake/scripts/generate_header.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import argparse
44
import pathlib
5-
import subprocess
65

76
parser = argparse.ArgumentParser()
87
parser.add_argument(

Diff for: cmake/scripts/parse_boards.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __getattr__(self, attr):
2525
return self.__getitem__(attr)
2626

2727
def __setattr__(self, attr, val):
28-
return self.__setitem__(item, attr)
28+
return self.__setitem__(val, attr)
2929

3030
def set_default_entries(self, mothercfg):
3131
for k, v in mothercfg.items():
@@ -51,9 +51,13 @@ def evaluate_entries(self, wrt=None):
5151
self[k].evaluate_entries(wrt)
5252

5353

54+
def default_reject(x):
55+
return False
56+
57+
5458
def parse_file(infile, reject=None):
5559
if reject is None:
56-
reject = lambda x: False
60+
reject = default_reject
5761

5862
config = Configuration()
5963

Diff for: cmake/scripts/sizereport.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949

5050
print(
5151
f"""
52-
Sketch uses {allsz} bytes ({allsz/shargs.progmem:.0%}) of program storage space. Maximum is {shargs.progmem} bytes.
53-
Global variables use {datasz} bytes ({datasz/shargs.datamem:.0%}) of dynamic memory, leaving {shargs.datamem-datasz} bytes for local variables. Maximum is {shargs.datamem} bytes.
52+
Sketch uses {allsz} bytes ({allsz/shargs.progmem:.0%}) of program storage space. \
53+
Maximum is {shargs.progmem} bytes.
54+
Global variables use {datasz} bytes ({datasz/shargs.datamem:.0%}) of dynamic memory, \
55+
leaving {shargs.datamem-datasz} bytes for local variables. \
56+
Maximum is {shargs.datamem} bytes.
5457
"""
5558
)

Diff for: cmake/scripts/syms.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ def parse_file(mapf):
4343
demander, sym = line.strip().rsplit(") (", 1)
4444
demander = demander + ")"
4545
sym = "(" + sym
46-
except:
46+
except Exception:
4747
continue
4848
else:
4949
provider = line.strip()
5050

5151
if provider and demander and sym:
52-
objdemander = demander.rsplit("/", 1)[
53-
1
54-
] # .split("(")[0] gets the lib ; without this you get the obj
52+
# .split("(")[0] gets the lib ; without this you get the obj
53+
objdemander = demander.rsplit("/", 1)[1]
5554
objprovider = provider.rsplit("/", 1)[1]
5655
libdemander = objdemander.split("(")[0]
5756
libprovider = objprovider.split("(")[0]

Diff for: cmake/scripts/update_boarddb.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ def get_fpconf(config):
1616

1717
def boardstxt_filter(key):
1818
# Remove menu entry labels
19-
# In our data model, they conflict with the actual configuration they are associated to
20-
# i.e. Nucleo_144.menu.pnum.NUCLEO_F207ZG would be both a string ("Nucleo F207ZG")
19+
# In our data model, they conflict with the actual configuration
20+
# they are associated to
21+
# i.e. Nucleo_144.menu.pnum.NUCLEO_F207ZG would be both
22+
# a string ("Nucleo F207ZG")
2123
# and a dict (.build.variant_h=..., .upload.maximum_size=...)
2224

2325
if key[0] == "menu":
@@ -120,7 +122,8 @@ def regenerate_template(config, infile, outfile):
120122
famcfg.set_default_entries(platformtxt_cfg)
121123

122124
inherit_fam = famcfg.copy()
123-
# shallow copy; we don't want to impact famcfg so we have to copy before edit/del
125+
# shallow copy;
126+
# we don't want to impact famcfg so we have to copy before edit/del
124127
inherit_fam["menu"] = inherit_fam["menu"].copy()
125128
# del what you iterate over (otherwise you get infinite nesting)
126129
del inherit_fam["menu"]["pnum"]
@@ -142,7 +145,8 @@ def regenerate_template(config, infile, outfile):
142145
labelcfg.set_default_entries(inherit_board)
143146
labelcfg.evaluate_entries()
144147

145-
# base config won't manage all the board features, we thus have to mask them out
148+
# base config won't manage all the board features,
149+
# we thus have to mask them out
146150
for feat in BOARD_FEATURES:
147151
boardcfg.build[feat] = ""
148152

0 commit comments

Comments
 (0)