Skip to content
Snippets Groups Projects
Commit 14eaf45a authored by Tim Jaacks's avatar Tim Jaacks
Browse files

Refactoring: inline immediately returned variables

See for reference:
https://docs.sourcery.ai/Reference/Python/Default-Rules/inline-immediately-returned-variable/
parent f9096a52
No related branches found
No related tags found
1 merge request!293Refactoring: inline immediately returned variables
Pipeline #72206 skipped with stage
......@@ -17,7 +17,6 @@ rule_settings:
- use-fstring-for-concatenation
- merge-dict-assign
- assign-if-exp
- inline-immediately-returned-variable
- remove-redundant-if
- switch
- low-code-quality
......
......@@ -35,8 +35,7 @@ verbose = 0
def decode_timestamp(t):
timestamp = datetime.datetime.strptime(t, GITLAB_TIMEFORMAT)
return timestamp
return datetime.datetime.strptime(t, GITLAB_TIMEFORMAT)
class Project:
......@@ -188,8 +187,7 @@ class MergeRequest:
return self.mr.title
def withlink(self):
out = self.mr.title + " [" + self.mr.reference + "](" + self.mr.web_url + ")"
return out
return self.mr.title + " [" + self.mr.reference + "](" + self.mr.web_url + ")"
def main(args):
......
......@@ -153,11 +153,10 @@ def wait_until_merge_status_is_set(project: Project, mr: MergeRequest):
def list_commits(commits):
"""Create a list of commits along with the commit messages"""
commit_list = "".join(
return "".join(
"\n--\n\nCommit: %s\n\n%s" % (commit.web_url, commit.message)
for commit in commits
)
return commit_list
def commit_and_push(
......
......@@ -45,8 +45,7 @@ def get_pipeline_jobs(gitlab, project, pipeline, name=None, stage=None):
pipeline_jobs = get_pipeline_pipelinejobs(gitlab, project, pipeline, name, stage)
# Project Jobs from Pipeline Job
jobs = [gl_project.jobs.get(job.id) for job in pipeline_jobs]
return jobs
return [gl_project.jobs.get(job.id) for job in pipeline_jobs]
def get_pipeline_job_ids(gitlab, project, pipeline, name=None, stage=None):
......
......@@ -30,8 +30,7 @@ verbose = 0
def decode_timestamp(t):
timestamp = datetime.datetime.strptime(t, GITLAB_TIMEFORMAT)
return timestamp
return datetime.datetime.strptime(t, GITLAB_TIMEFORMAT)
class Project:
......@@ -183,8 +182,7 @@ class MergeRequest:
return self.mr.title
def withlink(self):
out = self.mr.title + " [" + self.mr.reference + "](" + self.mr.web_url + ")"
return out
return self.mr.title + " [" + self.mr.reference + "](" + self.mr.web_url + ")"
def get_projects_from_group(gitlab, base_group):
......
......@@ -53,8 +53,7 @@ class Lava:
if not ok:
raise LavaException("Failed to query lava suburl: %s" % suburl)
results = json.loads(text)
return results
return json.loads(text)
def get_job_suites(self, jobid):
return self.request_json("jobs/{}/suites/".format(jobid))
......@@ -72,9 +71,7 @@ class Lava:
# print(content)
yaml = YAML(typ="safe")
log = yaml.load(content)
return log
return yaml.load(content)
def get_device_list(self):
return self.request_json("devices/")
......@@ -277,12 +274,11 @@ class LavaDevice:
if filter_types is None:
filter_types = ["karl", "lxc"]
devices = lava.get_device_list()
device_list = {
return {
d["hostname"]: LavaDevice(d, tags)
for d in devices["results"]
if d["device_type"] not in filter_types
}
return device_list
def __str__(self):
return "LavaDevice " + self.name
......@@ -314,8 +310,7 @@ class LavaTag:
@staticmethod
def taglist_from_lava(lava):
tags = lava.get_tag_list()
tag_list = {t["id"]: LavaTag(t) for t in tags["results"]}
return tag_list
return {t["id"]: LavaTag(t) for t in tags["results"]}
class LavaSuite:
......
......@@ -82,8 +82,7 @@ class TestCollection:
if test.test_case_id not in tests.keys():
tests[test.test_case_id] = []
tests[test.test_case_id].append(test)
test_collections = [TestCollection(k, v) for k, v in tests.items()]
return test_collections
return [TestCollection(k, v) for k, v in tests.items()]
def __str__(self):
return "TestCollection " + self.name
......
......@@ -78,8 +78,7 @@ def get_lava_credentials(host=None):
def get_lava_host():
"""Get LAVA host from environment or use default value"""
host = os.getenv("LAVA_HOST", DEFAULT_LAVA_HOST)
return host
return os.getenv("LAVA_HOST", DEFAULT_LAVA_HOST)
def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment