pep8: Fix E129 violations

This commit is contained in:
bulat22101 2016-12-03 17:19:09 +00:00 committed by Tim Abbott
parent adebc75740
commit a6f91064a2
17 changed files with 30 additions and 30 deletions

View File

@ -95,7 +95,7 @@ def send_bot_message(oldrev, newrev, refname):
old_head = oldrev[:12]
if (oldrev == '0000000000000000000000000000000000000000' or
newrev == '0000000000000000000000000000000000000000'):
newrev == '0000000000000000000000000000000000000000'):
# New branch pushed or old branch removed
added = ''
removed = ''

View File

@ -81,7 +81,7 @@ class CountingBackoff(object):
# type: () -> None
if (self.timeout_success_equivalent is not None
and self.last_attempt_time != 0
and time.time() - self.last_attempt_time > self.timeout_success_equivalent):
and time.time() - self.last_attempt_time > self.timeout_success_equivalent):
self.number_of_retries = 0
class RandomExponentialBackoff(CountingBackoff):
@ -171,7 +171,7 @@ def get_default_config_filename():
# type: () -> str
config_file = os.path.join(os.environ["HOME"], ".zuliprc")
if (not os.path.exists(config_file) and
os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))):
os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))):
raise RuntimeError("The Zulip API configuration file is now ~/.zuliprc; please run:\n\n"
" mv ~/.humbugrc ~/.zuliprc\n")
return config_file
@ -366,7 +366,7 @@ class Client(object):
# want the later exception handlers to deal with any
# non-timeout other SSLErrors
if (isinstance(e, requests.exceptions.SSLError) and
str(e) != "The read operation timed out"):
str(e) != "The read operation timed out"):
raise
if longpolling:
# When longpolling, we expect the timeout to fire,

View File

@ -67,7 +67,7 @@ def zulip_to_jid(email, jabber_domain):
jid = JID(email, domain=jabber_domain)
if (options.zulip_email_suffix
and options.zulip_email_suffix in jid.username
and not jid.username.endswith("-bot")):
and not jid.username.endswith("-bot")):
jid.username = jid.username.rpartition(options.zulip_email_suffix)[0]
return jid
@ -384,7 +384,7 @@ option does not affect login credentials.'''.replace("\n", " "))
for option in ("jid", "jabber_password", "conference_domain", "mode", "zulip_email_suffix",
"jabber_server_address", "jabber_server_port"):
if (getattr(options, option) is None
and config.has_option("jabber_mirror", option)):
and config.has_option("jabber_mirror", option)):
setattr(options, option, config.get("jabber_mirror", option))
for option in ("no_use_tls",):

View File

@ -100,7 +100,7 @@ def unwrap_lines(body):
for line in lines[1:]:
line = line.rstrip()
if (re.match(r'^\W', line, flags=re.UNICODE)
and re.match(r'^\W', previous_line, flags=re.UNICODE)):
and re.match(r'^\W', previous_line, flags=re.UNICODE)):
result += previous_line + "\n"
elif (line == "" or
previous_line == "" or
@ -205,7 +205,7 @@ def update_subscriptions():
for stream in public_streams:
zephyr_class = stream.encode("utf-8")
if (options.shard is not None and
not hashlib.sha1(zephyr_class).hexdigest().startswith(options.shard)):
not hashlib.sha1(zephyr_class).hexdigest().startswith(options.shard)):
# This stream is being handled by a different zephyr_mirror job.
continue
if zephyr_class in current_zephyr_subs:
@ -369,7 +369,7 @@ def process_notice(notice, log):
logger.debug("Skipping message we got from Zulip!")
return
if (zephyr_class == "mail" and notice.instance.lower() == "inbox" and is_personal and
not options.forward_mail_zephyrs):
not options.forward_mail_zephyrs):
# Only forward mail zephyrs if forwarding them is enabled.
return

View File

@ -84,7 +84,7 @@ def check_pep8(files):
ignored_rules = [
'E402', 'E501', 'W503', 'E711', 'E128', 'E226',
'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221',
'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302', 'E129',
'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302',
'E741', 'E714', 'W391', 'E713', 'E305', 'E251', 'E306',
]
pep8 = subprocess.Popen(
@ -159,7 +159,7 @@ def build_custom_checkers(by_lang):
traceback.print_exc()
if (max_length is not None and len(line) > max_length and
'# type' not in line and 'test' not in fn and 'example' not in fn and
"#ignorelongline" not in line):
"#ignorelongline" not in line):
print("Line too long (%s) at %s line %s: %s" % (len(line), fn, i+1, line_newline_stripped))
lastLine = line
if lineFlag and '\n' not in lastLine:

View File

@ -894,7 +894,7 @@ def do_send_messages(messages):
send_event(event, users)
if (settings.ENABLE_FEEDBACK and
message['message'].recipient.type == Recipient.PERSONAL and
settings.FEEDBACK_BOT in [up.email for up in message['recipients']]):
settings.FEEDBACK_BOT in [up.email for up in message['recipients']]):
queue_json_publish(
'feedback_messages',
message_to_dict(message['message'], apply_markdown=False),
@ -1080,7 +1080,7 @@ def recipient_for_emails(emails, not_forged_mirror_message,
# If the private message is just between the sender and
# another person, force it to be a personal internally
if (len(recipient_profile_ids) == 2
and sender.id in recipient_profile_ids):
and sender.id in recipient_profile_ids):
recipient_profile_ids.remove(sender.id)
if len(recipient_profile_ids) > 1:
@ -2370,7 +2370,7 @@ def do_update_user_activity_interval(user_profile, log_time):
# (2) The end of the new interval could be inside the old interval
# In either case, we just extend the old interval to include the new interval.
if ((log_time <= last.end and log_time >= last.start) or
(effective_end <= last.end and effective_end >= last.start)):
(effective_end <= last.end and effective_end >= last.start)):
last.end = max(last.end, effective_end)
last.start = min(last.start, log_time)
last.save(update_fields=["start", "end"])
@ -3059,7 +3059,7 @@ def apply_events(state, events, user_profile):
# solved by removing the all-realm-bots data
# given to admin users from this flow.
if ('is_admin' in person and 'realm_bots' in state and
user_profile.email == person['email']):
user_profile.email == person['email']):
if p['is_admin'] and not person['is_admin']:
state['realm_bots'] = []
if not p['is_admin'] and person['is_admin']:
@ -3170,17 +3170,17 @@ def apply_events(state, events, user_profile):
user_id = event['user_id']
for sub in state['subscriptions']:
if (sub['name'] in event['subscriptions'] and
user_id not in sub['subscribers']):
user_id not in sub['subscribers']):
sub['subscribers'].append(user_id)
for sub in state['never_subscribed']:
if (sub['name'] in event['subscriptions'] and
user_id not in sub['subscribers']):
user_id not in sub['subscribers']):
sub['subscribers'].append(user_id)
elif event['op'] == 'peer_remove':
user_id = event['user_id']
for sub in state['subscriptions']:
if (sub['name'] in event['subscriptions'] and
user_id in sub['subscribers']):
user_id in sub['subscribers']):
sub['subscribers'].remove(user_id)
elif event['type'] == "presence":
state['presences'][event['email']] = event['presence']

View File

@ -818,7 +818,7 @@ class BugdownUListPreprocessor(markdown.preprocessors.Preprocessor):
# hanging off a paragraph, add a newline
if (not fence and lines[i] and
self.LI_RE.match(lines[i+1]) and
not self.LI_RE.match(lines[i])):
not self.LI_RE.match(lines[i])):
copy.insert(i+inserts+1, '')
inserts += 1

View File

@ -85,7 +85,7 @@ def rest_dispatch(request, **kwargs):
# for some special views (e.g. serving a file that has been
# uploaded), we support using the same url for web and API clients.
if ('override_api_url_scheme' in view_flags
and request.META.get('HTTP_AUTHORIZATION', None) is not None):
and request.META.get('HTTP_AUTHORIZATION', None) is not None):
# This request API based authentication.
target_function = authenticated_rest_api_view()(target_function)
# /json views (web client) validate with a session token (cookie)

View File

@ -139,7 +139,7 @@ class Command(BaseCommand):
# We're probably running from cron, try to batch-process mail
if (not settings.EMAIL_GATEWAY_BOT or not settings.EMAIL_GATEWAY_LOGIN or
not settings.EMAIL_GATEWAY_PASSWORD or not settings.EMAIL_GATEWAY_IMAP_SERVER or
not settings.EMAIL_GATEWAY_IMAP_PORT or not settings.EMAIL_GATEWAY_IMAP_FOLDER):
not settings.EMAIL_GATEWAY_IMAP_PORT or not settings.EMAIL_GATEWAY_IMAP_FOLDER):
print("Please configure the Email Mirror Gateway in /etc/zulip/, "
"or specify $ORIGINAL_RECIPIENT if piping a single mail.")
exit(1)

View File

@ -351,7 +351,7 @@ class SessionHostDomainMiddleware(SessionMiddleware):
# type: (HttpRequest, HttpResponse) -> HttpResponse
if settings.REALMS_HAVE_SUBDOMAINS:
if (not request.path.startswith("/static/") and not request.path.startswith("/api/")
and not request.path.startswith("/json/")):
and not request.path.startswith("/json/")):
subdomain = get_subdomain(request)
if (request.get_host() == "127.0.0.1:9991" or request.get_host() == "localhost:9991"):
return redirect("%s%s" % (settings.EXTERNAL_URI_SCHEME,

View File

@ -262,7 +262,7 @@ class EventQueue(object):
self.next_event_id += 1
full_event_type = compute_full_event_type(event)
if (full_event_type in ["pointer", "restart"] or
full_event_type.startswith("flags/")):
full_event_type.startswith("flags/")):
if full_event_type not in self.virtual_events:
self.virtual_events[full_event_type] = copy.deepcopy(event)
return
@ -760,7 +760,7 @@ def process_message_event(event_template, users):
# The below prevents (Zephyr) mirroring loops.
if ('mirror' in sending_client and
sending_client.lower() == client.client_type_name.lower()):
sending_client.lower() == client.client_type_name.lower()):
continue
client.add_event(user_event)

View File

@ -844,7 +844,7 @@ def send_message_backend(request, user_profile,
if client.name == "zephyr_mirror" and not user_profile.realm.is_zephyr_mirror_realm:
return json_error(_("Invalid mirrored realm"))
if (client.name == "irc_mirror" and message_type_name != "private" and
not message_to[0].startswith("#")):
not message_to[0].startswith("#")):
return json_error(_("IRC stream names must start with #"))
sender = mirror_sender
else:

View File

@ -62,7 +62,7 @@ def update_realm(request, user_profile, name=REQ(validator=check_string, default
data['create_stream_by_admins_only'] = create_stream_by_admins_only
if (allow_message_editing is not None and realm.allow_message_editing != allow_message_editing) or \
(message_content_edit_limit_seconds is not None and
realm.message_content_edit_limit_seconds != message_content_edit_limit_seconds):
realm.message_content_edit_limit_seconds != message_content_edit_limit_seconds):
if allow_message_editing is None:
allow_message_editing = realm.allow_message_editing
if message_content_edit_limit_seconds is None:

View File

@ -122,7 +122,7 @@ def principal_to_user_profile(agent, principal):
principal_doesnt_exist = True
if (principal_doesnt_exist
or agent.realm != principal_user_profile.realm):
or agent.realm != principal_user_profile.realm):
# We have to make sure we don't leak information about which users
# are registered for Zulip in a different realm. We could do
# something a little more clever and check the domain part of the

View File

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

View File

@ -230,7 +230,7 @@ def add_bot_backend(request, user_profile, full_name=REQ(), short_name=REQ(),
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
subscribed_to_stream(user_profile, default_sending_stream)):
subscribed_to_stream(user_profile, default_sending_stream)):
return json_error(_('Insufficient permission'))

View File

@ -328,7 +328,7 @@ def send_messages(data):
randkey = random.randint(1, random_max)
if (num_messages > 0 and
random.randint(1, random_max) * 100. / random_max < options["stickyness"]):
random.randint(1, random_max) * 100. / random_max < options["stickyness"]):
# Use an old recipient
message_type, recipient_id, saved_data = recipients[num_messages - 1]
if message_type == Recipient.PERSONAL: