diff --git a/.github/workflows/python/github.py b/.github/workflows/python/github.py index 89e72b5991..1abbbb03c9 100644 --- a/.github/workflows/python/github.py +++ b/.github/workflows/python/github.py @@ -31,20 +31,20 @@ def __init__(self): def get_reviews(self): """ Get a list of reviews on a Github pull request as json object """ - reviews = self.session.get(self.api + 'repos/{}/pulls/{}/reviews'.format(self.github_repository, self.pr_id)) + reviews = self.session.get(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews') reviews.raise_for_status() return reviews.json() def update_review(self, review_id, body): """ Update a review given by `review_id` and set its body to `body` """ payload = {'body': body} - resp = self.session.put(self.api + 'repos/{}/pulls/{}/reviews/{}'.format(self.github_repository, self.pr_id, review_id), json=payload) + resp = self.session.put(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews/{review_id}', json=payload) resp.raise_for_status() return resp.json() def post_review(self, body): """ Post a pull request review containing `body` and requesting changes """ payload = {'body': body, 'event': "REQUEST_CHANGES"} - resp = self.session.post(self.api + 'repos/{}/pulls/{}/reviews'.format(self.github_repository, self.pr_id), json=payload) + resp = self.session.post(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews', json=payload) resp.raise_for_status() return resp.json() diff --git a/.github/workflows/python/pycodestyle_comment.py b/.github/workflows/python/pycodestyle_comment.py index 89eca1936f..4cce4d4028 100644 --- a/.github/workflows/python/pycodestyle_comment.py +++ b/.github/workflows/python/pycodestyle_comment.py @@ -34,7 +34,7 @@ def style_error_format(style_error_list) -> str: """ Format the list of pycodestyle errors and return them a one string. """ ret = '' for error in style_error_list: - ret += '* {}\n'.format(error) + ret += f'* {error}\n' return ret @@ -45,7 +45,7 @@ def style_error_format(style_error_list) -> str: style_errors = list_style_errors() if style_errors: - print("Found {} errors.".format(len(style_errors))) + print(f"Found {len(style_errors)} errors.") gh = github.Github() diff --git a/NEWS.md b/NEWS.md index 29549fadc3..35db89ab43 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,7 +14,7 @@ Please refer to the change log for a full list of changes. --------------------------------- ### Requirements -Python 3.8 or newer is required +Python 3.8 or newer is required. ### Tools diff --git a/contrib/example-extension-package/setup.py b/contrib/example-extension-package/setup.py index 3d6774693f..d662eca34d 100644 --- a/contrib/example-extension-package/setup.py +++ b/contrib/example-extension-package/setup.py @@ -28,7 +28,7 @@ entry_point = '.'.join(file.with_suffix('').parts) file = Path(str(file).replace('intelmq/bots', 'mybots/bots')) module = '.'.join(file.with_suffix('').parts) - BOTS.append('{0} = {1}:BOT.run'.format(entry_point, module)) + BOTS.append(f'{entry_point} = {module}:BOT.run') setup( name='intelmq-example-extension', diff --git a/intelmq/bots/collectors/rsync/collector_rsync.py b/intelmq/bots/collectors/rsync/collector_rsync.py index 112deb1f17..3829c8a3f8 100644 --- a/intelmq/bots/collectors/rsync/collector_rsync.py +++ b/intelmq/bots/collectors/rsync/collector_rsync.py @@ -13,7 +13,7 @@ from intelmq.lib.bot import CollectorBot -class Time(object): +class Time: def __init__(self, delta=None): """ Delta is a datetime.timedelta JSON string, ex: '{days=-1}'. """ self.time = datetime.now() diff --git a/intelmq/bots/experts/modify/expert.py b/intelmq/bots/experts/modify/expert.py index a9945449a4..f6cdbbb439 100644 --- a/intelmq/bots/experts/modify/expert.py +++ b/intelmq/bots/experts/modify/expert.py @@ -17,10 +17,7 @@ def is_re_pattern(value): """ Checks if the given value is a re compiled pattern """ - if sys.version_info > (3, 7): - return isinstance(value, re.Pattern) - else: - return hasattr(value, "pattern") + return isinstance(value, re.Pattern) class MatchGroupMapping: diff --git a/intelmq/bots/outputs/smtp_batch/output.py b/intelmq/bots/outputs/smtp_batch/output.py index d24d114671..5661ea7339 100644 --- a/intelmq/bots/outputs/smtp_batch/output.py +++ b/intelmq/bots/outputs/smtp_batch/output.py @@ -123,7 +123,7 @@ def cli_run(self): with open(self.mail_template) as f: self.mail_contents = f.read() if self.alternative_mails: - with open(self.alternative_mails, "r") as f: + with open(self.alternative_mails) as f: self.alternative_mail = {row[0]: row[1] for row in csv.reader(f, delimiter=",")} print("Preparing mail queue...")