From 3f8d4193da17d967f2ddb252dea4e32ac50ec088 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 9 Jan 2017 11:45:11 -0800 Subject: [PATCH] lint: Fix % comprehensions being used without a tuple. --- analytics/views.py | 2 +- api/integrations/google/google-calendar | 2 +- contrib_bots/lib/xkcd.py | 2 +- tools/lint-all | 2 ++ zerver/lib/bugdown/__init__.py | 4 ++-- zerver/lib/notifications.py | 2 +- zerver/lib/upload.py | 2 +- zerver/views/webhooks/solano.py | 2 +- zerver/views/webhooks/teamcity.py | 6 +++--- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/analytics/views.py b/analytics/views.py index bf0bd466c0..dee0f39ff7 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -942,7 +942,7 @@ def get_realm_activity(request, realm_str): data += [(page_title, content)] realm_link = 'https://stats1.zulip.net:444/render/?from=-7days' - realm_link += '&target=stats.gauges.staging.users.active.%s.0_16hr' % (realm_str) + realm_link += '&target=stats.gauges.staging.users.active.%s.0_16hr' % (realm_str,) title = realm_str return render_to_response( diff --git a/api/integrations/google/google-calendar b/api/integrations/google/google-calendar index 014b7e48e6..47b541e96f 100755 --- a/api/integrations/google/google-calendar +++ b/api/integrations/google/google-calendar @@ -143,7 +143,7 @@ def send_reminders(): key = (id, start) if key not in sent: if start.hour == 0 and start.minute == 0: - line = '%s is today.' % (summary) + line = '%s is today.' % (summary,) else: line = '%s starts at %s' % (summary, start.strftime('%H:%M')) print('Sending reminder:', line) diff --git a/contrib_bots/lib/xkcd.py b/contrib_bots/lib/xkcd.py index c3286a096f..6bb90a9b32 100644 --- a/contrib_bots/lib/xkcd.py +++ b/contrib_bots/lib/xkcd.py @@ -87,7 +87,7 @@ def get_xkcd_bot_response(message): except XkcdNotFoundError: logging.exception('XKCD server responded 404 when trying to fetch comic with id %s' % (command)) - return 'Sorry, there is likely no xkcd comic strip with id: #%s' % (command) + return 'Sorry, there is likely no xkcd comic strip with id: #%s' % (command,) else: return ("#%s: **%s**\n[%s](%s)" % (fetched['num'], fetched['title'], diff --git a/tools/lint-all b/tools/lint-all index d38690ff4b..383fd8d3dd 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -292,6 +292,8 @@ def build_custom_checkers(by_lang): ('tools/tests/test_template_parser.py', '{% foo'), ]), 'description': 'Used % comprehension without a tuple'}, + {'pattern': '.*%s.* % \([a-zA-Z0-9_.]*\)$', + 'description': 'Used % comprehension without a tuple'}, {'pattern': 'json_success\({}\)', 'description': 'Use json_success() to return nothing'}, # To avoid json_error(_variable) and json_error(_(variable)) diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 023d3869f0..1ed5a3c77d 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -658,7 +658,7 @@ class UnicodeEmoji(markdown.inlinepatterns.Pattern): orig_syntax = match.group('syntax') name = hex(ord(orig_syntax))[2:] if name in unicode_emoji_list: - src = '/static/generated/emoji/images/emoji/unicode/%s.png' % (name) + src = '/static/generated/emoji/images/emoji/unicode/%s.png' % (name,) return make_emoji(name, src, orig_syntax) else: return None @@ -676,7 +676,7 @@ class Emoji(markdown.inlinepatterns.Pattern): if current_message and name in realm_emoji: return make_emoji(name, realm_emoji[name]['display_url'], orig_syntax) elif name in emoji_list: - src = '/static/generated/emoji/images/emoji/%s.png' % (name) + src = '/static/generated/emoji/images/emoji/%s.png' % (name,) return make_emoji(name, src, orig_syntax) else: return None diff --git a/zerver/lib/notifications.py b/zerver/lib/notifications.py index 6e90938200..1e4bebb46b 100644 --- a/zerver/lib/notifications.py +++ b/zerver/lib/notifications.py @@ -147,7 +147,7 @@ def build_message_list(user_profile, messages): # type: (UserProfile, Message) -> Dict[str, Any] disp_recipient = get_display_recipient(message.recipient) if message.recipient.type == Recipient.PERSONAL: - header = u"You and %s" % (message.sender.full_name) + header = u"You and %s" % (message.sender.full_name,) html_link = pm_narrow_url(user_profile.realm, [message.sender.email]) header_html = u"%s" % (html_link, header) elif message.recipient.type == Recipient.HUDDLE: diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index 8d0cbfc156..ec0f70ebd9 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -195,7 +195,7 @@ class S3UploadBackend(ZulipUploadBackend): random_name(18), sanitize_name(uploaded_file_name) ]) - url = "/user_uploads/%s" % (s3_file_name) + url = "/user_uploads/%s" % (s3_file_name,) upload_image_to_s3( bucket_name, diff --git a/zerver/views/webhooks/solano.py b/zerver/views/webhooks/solano.py index 1c0b390c84..e9d510937c 100644 --- a/zerver/views/webhooks/solano.py +++ b/zerver/views/webhooks/solano.py @@ -44,7 +44,7 @@ def api_solano_webhook(request, user_profile, client, elif status in neutral_status: emoji = ':arrows_counterclockwise:' else: - emoji = "(No emoji specified for status '%s'.)" % (status) + emoji = "(No emoji specified for status '%s'.)" % (status,) template = ( u'Author: {}\n' diff --git a/zerver/views/webhooks/teamcity.py b/zerver/views/webhooks/teamcity.py index f1b1875aa5..e7cd666989 100644 --- a/zerver/views/webhooks/teamcity.py +++ b/zerver/views/webhooks/teamcity.py @@ -59,13 +59,13 @@ def api_teamcity_webhook(request, user_profile, client, payload=REQ(argument_typ status = 'was successful! :thumbsup:' elif build_result == 'failure': if build_result_delta == 'broken': - status = 'is broken with status %s! :thumbsdown:' % (build_status) + status = 'is broken with status %s! :thumbsdown:' % (build_status,) else: - status = 'is still broken with status %s! :thumbsdown:' % (build_status) + status = 'is still broken with status %s! :thumbsdown:' % (build_status,) elif build_result == 'running': status = 'has started.' else: - status = '(has no message specified for status %s)' % (build_status) + status = '(has no message specified for status %s)' % (build_status,) template = ( u'%s build %s %s\n'