From 6b5560aab94f631a049070e2a5243b9d5b29ff43 Mon Sep 17 00:00:00 2001 From: Spacetown Date: Wed, 4 Aug 2021 21:10:18 +0200 Subject: [PATCH 1/2] Add flake8-no-fstring to detect usage of fstrings. --- requirements-dev.txt | 1 + tox.ini | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 4c095e514..d3cb12f88 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,6 +3,7 @@ mock pytest pytest-cov flake8 +flake8-no-fstring black tox coverage diff --git a/tox.ini b/tox.ini index 2ce66113f..1f3b19b86 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,9 @@ parallel_show_output = true [testenv:flake8] basepython = python3 skip_install = true -deps = flake8 +deps = + flake8 + flake8-no-fstring commands = flake8 [testenv:pylint] From 760e41755f159b27474f52f6570280d67e41edc5 Mon Sep 17 00:00:00 2001 From: Spacetown Date: Wed, 4 Aug 2021 21:13:13 +0200 Subject: [PATCH 2/2] Remove fstrings from code. --- examples/bitbucket/stash_user_auth_report.py | 4 +++- examples/jira/jira_dc_create_support_zips.py | 4 ++-- examples/jira/jira_jql_fetcher_as_weekly_report.py | 12 +++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/examples/bitbucket/stash_user_auth_report.py b/examples/bitbucket/stash_user_auth_report.py index f27f7a74e..94de8a8ca 100644 --- a/examples/bitbucket/stash_user_auth_report.py +++ b/examples/bitbucket/stash_user_auth_report.py @@ -29,7 +29,9 @@ def report(limit=200, include_in_active=False): else: full_date = None if include_in_active or user.get("active"): - output = f"|{user.get('active')}|{user.get('displayName')}|{user.get('emailAddress')}|{full_date}|" + output = "|{}|{}|{}|{}|".format( + user.get("active"), user.get("displayName"), user.get("emailAddress"), full_date + ) print(output) diff --git a/examples/jira/jira_dc_create_support_zips.py b/examples/jira/jira_dc_create_support_zips.py index 8896c1fa8..f30e31973 100644 --- a/examples/jira/jira_dc_create_support_zips.py +++ b/examples/jira/jira_dc_create_support_zips.py @@ -14,7 +14,7 @@ for task in jira.check_support_zip_status(zips_creation_task_id)["tasks"]: if task["status"] == "IN_PROGRESS": - print(f"file {task['fileName']} {task['progressMessage']}") + print("file {} {}".format(task["fileName"], task["progressMessage"])) if task["fileName"] not in in_progress_zips: in_progress_zips.append(task["fileName"]) @@ -25,7 +25,7 @@ with open(task["fileName"], "wb") as fp: fp.write(support_zip) - print(f"{task['fileName']} written.") + print("{} written.".format(task["fileName"])) if task["fileName"] in in_progress_zips: in_progress_zips.remove(task["fileName"]) diff --git a/examples/jira/jira_jql_fetcher_as_weekly_report.py b/examples/jira/jira_jql_fetcher_as_weekly_report.py index 507481a81..89ee0c892 100644 --- a/examples/jira/jira_jql_fetcher_as_weekly_report.py +++ b/examples/jira/jira_jql_fetcher_as_weekly_report.py @@ -63,11 +63,17 @@ def __get_changes_of_cases(self, histories): continue output = [ history.get("author").get("name"), - f"{change_date:%Y-%m-%d}", + change_date.format("%Y-%m-%d"), ] # person who did the change changes = ["Listing all items that changed:"] for item in history.get("items"): - changes.append(f"{item['field']} - {item['fromString']}- {item['toString']}") + changes.append( + "{} - {}- {}".format( + item["field"], + item["fromString"], + item["toString"], + ) + ) output.append("\t".join(changes)) return " - ".join(output) @@ -84,7 +90,7 @@ def console_output(self, delimiter="|", console=True): number = 1 data = [] for case in self.cases: - print(f"Processing case #{number}") + print("Processing case #{}".format(number)) output = [ case.get("actor"), case.get("key"),