From e355932f9574cd6ab79657f7ab8b5a8ef5d10e4d Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@seco.com> Date: Fri, 28 Jul 2023 17:13:32 +0200 Subject: [PATCH] Refactoring: use join() instead of for loop See for reference: https://docs.sourcery.ai/Reference/Python/Default-Rules/use-join/ --- scripts/.sourcery.yaml | 1 - scripts/common.py | 7 ++++--- scripts/markdown_generator.py | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/.sourcery.yaml b/scripts/.sourcery.yaml index 049190bd..54fcaeaa 100644 --- a/scripts/.sourcery.yaml +++ b/scripts/.sourcery.yaml @@ -32,7 +32,6 @@ rule_settings: - use-named-expression - use-next - sum-comprehension - - use-join rule_types: - refactoring diff --git a/scripts/common.py b/scripts/common.py index a005f36d..b87a426a 100755 --- a/scripts/common.py +++ b/scripts/common.py @@ -153,9 +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 = "" - for commit in commits: - commit_list += "\n--\n\nCommit: %s\n\n%s" % (commit.web_url, commit.message) + commit_list = "".join( + "\n--\n\nCommit: %s\n\n%s" % (commit.web_url, commit.message) + for commit in commits + ) return commit_list diff --git a/scripts/markdown_generator.py b/scripts/markdown_generator.py index a952a501..9d41771f 100755 --- a/scripts/markdown_generator.py +++ b/scripts/markdown_generator.py @@ -97,9 +97,7 @@ class MarkDownTableRow: self._current_col += 1 def __str__(self): - c = "" - for i in self.cols: - c += "| " + i.content + " |" + c = "".join("| " + i.content + " |" for i in self.cols) return "MarkDownTableRow (" + self.length + " cols) " + c def render(self): -- GitLab