diff --git a/scripts/.sourcery.yaml b/scripts/.sourcery.yaml index 62d412fa4056f433e8cb7d82071a990dab5e1f58..01b1149ba26bb89259a558c39e2bef4581440ec3 100644 --- a/scripts/.sourcery.yaml +++ b/scripts/.sourcery.yaml @@ -16,7 +16,6 @@ rule_settings: - replace-interpolation-with-fstring - use-fstring-for-concatenation - merge-dict-assign - - assign-if-exp - remove-redundant-if - switch - low-code-quality diff --git a/scripts/changelog_generator.py b/scripts/changelog_generator.py index 83e3880b94760e1d85c3eff25aa2c3148091e89f..5afce6adad5961b26850b2aca151de3f919b0120 100755 --- a/scripts/changelog_generator.py +++ b/scripts/changelog_generator.py @@ -51,9 +51,7 @@ class Project: ) def __eq__(self, p): - if not p: - return False - return self.project.id == p.project.id + return self.project.id == p.project.id if p else False class Tag: @@ -167,9 +165,7 @@ class Release: def description(self): m = self.tag.message - if not m: - return "" - return m + return m or "" def __str__(self): return self.tag.name diff --git a/scripts/gitlab_backup.py b/scripts/gitlab_backup.py index 1e86665bf822b7797001fc40ee99d4f37bbdf5f6..0a05b48c48367bb7aea12d05c2d305933e3dfe36 100755 --- a/scripts/gitlab_backup.py +++ b/scripts/gitlab_backup.py @@ -46,9 +46,7 @@ class Project: ) def __eq__(self, p): - if not p: - return False - return self.project.id == p.project.id + return self.project.id == p.project.id if p else False class Tag: @@ -162,9 +160,7 @@ class Release: def description(self): m = self.tag.message - if not m: - return "" - return m + return m or "" def __str__(self): return self.tag.name diff --git a/scripts/lava_api.py b/scripts/lava_api.py index e76c006292789ddfea3b2dd57ed6484ac6256bc6..e66f0d278d415a51e882d4962ebde28304ce18de 100755 --- a/scripts/lava_api.py +++ b/scripts/lava_api.py @@ -250,21 +250,15 @@ class LavaDevice: @property def serial(self): - if self._serial is None: - return "" - return self._serial.name + return self._serial.name if self._serial is not None else "" @property def hw_revision(self): - if self._hw_revision is None: - return "" - return self._hw_revision.name + return self._hw_revision.name if self._hw_revision is not None else "" @property def article_no(self): - if self._article_no is None: - return "" - return self._article_no.name + return self._article_no.name if self._article_no is not None else "" def __lt__(self, other): return self.name < other.name diff --git a/scripts/lava_create_testreport.py b/scripts/lava_create_testreport.py index d03f56f70e76815438fc506e72a9520e63a1542b..adaeb85726d0659e91d0248066565d947e0d1ecd 100755 --- a/scripts/lava_create_testreport.py +++ b/scripts/lava_create_testreport.py @@ -36,16 +36,12 @@ class TestCollection: return "" tests = self.tests[machine] out = ["{:.2f}".format(float(t.measurement)) for t in tests] - if not out: - return None - return "/".join(out) + return "/".join(out) if out else None @property def name(self): t = self.get_test() - if t is None: - return self.test_case_id - return t.name + return t.name if t is not None else self.test_case_id # Sort alphabetically def __lt__(self, other): @@ -55,9 +51,7 @@ class TestCollection: keys = list(self.tests.keys()) if not keys: return None - if len(self.tests[keys[index]]) < 1: - return None - return self.tests[keys[index]][0] + return None if len(self.tests[keys[index]]) < 1 else self.tests[keys[index]][0] def get_result(self, machine): if machine not in self.tests.keys(): diff --git a/scripts/markdown_generator.py b/scripts/markdown_generator.py index 9d41771f8165593c36acc10e0ccc5c7396d57655..4a9b8f944b79e77a8c95d940092c521881651434 100755 --- a/scripts/markdown_generator.py +++ b/scripts/markdown_generator.py @@ -138,14 +138,10 @@ class MarkDownTable: return "MarkDownTable (" + self.length + " rows)" def get_alignment(self, col): - if col < len(self.alignment): - return self.alignment[col] - return self.alignment[-1] + return self.alignment[col] if col < len(self.alignment) else self.alignment[-1] def get_column_width(self, col): - if col < len(self.column_width): - return self.column_width[col] + 2 - return 60 + return self.column_width[col] + 2 if col < len(self.column_width) else 60 def get_column_count(self): max_cols = 0 diff --git a/scripts/submit_test.py b/scripts/submit_test.py index 9e3a5046fd7fcb879ba33c1d8323b6e380665ca9..f5ea1fc9f1e1a24d5ea56bf8586445393fca99ed 100755 --- a/scripts/submit_test.py +++ b/scripts/submit_test.py @@ -23,12 +23,8 @@ def call(cmd, stdout=None): else: result = subprocess.run(cmd, stdout=stdout, check=True) except subprocess.CalledProcessError as e: - out = "" - err = "" - if e.stdout is not None: - out = e.stdout.decode() - if e.stderr is not None: - err = e.stderr.decode() + out = e.stdout.decode() if e.stdout is not None else "" + err = e.stderr.decode() if e.stderr is not None else "" logging.error("Command failed %s: %s %s", cmd, out, err) exit(1) if result is not None and result.stdout is not None: