Skip to content

Commit af431b1

Browse files
committed
Linting compliance
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent 865c33b commit af431b1

49 files changed

Lines changed: 691 additions & 239 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/docker/data/tast_parser.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
# along with this library; if not, write to the Free Software Foundation, Inc.,
1818
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919

20-
from functools import partial
21-
import subprocess
22-
import sys
23-
import os
2420
import json
21+
import os
2522
import pwd
23+
import subprocess
24+
import sys
25+
from functools import partial
2626

2727
FAILED_RUN_FILE = "failed_run"
2828
STDERR_FILE = "stderr.log"
@@ -69,7 +69,9 @@ def report_lava(test_data):
6969
if "measurements" in test_data:
7070
lava_test_set_start(test_data["name"])
7171
for measurement in test_data["measurements"]:
72-
report_lava_test_case(measurement["name"], test_data["result"], measurement)
72+
report_lava_test_case(
73+
measurement["name"], test_data["result"], measurement
74+
)
7375
lava_test_set_stop(test_data["name"])
7476
else:
7577
report_lava_test_case(test_data["name"], test_data["result"])
@@ -178,7 +180,9 @@ def parse_test_results():
178180
report_lava_critical("Tast tests run failed, no results")
179181
sys.exit(1)
180182
for test_data in parse_results(results):
181-
results_chart = os.path.join(test_data["outDir"], RESULTS_CHART_FILE)
183+
results_chart = os.path.join(
184+
test_data["outDir"], RESULTS_CHART_FILE
185+
)
182186
if os.path.isfile(results_chart):
183187
with open(results_chart, "r") as rc_file:
184188
rc_data = json.load(rc_file)

kernelci/api/__init__.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import urllib
1313
from typing import Dict, Optional, Sequence
1414

15-
from cloudevents.http import CloudEvent
1615
import requests
16+
from cloudevents.http import CloudEvent
1717
from requests.adapters import HTTPAdapter
1818
from urllib3.util import Retry
1919

@@ -22,7 +22,9 @@
2222
HTTP_ERROR_BODY_SNIPPET = 512
2323

2424

25-
def _http_error_body_snippet(response, max_length: int = HTTP_ERROR_BODY_SNIPPET):
25+
def _http_error_body_snippet(
26+
response, max_length: int = HTTP_ERROR_BODY_SNIPPET
27+
):
2628
"""Return a truncated response body useful for HTTP error logging.
2729
Also try to extract a more specific error message from the body if it's a JSON
2830
with a "detail", "error" or "message" field.
@@ -150,7 +152,10 @@ def _get(self, path, params=None):
150152
session.mount("https://", adapter)
151153

152154
resp = session.get(
153-
url, params=params, headers=self.data.headers, timeout=self.data.timeout
155+
url,
156+
params=params,
157+
headers=self.data.headers,
158+
timeout=self.data.timeout,
154159
)
155160
try:
156161
resp.raise_for_status()
@@ -190,13 +195,19 @@ def _post(self, path, data=None, params=None, json_data=True):
190195
# requests.post, but in this case we have to explicitly
191196
# specify the Content-Type header
192197
if json_data:
193-
headers = self.data.headers | {"Content-Type": "application/json"}
198+
headers = self.data.headers | {
199+
"Content-Type": "application/json"
200+
}
194201
else:
195202
headers = self.data.headers | {
196203
"Content-Type": "application/x-www-form-urlencoded"
197204
}
198205
resp = session.post(
199-
url, data, headers=headers, params=params, timeout=self.data.timeout
206+
url,
207+
data,
208+
headers=headers,
209+
params=params,
210+
timeout=self.data.timeout,
200211
)
201212
else:
202213
# When passing a dict to requests.post, it will
@@ -325,7 +336,9 @@ def _delete(self, path):
325336
session.mount("http://", adapter)
326337
session.mount("https://", adapter)
327338

328-
resp = session.delete(url, headers=self.data.headers, timeout=self.data.timeout)
339+
resp = session.delete(
340+
url, headers=self.data.headers, timeout=self.data.timeout
341+
)
329342
try:
330343
resp.raise_for_status()
331344
except requests.exceptions.HTTPError as err:

kernelci/api/helper.py

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
"""KernelCI API helpers"""
99

10-
from typing import Dict
1110
import json
1211
import os
12+
from typing import Dict
13+
1314
import requests
1415

1516
from . import API
@@ -36,7 +37,9 @@ def merge(primary: dict, secondary: dict):
3637
for key in primary:
3738
result[key] = primary[key]
3839
if key in secondary:
39-
if isinstance(primary[key], dict) and isinstance(secondary[key], dict):
40+
if isinstance(primary[key], dict) and isinstance(
41+
secondary[key], dict
42+
):
4043
result[key] = merge(primary[key], secondary[key])
4144
else:
4245
result[key] = secondary[key]
@@ -62,7 +65,9 @@ def api(self):
6265
"""API object"""
6366
return self._api
6467

65-
def subscribe_filters(self, filters=None, channel="node", promiscuous=False):
68+
def subscribe_filters(
69+
self, filters=None, channel="node", promiscuous=False
70+
):
6671
"""Subscribe to a channel with some added filters"""
6772
sub_id = self.api.subscribe(channel, promiscuous)
6873
self._filters[sub_id] = filters
@@ -140,7 +145,9 @@ def receive_event_node(self, sub_id):
140145
# Crude (provisional) filtering of non-node events
141146
if not node:
142147
continue
143-
if all(self.pubsub_event_filter(sub_id, obj) for obj in [node, event]):
148+
if all(
149+
self.pubsub_event_filter(sub_id, obj) for obj in [node, event]
150+
):
144151
return node, event.get("is_hierarchy")
145152

146153
def _find_container(self, field, node):
@@ -188,7 +195,9 @@ def _is_allowed(self, rules, key, node):
188195
# the node on the basis that its rules aren; t fulfilled
189196
if not base:
190197
if len(allow) > 0:
191-
print(f"rules[{key}]: attribute '{key}' not found in node hierarchy")
198+
print(
199+
f"rules[{key}]: attribute '{key}' not found in node hierarchy"
200+
)
192201
return False
193202
return True
194203

@@ -217,7 +226,9 @@ def _is_allowed(self, rules, key, node):
217226
found = True
218227

219228
if not found:
220-
print(f"rules[{key}]: {key.capitalize()} missing one of {allow}")
229+
print(
230+
f"rules[{key}]: {key.capitalize()} missing one of {allow}"
231+
)
221232
return False
222233

223234
else:
@@ -280,7 +291,10 @@ def _match_combos(self, node, combos):
280291
"""
281292
match = None
282293
for combo in combos:
283-
if node["tree"] == combo["tree"] and node["branch"] == combo["branch"]:
294+
if (
295+
node["tree"] == combo["tree"]
296+
and node["branch"] == combo["branch"]
297+
):
284298
match = combo
285299
break
286300
return match
@@ -415,15 +429,17 @@ def should_create_node(self, rules, node):
415429
rule_major = rules[key]["version"]
416430
rule_minor = rules[key]["patchlevel"]
417431
if key.startswith("min") and (
418-
(major < rule_major) or (major == rule_major and minor < rule_minor)
432+
(major < rule_major)
433+
or (major == rule_major and minor < rule_minor)
419434
):
420435
print(
421436
f"rules[{key}]: Version {major}.{minor} older than minimum version "
422437
f"({rule_major}.{rule_minor})"
423438
)
424439
return False
425440
if key.startswith("max") and (
426-
(major > rule_major) or (major == rule_major and minor > rule_minor)
441+
(major > rule_major)
442+
or (major == rule_major and minor > rule_minor)
427443
):
428444
print(
429445
f"rules[{key}]: Version {major}.{minor} newer than maximum version "
@@ -473,7 +489,9 @@ def _is_job_filtered(self, node):
473489
# * jobfilter contains the job name suffixed with '+'
474490
# * at least one element of the node's 'path' appears in jobilfter
475491
# with a '+' suffix
476-
for filt in (item.rstrip("+") for item in jobfilter if item.endswith("+")):
492+
for filt in (
493+
item.rstrip("+") for item in jobfilter if item.endswith("+")
494+
):
477495
if filt in node["path"] or filt == node["name"]:
478496
return False
479497

@@ -483,7 +501,13 @@ def _is_job_filtered(self, node):
483501

484502
# pylint: disable=too-many-arguments
485503
def create_job_node(
486-
self, job_config, input_node, *, runtime=None, platform=None, retry_counter=0
504+
self,
505+
job_config,
506+
input_node,
507+
*,
508+
runtime=None,
509+
platform=None,
510+
retry_counter=0,
487511
):
488512
"""Create a new job node based on input and configuration"""
489513
jobfilter = input_node.get("jobfilter")
@@ -525,10 +549,14 @@ def create_job_node(
525549
# Test-specific fields inherited from parent node (kbuild or
526550
# job) if available
527551
if job_config.kind == "job":
528-
job_node["data"]["kernel_type"] = input_node["data"].get("kernel_type")
552+
job_node["data"]["kernel_type"] = input_node["data"].get(
553+
"kernel_type"
554+
)
529555
job_node["data"]["arch"] = input_node["data"].get("arch")
530556
job_node["data"]["defconfig"] = input_node["data"].get("defconfig")
531-
job_node["data"]["config_full"] = input_node["data"].get("config_full")
557+
job_node["data"]["config_full"] = input_node["data"].get(
558+
"config_full"
559+
)
532560
job_node["data"]["compiler"] = input_node["data"].get("compiler")
533561
# This information is highly useful, as we might
534562
# extract from it the following, for example:
@@ -574,7 +602,9 @@ def create_job_node(
574602
job_node = self._fsanitize_node_fields(job_node, "commit_message")
575603

576604
try:
577-
job_node["data"] = platform.format_params(job_node["data"], extra_args)
605+
job_node["data"] = platform.format_params(
606+
job_node["data"], extra_args
607+
)
578608
except Exception as error:
579609
print(f"Exception Error, node id: {input_node['id']}, {error}")
580610
raise error

0 commit comments

Comments
 (0)