pep8: Fix E502 violations

This commit is contained in:
bulat22101 2016-12-03 17:07:49 +00:00 committed by Tim Abbott
parent e6fa4bc2fd
commit adebc75740
20 changed files with 28 additions and 28 deletions

View File

@ -168,7 +168,7 @@ def do_aggregate_to_summary_table(stat, end_time, interval):
def do_pull_from_zerver(stat, start_time, end_time, interval):
# type: (CountStat, datetime, datetime, str) -> None
zerver_table = stat.zerver_count_query.zerver_table._meta.db_table # type: ignore
join_args = ' '.join('AND %s.%s = %s' % (zerver_table, key, value) \
join_args = ' '.join('AND %s.%s = %s' % (zerver_table, key, value)
for key, value in stat.filter_args.items())
if stat.group_by is None:
subgroup = 'NULL'

View File

@ -77,7 +77,7 @@ class AnalyticsTestCase(TestCase):
self.assertEqual(table.objects.filter(realm=realm,
property=property,
interval=interval,
end_time=end_time) \
end_time=end_time)
.filter(**kwargs).values_list('value', flat=True)[0],
value)

View File

@ -42,7 +42,7 @@ def do_send_message(client, message_data):
'''Sends a message and optionally prints status about the same.'''
if message_data['type'] == 'stream':
log.info('Sending message to stream "%s", subject "%s"... ' % \
log.info('Sending message to stream "%s", subject "%s"... ' %
(message_data['to'], message_data['subject']))
else:
log.info('Sending message to %s... ' % message_data['to'])

View File

@ -208,9 +208,9 @@ def process_new_events():
"""
# In task queries, Asana only exposes IDs for projects and users, so we need
# to look up the mappings.
projects = dict((elt["id"], elt["name"]) for elt in \
projects = dict((elt["id"], elt["name"]) for elt in
fetch_from_asana("/projects")["data"])
users = dict((elt["id"], elt["name"]) for elt in \
users = dict((elt["id"], elt["name"]) for elt in
fetch_from_asana("/users")["data"])
cutoff = since()

View File

@ -312,7 +312,7 @@ class Client(object):
return False
if self.verbose:
if not query_state["had_error_retry"]:
sys.stdout.write("zulip API(%s): connection error%s -- retrying." % \
sys.stdout.write("zulip API(%s): connection error%s -- retrying." %
(url.split(API_VERSTRING, 2)[0], error_string,))
query_state["had_error_retry"] = True
else:

View File

@ -328,11 +328,11 @@ for key in all_keys:
continue
if key in zhkeys:
(stream, test) = zhkeys[key]
logger.warning("%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s" % \
logger.warning("%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s" %
(key, z_key_counts[key], h_key_counts[key], test, stream))
if key in hzkeys:
(stream, test) = hzkeys[key]
logger.warning("%10s: z got %s. h got %s. Sent via Zulip(%s): class %s" % \
logger.warning("%10s: z got %s. h got %s. Sent via Zulip(%s): class %s" %
(key, z_key_counts[key], h_key_counts[key], test, stream))
logger.error("")
logger.error("Summary of specific problems:")

View File

@ -317,7 +317,7 @@ user and mirrors messages sent to Jabber rooms to Zulip. Defaults to
parser.add_option('--zulip-email-suffix',
default=None,
action='store',
help= \
help=
'''Add the specified suffix to the local part of email addresses constructed
from JIDs and nicks before sending requests to the Zulip server, and remove the
suffix before sending requests to the Jabber server. For example, specifying

View File

@ -50,9 +50,9 @@ now = datetime.datetime.utcnow()
all_users = UserActivity.objects.filter(query__in=["get_events_backend", "/api/v1/events"],
client__name="zephyr_mirror")
new_inactive_users = [user for user in all_users if user.last_visit.replace(tzinfo=None) < \
new_inactive_users = [user for user in all_users if user.last_visit.replace(tzinfo=None) <
now - datetime.timedelta(minutes=10)]
old_inactive_users = [user for user in new_inactive_users if user.last_visit.replace(tzinfo=None) < \
old_inactive_users = [user for user in new_inactive_users if user.last_visit.replace(tzinfo=None) <
now - datetime.timedelta(minutes=60)]
recently_inactive_users = set(new_inactive_users) - set(old_inactive_users)

View File

@ -85,7 +85,7 @@ def check_pep8(files):
'E402', 'E501', 'W503', 'E711', 'E128', 'E226',
'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221',
'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302', 'E129',
'E741', 'E714', 'W391', 'E713', 'E502', 'E305', 'E251', 'E306',
'E741', 'E714', 'W391', 'E713', 'E305', 'E251', 'E306',
]
pep8 = subprocess.Popen(
['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))],

View File

@ -87,8 +87,8 @@ CLOSURE_BINARY = '/usr/bin/closure-compiler'
if not os.path.exists(CLOSURE_BINARY):
CLOSURE_BINARY = 'tools/closure-compiler/run'
if not os.path.exists(CLOSURE_BINARY):
print("closure-compiler not installed; the Vagrant tools/provision.py installs it via apt "\
"or you can manually unpack http://dl.google.com/closure-compiler/compiler-latest.zip to "\
print("closure-compiler not installed; the Vagrant tools/provision.py installs it via apt "
"or you can manually unpack http://dl.google.com/closure-compiler/compiler-latest.zip to "
"tools/closure-compiler")
sys.exit(1)

View File

@ -595,7 +595,7 @@ def rate_limit(domain='all'):
user = None
if not user:
logging.error("Requested rate-limiting on %s but user is not authenticated!" % \
logging.error("Requested rate-limiting on %s but user is not authenticated!" %
func.__name__)
return func(request, *args, **kwargs)

View File

@ -63,7 +63,7 @@ class RegistrationForm(forms.Form):
realm_name = forms.CharField(max_length=100, required=False)
realm_subdomain = forms.CharField(max_length=40, required=False)
realm_org_type = forms.ChoiceField(((Realm.COMMUNITY, 'Community'),
(Realm.CORPORATE, 'Corporate')), \
(Realm.CORPORATE, 'Corporate')),
initial=Realm.COMMUNITY, required=False)
if settings.TERMS_OF_SERVICE:

View File

@ -229,7 +229,7 @@ def send_signup_message(sender, signups_stream, user_profile,
if user_profile.realm.notifications_stream is not None and user_count > 1:
internal_send_message(sender, "stream",
user_profile.realm.notifications_stream.name,
"New users", "%s just signed up for Zulip. Say hello!" % \
"New users", "%s just signed up for Zulip. Say hello!" %
(user_profile.full_name,),
realm=user_profile.realm)
@ -2809,7 +2809,7 @@ def gather_subscriptions_helper(user_profile):
stream_ids = set([sub["recipient__type_id"] for sub in sub_dicts])
all_streams = get_active_streams(user_profile.realm).select_related(
"realm").values("id", "name", "invite_only", "realm_id", \
"realm").values("id", "name", "invite_only", "realm_id",
"realm__domain", "email_token", "description")
stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids]
@ -2824,7 +2824,7 @@ def gather_subscriptions_helper(user_profile):
never_subscribed = []
# Deactivated streams aren't in stream_hash.
streams = [stream_hash[sub["recipient__type_id"]] for sub in sub_dicts \
streams = [stream_hash[sub["recipient__type_id"]] for sub in sub_dicts
if sub["recipient__type_id"] in stream_hash]
streams_subscribed_map = dict((sub["recipient__type_id"], sub["active"]) for sub in sub_dicts)

View File

@ -94,6 +94,6 @@ def fill_remote_cache(cache):
cache_set_many(items_for_remote_cache, timeout=3600*24)
items_for_remote_cache = {}
cache_set_many(items_for_remote_cache, timeout=3600*24*7)
logging.info("Succesfully populated %s cache! Consumed %s remote cache queries (%s time)" % \
logging.info("Succesfully populated %s cache! Consumed %s remote cache queries (%s time)" %
(cache, get_remote_cache_requests() - remote_cache_requests_start,
round(get_remote_cache_time() - remote_cache_time_start, 2)))

View File

@ -87,7 +87,7 @@ def gather_hot_conversations(user_profile, stream_messages):
count = conversation_length[h]
# We'll display up to 2 messages from the conversation.
first_few_messages = [user_message.message for user_message in \
first_few_messages = [user_message.message for user_message in
stream_messages.filter(
message__recipient__type_id=stream_id,
message__subject=subject)[:2]]
@ -189,7 +189,7 @@ def handle_digest_email(user_profile_id, cutoff):
user_profile, [pm.message for pm in pms[:pms_limit]])
template_payload['remaining_unread_pms_count'] = min(0, len(pms) - pms_limit)
home_view_recipients = [sub.recipient for sub in \
home_view_recipients = [sub.recipient for sub in
Subscription.objects.filter(
user_profile=user_profile,
active=True,

View File

@ -47,7 +47,7 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty]
# type: (Model) -> None
count = model.objects.count()
if count:
print("Zulip instance is not empty, found %d rows in %s table. " \
print("Zulip instance is not empty, found %d rows in %s table. "
% (count, model._meta.db_table))
print("You may use --destroy-rebuild-database to destroy and rebuild the database prior to import.")
exit(1)

View File

@ -710,8 +710,8 @@ class GetOldMessagesTest(ZulipTestCase):
for type in bad_types:
# Rotate through every bad type for every integer
# parameter, one at a time.
post_params = dict(other_params + [(param, type)] + \
[(other_param, 0) for other_param in \
post_params = dict(other_params + [(param, type)] +
[(other_param, 0) for other_param in
int_params[:idx] + int_params[idx + 1:]]
)
result = self.client_get("/json/messages", post_params)

View File

@ -105,7 +105,7 @@ def json_time_setting(request, user_profile, twenty_four_hour_time=REQ(validator
def json_left_side_userlist(request, user_profile, left_side_userlist=REQ(validator=check_bool, default=None)):
# type: (HttpRequest, UserProfile, Optional[bool]) -> HttpResponse
result = {}
if (left_side_userlist is not None and \
if (left_side_userlist is not None and
user_profile.left_side_userlist != left_side_userlist):
do_change_left_side_userlist(user_profile, left_side_userlist)

View File

@ -229,7 +229,7 @@ def add_bot_backend(request, user_profile, full_name=REQ(), short_name=REQ(),
if default_sending_stream_name is not None:
default_sending_stream = stream_or_none(default_sending_stream_name, user_profile.realm)
if (default_sending_stream and not
default_sending_stream.is_public() and not \
default_sending_stream.is_public() and not
subscribed_to_stream(user_profile, default_sending_stream)):
return json_error(_('Insufficient permission'))

View File

@ -27,7 +27,7 @@ def api_stash_webhook(request, user_profile, payload=REQ(argument_type='body'),
branch_name = payload["refChanges"][0]["refId"].split("/")[-1]
commit_entries = payload["changesets"]["values"]
commits = [(entry["toCommit"]["displayId"],
entry["toCommit"]["message"].split("\n")[0]) for \
entry["toCommit"]["message"].split("\n")[0]) for
entry in commit_entries]
head_ref = commit_entries[-1]["toCommit"]["displayId"]
except KeyError as e: