Harden style rule for % comprehensions and fix existing errors.

This commit is contained in:
Tim Abbott 2016-01-26 20:12:06 -08:00
parent 4887a79d21
commit aad3bff193
5 changed files with 6 additions and 6 deletions

View File

@ -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 = [

View File

@ -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()

View File

@ -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 = ''

View File

@ -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] <json file name> [<json file name>...]""" % DEFAULT_CHUNK_SIZE
Usage: python2.7 manage.py import_dump [--destroy-rebuild-database] [--chunk-size=%s] <json file name> [<json file name>...]""" % (DEFAULT_CHUNK_SIZE,)
option_list = BaseCommand.option_list + (
make_option('--destroy-rebuild-database',

View File

@ -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: