Skip to content

Commit 15d0439

Browse files
committed
Upgrade python syntax to 3.8+
Using pyupgrade.
1 parent 853b66f commit 15d0439

File tree

7 files changed

+10
-13
lines changed

7 files changed

+10
-13
lines changed

.github/workflows/python/github.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ def __init__(self):
3131

3232
def get_reviews(self):
3333
""" Get a list of reviews on a Github pull request as json object """
34-
reviews = self.session.get(self.api + 'repos/{}/pulls/{}/reviews'.format(self.github_repository, self.pr_id))
34+
reviews = self.session.get(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews')
3535
reviews.raise_for_status()
3636
return reviews.json()
3737

3838
def update_review(self, review_id, body):
3939
""" Update a review given by `review_id` and set its body to `body` """
4040
payload = {'body': body}
41-
resp = self.session.put(self.api + 'repos/{}/pulls/{}/reviews/{}'.format(self.github_repository, self.pr_id, review_id), json=payload)
41+
resp = self.session.put(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews/{review_id}', json=payload)
4242
resp.raise_for_status()
4343
return resp.json()
4444

4545
def post_review(self, body):
4646
""" Post a pull request review containing `body` and requesting changes """
4747
payload = {'body': body, 'event': "REQUEST_CHANGES"}
48-
resp = self.session.post(self.api + 'repos/{}/pulls/{}/reviews'.format(self.github_repository, self.pr_id), json=payload)
48+
resp = self.session.post(self.api + f'repos/{self.github_repository}/pulls/{self.pr_id}/reviews', json=payload)
4949
resp.raise_for_status()
5050
return resp.json()

.github/workflows/python/pycodestyle_comment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def style_error_format(style_error_list) -> str:
3434
""" Format the list of pycodestyle errors and return them a one string. """
3535
ret = ''
3636
for error in style_error_list:
37-
ret += '* {}\n'.format(error)
37+
ret += f'* {error}\n'
3838
return ret
3939

4040

@@ -45,7 +45,7 @@ def style_error_format(style_error_list) -> str:
4545
style_errors = list_style_errors()
4646

4747
if style_errors:
48-
print("Found {} errors.".format(len(style_errors)))
48+
print(f"Found {len(style_errors)} errors.")
4949

5050
gh = github.Github()
5151

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Please refer to the change log for a full list of changes.
1414
---------------------------------
1515

1616
### Requirements
17-
Python 3.8 or newer is required
17+
Python 3.8 or newer is required.
1818

1919
### Tools
2020

contrib/example-extension-package/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
entry_point = '.'.join(file.with_suffix('').parts)
2929
file = Path(str(file).replace('intelmq/bots', 'mybots/bots'))
3030
module = '.'.join(file.with_suffix('').parts)
31-
BOTS.append('{0} = {1}:BOT.run'.format(entry_point, module))
31+
BOTS.append(f'{entry_point} = {module}:BOT.run')
3232

3333
setup(
3434
name='intelmq-example-extension',

intelmq/bots/collectors/rsync/collector_rsync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from intelmq.lib.bot import CollectorBot
1414

1515

16-
class Time(object):
16+
class Time:
1717
def __init__(self, delta=None):
1818
""" Delta is a datetime.timedelta JSON string, ex: '{days=-1}'. """
1919
self.time = datetime.now()

intelmq/bots/experts/modify/expert.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ def is_re_pattern(value):
1717
"""
1818
Checks if the given value is a re compiled pattern
1919
"""
20-
if sys.version_info > (3, 7):
21-
return isinstance(value, re.Pattern)
22-
else:
23-
return hasattr(value, "pattern")
20+
return isinstance(value, re.Pattern)
2421

2522

2623
class MatchGroupMapping:

intelmq/bots/outputs/smtp_batch/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def cli_run(self):
123123
with open(self.mail_template) as f:
124124
self.mail_contents = f.read()
125125
if self.alternative_mails:
126-
with open(self.alternative_mails, "r") as f:
126+
with open(self.alternative_mails) as f:
127127
self.alternative_mail = {row[0]: row[1] for row in csv.reader(f, delimiter=",")}
128128

129129
print("Preparing mail queue...")

0 commit comments

Comments
 (0)