From 25803455a3f891e0f4332d87c90df7e62b25ea31 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 29 Sep 2020 06:12:55 -0700 Subject: [PATCH] Fix some code style issues identified by flake8 Some of the things fixed include TAB based indentation of a documentation string, some unneeded semicolons, a missing exception name, and an excessively long line. --- .flake8 | 2 +- turbot.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.flake8 b/.flake8 index f474fae..532d8e5 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,2 @@ [flake8] -ignore = E305 +ignore = E251, E305, E302 diff --git a/turbot.py b/turbot.py index 4a6aaff..4224d42 100755 --- a/turbot.py +++ b/turbot.py @@ -42,7 +42,7 @@ def rot(): This implements the /rot command of our Slack bot. The format of this command is as follows: - /rot [count|*] String to be rotated + /rot [count|*] String to be rotated The optional count indicates an amount to rotate each character in the string. If the count is '*' or is not present, then the string will @@ -54,8 +54,8 @@ def rot(): in a direct message that it is not a member of. Otherwise, if the slash command was issued in a channel, the bot will reply in that channel.""" - data = request.get_data(); - headers = request.headers; + data = request.get_data() + headers = request.headers response_url = request.form.get('response_url') channel_name = request.form.get('channel_name') channel = request.form.get('channel_id') @@ -68,7 +68,7 @@ def rot(): if (match): try: count = int(match.group(1)) - except: + except ValueError: count = None text = match.group(2) else: @@ -82,7 +82,8 @@ def rot(): if count: reply += rot_string(text, count) else: - reply += "\n".join(["{:02d} ".format(count) + rot_string(text, count) for count in range(1,26)]) + reply += "\n".join(["{:02d} ".format(count) + rot_string(text, count) + for count in range(1, 26)]) reply += "```" -- 2.45.2