From aad3bff193b863e73c94d66d11daf4e9c0f6424e Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 26 Jan 2016 20:12:06 -0800 Subject: [PATCH] Harden style rule for % comprehensions and fix existing errors. --- tools/lint-all | 2 +- tools/zulip-export/zulip-export | 2 +- zerver/lib/bugdown/codehilite.py | 2 +- zerver/management/commands/import_dump.py | 2 +- zerver/views/__init__.py | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/lint-all b/tools/lint-all index fd0ec9df23..3c823bde70 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -165,7 +165,7 @@ python_rules = [ # This next check could have false positives, but it seems pretty # rare; if we find any, they can be added to the exclude list for # this rule. - {'pattern': '% [a-z_]*\)?$', + {'pattern': '% [a-zA-Z0-9_.]*\)?$', 'description': 'Used % comprehension without a tuple'}, ] + whitespace_rules python_line_skip_rules = [ diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export index d08cb24ffd..e34c000bac 100755 --- a/tools/zulip-export/zulip-export +++ b/tools/zulip-export/zulip-export @@ -77,7 +77,7 @@ for msg in result['messages']: msg.pop(k, None) messages.append(msg) -filename = "zulip-%s.json" % options.stream +filename = "zulip-%s.json" % (options.stream,) f = codecs.open(filename, encoding='utf-8', mode="wb") f.write(json.dumps(messages, indent=0, sort_keys=False)) f.close() diff --git a/zerver/lib/bugdown/codehilite.py b/zerver/lib/bugdown/codehilite.py index b2d7298608..199715c344 100644 --- a/zerver/lib/bugdown/codehilite.py +++ b/zerver/lib/bugdown/codehilite.py @@ -105,7 +105,7 @@ class CodeHilite(object): txt = txt.replace('"', '"') classes = [] if self.lang: - classes.append('language-%s' % self.lang) + classes.append('language-%s' % (self.lang,)) if self.linenos: classes.append('linenums') class_str = '' diff --git a/zerver/management/commands/import_dump.py b/zerver/management/commands/import_dump.py index 227cdcd463..c03f21abdc 100644 --- a/zerver/management/commands/import_dump.py +++ b/zerver/management/commands/import_dump.py @@ -23,7 +23,7 @@ class Command(BaseCommand): This command should be used only on a newly created, empty Zulip instance to import a database dump from one or more JSON files. -Usage: python2.7 manage.py import_dump [--destroy-rebuild-database] [--chunk-size=%s] [...]""" % DEFAULT_CHUNK_SIZE +Usage: python2.7 manage.py import_dump [--destroy-rebuild-database] [--chunk-size=%s] [...]""" % (DEFAULT_CHUNK_SIZE,) option_list = BaseCommand.option_list + ( make_option('--destroy-rebuild-database', diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index adfcf9d3fa..5554ac99bb 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -499,7 +499,7 @@ def finish_google_oauth2(request): }, ) if resp.status_code != 200: - raise Exception('Could not convert google oauth2 code to access_token\r%r' % resp.text) + raise Exception('Could not convert google oauth2 code to access_token\r%r' % (resp.text,)) access_token = extract_json_response(resp)['access_token'] resp = requests.get( @@ -507,7 +507,7 @@ def finish_google_oauth2(request): params={'access_token': access_token} ) if resp.status_code != 200: - raise Exception('Google login failed making API call\r%r' % resp.text) + raise Exception('Google login failed making API call\r%r' % (resp.text,)) body = extract_json_response(resp) try: