From 6b0df43463709fcd0f6054798c6378a72133976c Mon Sep 17 00:00:00 2001 From: Bickio Date: Thu, 1 Dec 2016 09:54:51 +1300 Subject: [PATCH] pep8: Fix E125. --- bots/zephyr_mirror_backend.py | 8 ++++---- .../zulip_app_frontend/check_send_receive_time | 2 +- tools/lint-all | 2 +- zerver/lib/bugdown/__init__.py | 6 ++++-- zerver/lib/cache.py | 4 ++-- zerver/lib/test_fixtures.py | 3 +-- zerver/lib/upload.py | 3 +-- zerver/views/user_settings.py | 7 ++++--- zerver/views/users.py | 8 +++++--- 9 files changed, 23 insertions(+), 20 deletions(-) diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 1b93ff1d3e..131b1d125a 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -103,9 +103,9 @@ def unwrap_lines(body): and re.match(r'^\W', previous_line, flags=re.UNICODE)): result += previous_line + "\n" elif (line == "" or - previous_line == "" or - re.match(r'^\W', line, flags=re.UNICODE) or - different_paragraph(previous_line, line)): + previous_line == "" or + re.match(r'^\W', line, flags=re.UNICODE) or + different_paragraph(previous_line, line)): # Use 2 newlines to separate sections so that we # trigger proper Markdown processing on things like # bulleted lists @@ -622,7 +622,7 @@ Feedback button or at support@zulipchat.com.""" # appropriate WHITESPACE instance for bidirectional mirroring instance = match_whitespace_instance.group(1) elif (instance == "instance %s" % (zephyr_class,) or - instance == "test instance %s" % (zephyr_class,)): + instance == "test instance %s" % (zephyr_class,)): # Forward messages to e.g. -c -i white-magic back from the # place we forward them to if instance.startswith("test"): diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time index eaaef23f45..90219623a9 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time +++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time @@ -121,7 +121,7 @@ def get_zulips(): return [event['message'] for event in res['events']] if "staging" in options.site and settings.NAGIOS_STAGING_SEND_BOT is not None and \ - settings.NAGIOS_STAGING_RECEIVE_BOT is not None: + settings.NAGIOS_STAGING_RECEIVE_BOT is not None: sender = get_user_profile_by_email(settings.NAGIOS_STAGING_SEND_BOT) recipient = get_user_profile_by_email(settings.NAGIOS_STAGING_RECEIVE_BOT) else: diff --git a/tools/lint-all b/tools/lint-all index bccae6c80e..4ded579473 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -82,7 +82,7 @@ def check_pep8(files): # type: (List[str]) -> bool failed = False ignored_rules = [ - 'E402', 'E501', 'W503', 'E711', 'E201', 'E203', 'E202', 'E128', 'E226', 'E124', 'E125', + 'E402', 'E501', 'W503', 'E711', 'E201', 'E203', 'E202', 'E128', 'E226', 'E124', 'E126', 'E127', 'E121', 'E122', 'E123', 'E266', 'E265', 'E261', 'E221', 'E303', 'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E111', 'E731', 'E302', 'E129', 'E741', 'E714', 'W391', 'E211', 'E713', 'E502', 'E131', 'E305', 'E251', 'E306', diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index ea8992230f..4076b3a78a 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -816,8 +816,10 @@ class BugdownUListPreprocessor(markdown.preprocessors.Preprocessor): # If we're not in a fenced block and we detect an upcoming list # 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]): + if (not fence and lines[i] and + self.LI_RE.match(lines[i+1]) and + not self.LI_RE.match(lines[i])): + copy.insert(i+inserts+1, '') inserts += 1 return copy diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index b6bc917ccf..5904c6a79e 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -335,7 +335,8 @@ def flush_user_profile(sender, **kwargs): # Invalidate our active_users_in_realm info dict if any user has changed # the fields in the dict or become (in)active if kwargs.get('update_fields') is None or \ - len(set(active_user_dict_fields + ['is_active']) & set(kwargs['update_fields'])) > 0: + len(set(active_user_dict_fields + ['is_active']) & + set(kwargs['update_fields'])) > 0: cache_delete(active_user_dicts_in_realm_cache_key(user_profile.realm)) # Invalidate our active_bots_in_realm info dict if any bot has @@ -399,4 +400,3 @@ def flush_message(sender, **kwargs): message = kwargs['instance'] cache_delete(to_dict_cache_key(message, False)) cache_delete(to_dict_cache_key(message, True)) - diff --git a/zerver/lib/test_fixtures.py b/zerver/lib/test_fixtures.py index f0a7c814c5..05695cdd32 100644 --- a/zerver/lib/test_fixtures.py +++ b/zerver/lib/test_fixtures.py @@ -98,8 +98,7 @@ def is_template_database_current( database_name='zulip_test_template', migration_status='var/migration-status', settings='zproject.test_settings', - check_files=None - ): + check_files=None): # type: (Optional[text_type], Optional[text_type], Optional[text_type], Optional[List[str]]) -> bool # Using str type for check_files because re.split doesn't accept unicode if check_files is None: diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index faf2590264..05f757fd59 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -137,8 +137,7 @@ def upload_image_to_s3( file_name, content_type, user_profile, - contents, - ): + contents): # type: (NonBinaryStr, text_type, Optional[text_type], UserProfile, binary_type) -> None conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY) diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index d52b3eb9f0..cdbfcd32c6 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -93,7 +93,7 @@ def json_time_setting(request, user_profile, twenty_four_hour_time=REQ(validator # type: (HttpRequest, UserProfile, Optional[bool]) -> HttpResponse result = {} if twenty_four_hour_time is not None and \ - user_profile.twenty_four_hour_time != twenty_four_hour_time: + user_profile.twenty_four_hour_time != twenty_four_hour_time: do_change_twenty_four_hour_time(user_profile, twenty_four_hour_time) result['twenty_four_hour_time'] = twenty_four_hour_time @@ -105,8 +105,9 @@ 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 \ - user_profile.left_side_userlist != left_side_userlist: + 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) result['left_side_userlist'] = left_side_userlist diff --git a/zerver/views/users.py b/zerver/views/users.py index 2c82cc8f92..240b697b02 100644 --- a/zerver/views/users.py +++ b/zerver/views/users.py @@ -228,8 +228,10 @@ def add_bot_backend(request, user_profile, full_name=REQ(), short_name=REQ(), default_sending_stream = None 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 \ - subscribed_to_stream(user_profile, default_sending_stream): + if (default_sending_stream and not + default_sending_stream.is_public() and not \ + subscribed_to_stream(user_profile, default_sending_stream)): + return json_error(_('Insufficient permission')) default_events_register_stream = None @@ -237,7 +239,7 @@ def add_bot_backend(request, user_profile, full_name=REQ(), short_name=REQ(), default_events_register_stream = stream_or_none(default_events_register_stream_name, user_profile.realm) if default_events_register_stream and not default_events_register_stream.is_public() and not \ - subscribed_to_stream(user_profile, default_events_register_stream): + subscribed_to_stream(user_profile, default_events_register_stream): return json_error(_('Insufficient permission'))