From c8ddea16c384aa00d4afa3e267e5d4b811877ba1 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 1 Dec 2016 23:15:16 -0800 Subject: [PATCH] pep8: Fix E122. --- bots/jabber_mirror_backend.py | 4 ++-- tools/lint-all | 3 ++- zerver/lib/actions.py | 2 +- zerver/lib/cache_helpers.py | 8 ++++---- zerver/lib/digest.py | 10 +++++----- zerver/lib/export.py | 8 ++++---- zerver/management/commands/enqueue_digest_emails.py | 2 +- zerver/tests/test_i18n.py | 2 +- zerver/tests/test_messages.py | 4 ++-- zerver/tests/test_signup.py | 10 +++++----- zerver/tests/test_subs.py | 2 +- zerver/views/__init__.py | 4 ++-- zilencer/error_notify.py | 6 +++--- zproject/prod_settings_template.py | 12 ++++++------ 14 files changed, 39 insertions(+), 38 deletions(-) diff --git a/bots/jabber_mirror_backend.py b/bots/jabber_mirror_backend.py index 0ad3ed2726..3a84b00a95 100755 --- a/bots/jabber_mirror_backend.py +++ b/bots/jabber_mirror_backend.py @@ -303,11 +303,11 @@ zulip configuration file under the jabber_mirror section (exceptions are noted in their help sections). Keys have the same name as options with hyphens replaced with underscores. Zulip configuration options go in the api section, as normal.'''.replace("\n", " ") -) + ) parser.add_option('--mode', default=None, action='store', - help= \ + help= '''Which mode to run in. Valid options are "personal" and "public". In "personal" mode, the mirror uses an individual users' credentials and mirrors all messages they send on Zulip to Jabber and all private Jabber messages to diff --git a/tools/lint-all b/tools/lint-all index b2709c496c..c30bcb7623 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -23,6 +23,7 @@ except ImportError as e: EXCLUDED_FILES = """ api/integrations/perforce/git_p4.py api/setup.py +docs/conf.py docs/html_unescape.py node_modules puppet/apt/.forge-release @@ -83,7 +84,7 @@ def check_pep8(files): failed = False ignored_rules = [ 'E402', 'E501', 'W503', 'E711', 'E128', 'E226', - 'E126', 'E121', 'E122', 'E123', 'E266', 'E265', 'E261', 'E221', 'E303', + 'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221', 'E303', 'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302', 'E129', 'E741', 'E714', 'W391', 'E713', 'E502', 'E131', 'E305', 'E251', 'E306', ] diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index c7a75769eb..4c33851ed5 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -335,7 +335,7 @@ def process_new_human_user(user_profile, prereg_user=None, newsletter_data=None) 'OPTIN_TIME': datetime.datetime.isoformat(now().replace(microsecond=0)), }, }, - lambda event: None) + lambda event: None) def notify_created_user(user_profile): # type: (UserProfile) -> None diff --git a/zerver/lib/cache_helpers.py b/zerver/lib/cache_helpers.py index 8f032253ef..0661b5cc0a 100644 --- a/zerver/lib/cache_helpers.py +++ b/zerver/lib/cache_helpers.py @@ -72,10 +72,10 @@ cache_fillers = { 'client': (lambda: Client.objects.select_related().all(), client_cache_items, 3600*24*7, 10000), 'recipient': (lambda: Recipient.objects.select_related().all(), recipient_cache_items, 3600*24*7, 10000), 'stream': (lambda: Stream.objects.select_related().all(), stream_cache_items, 3600*24*7, 10000), -### Message cache fetching disabled until we can fix the fact that it -### does a bunch of inefficient memcached queries as part of filling -### the display_recipient cache -# 'message': (message_fetch_objects, message_cache_items, 3600 * 24, 1000), + # Message cache fetching disabled until we can fix the fact that it + # does a bunch of inefficient memcached queries as part of filling + # the display_recipient cache + # 'message': (message_fetch_objects, message_cache_items, 3600 * 24, 1000), 'huddle': (lambda: Huddle.objects.select_related().all(), huddle_cache_items, 3600*24*7, 10000), 'session': (lambda: Session.objects.all(), session_cache_items, 3600*24*7, 10000), } # type: Dict[str, Tuple[Callable[[], List[Any]], Callable[[Dict[text_type, Any], Any], None], int, int]] diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py index 562db53df7..851916582a 100644 --- a/zerver/lib/digest.py +++ b/zerver/lib/digest.py @@ -88,14 +88,14 @@ def gather_hot_conversations(user_profile, stream_messages): # We'll display up to 2 messages from the conversation. first_few_messages = [user_message.message for user_message in \ - stream_messages.filter( - message__recipient__type_id=stream_id, - message__subject=subject)[:2]] + stream_messages.filter( + message__recipient__type_id=stream_id, + message__subject=subject)[:2]] teaser_data = {"participants": users, "count": count - len(first_few_messages), - "first_few_messages": build_message_list(user_profile, - first_few_messages)} + "first_few_messages": build_message_list( + user_profile, first_few_messages)} hot_conversation_render_payloads.append(teaser_data) return hot_conversation_render_payloads diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 3a1f3ade2a..d2a8c782b8 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -589,10 +589,10 @@ def fetch_user_profile_cross_realm(response, config, context): response['zerver_userprofile_crossrealm'] = [] else: response['zerver_userprofile_crossrealm'] = [dict(email=x.email, id=x.id) for x in [ - get_user_profile_by_email(settings.NOTIFICATION_BOT), - get_user_profile_by_email(settings.EMAIL_GATEWAY_BOT), - get_user_profile_by_email(settings.WELCOME_BOT), - ]] + get_user_profile_by_email(settings.NOTIFICATION_BOT), + get_user_profile_by_email(settings.EMAIL_GATEWAY_BOT), + get_user_profile_by_email(settings.WELCOME_BOT), + ]] def fetch_attachment_data(response, realm_id, message_ids): # type: (TableData, int, Set[int]) -> None diff --git a/zerver/management/commands/enqueue_digest_emails.py b/zerver/management/commands/enqueue_digest_emails.py index 80703fd962..b5706051d6 100644 --- a/zerver/management/commands/enqueue_digest_emails.py +++ b/zerver/management/commands/enqueue_digest_emails.py @@ -29,7 +29,7 @@ VALID_DIGEST_DAYS = (1, 2, 3, 4) def inactive_since(user_profile, cutoff): # type: (UserProfile, datetime.datetime) -> bool # Hasn't used the app in the last 24 business-day hours. - most_recent_visit = [row.last_visit for row in \ + most_recent_visit = [row.last_visit for row in UserActivity.objects.filter( user_profile=user_profile)] diff --git a/zerver/tests/test_i18n.py b/zerver/tests/test_i18n.py index de49741d6f..e2d80fecb2 100644 --- a/zerver/tests/test_i18n.py +++ b/zerver/tests/test_i18n.py @@ -28,7 +28,7 @@ class TranslationTestCase(ZulipTestCase): response = getattr(self.client, method)(url, **kwargs) self.assertEqual(response.status_code, expected_status, msg="Expected %d, received %d for %s to %s" % ( - expected_status, response.status_code, method, url)) + expected_status, response.status_code, method, url)) return response def test_accept_language_header(self): diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index f87fd35efc..9fd5ad7a5b 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -1467,8 +1467,8 @@ class AttachmentTest(ZulipTestCase): self.subscribe_to_stream(sender_email, "Denmark") body = "Some files here ...[zulip.txt](http://localhost:9991/user_uploads/1/31/4CBjtTLYZhk66pZrF8hnYGwc/zulip.txt)" + \ - "http://localhost:9991/user_uploads/1/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py.... Some more...." + \ - "http://localhost:9991/user_uploads/1/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py" + "http://localhost:9991/user_uploads/1/31/4CBjtTLYZhk66pZrF8hnYGwc/temp_file.py.... Some more...." + \ + "http://localhost:9991/user_uploads/1/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py" self.send_message(sender_email, "Denmark", Recipient.STREAM, body, "test") diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 9a9fe0caa0..ec81cd8077 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -57,7 +57,7 @@ class PublicURLTest(ZulipTestCase): response = getattr(self.client, method)(url) # e.g. self.client_post(url) if method is "post" self.assertEqual(response.status_code, expected_status, msg="Expected %d, received %d for %s to %s" % ( - expected_status, response.status_code, method, url)) + expected_status, response.status_code, method, url)) def test_public_urls(self): # type: () -> None @@ -406,8 +406,8 @@ class InviteUserTest(ZulipTestCase): self.login("hamlet@zulip.com") # Intentionally use a weird string. self.assert_json_success(self.invite( -"""bob-test@zulip.com, carol-test@zulip.com, -dave-test@zulip.com + """bob-test@zulip.com, carol-test@zulip.com, + dave-test@zulip.com earl-test@zulip.com""", ["Denmark"])) @@ -455,7 +455,7 @@ earl-test@zulip.com""", ["Denmark"])) "We weren't able to invite anyone.") self.assertRaises(PreregistrationUser.DoesNotExist, lambda: PreregistrationUser.objects.get( - email="hamlet@zulip.com")) + email="hamlet@zulip.com")) self.check_sent_emails([]) def test_invite_some_existing_some_new(self): @@ -479,7 +479,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!" for email in existing: self.assertRaises(PreregistrationUser.DoesNotExist, lambda: PreregistrationUser.objects.get( - email=email)) + email=email)) for email in new: self.assertTrue(PreregistrationUser.objects.get(email=email)) diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index a63c11b042..5ab230b4f9 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -1377,7 +1377,7 @@ class SubscriptionAPITest(ZulipTestCase): self.test_email, streams_to_sub, dict(principals=ujson.dumps([email1, email2])), - ) + ) self.assert_max_length(queries, 43) self.assert_length(events, 8) diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index ee3dcc5934..0bd3654a6d 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -424,9 +424,9 @@ def accounts_home(request): def approximate_unread_count(user_profile): # type: (UserProfile) -> int - not_in_home_view_recipients = [sub.recipient.id for sub in \ + not_in_home_view_recipients = [sub.recipient.id for sub in Subscription.objects.filter( - user_profile=user_profile, in_home_view=False)] + user_profile=user_profile, in_home_view=False)] # TODO: We may want to exclude muted messages from this count. # It was attempted in the past, but the original attempt diff --git a/zilencer/error_notify.py b/zilencer/error_notify.py index c6f23352a7..77e01a8c1a 100644 --- a/zilencer/error_notify.py +++ b/zilencer/error_notify.py @@ -93,9 +93,9 @@ def zulip_server_error(report): request_repr += "~~~~" internal_send_message(settings.ERROR_BOT, - "stream", "errors", format_subject(subject), - "Error generated by %s\n\n~~~~ pytb\n%s\n\n~~~~\n%s" % ( - user_info, stack_trace, request_repr)) + "stream", "errors", format_subject(subject), + "Error generated by %s\n\n~~~~ pytb\n%s\n\n~~~~\n%s" % ( + user_info, stack_trace, request_repr)) def email_server_error(report): # type: (Dict[str, Any]) -> None diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py index ef921da38d..2507702351 100644 --- a/zproject/prod_settings_template.py +++ b/zproject/prod_settings_template.py @@ -20,11 +20,11 @@ ZULIP_ADMINISTRATOR = 'zulip-admin@example.com' # See http://zulip.readthedocs.io/en/latest/prod-authentication-methods.html # for documentation on our authentication backends. AUTHENTICATION_BACKENDS = ( -# 'zproject.backends.EmailAuthBackend', # Email and password; see SMTP setup below -# 'zproject.backends.GoogleMobileOauth2Backend', # Google Apps, setup below -# 'zproject.backends.GitHubAuthBackend', # GitHub auth, setup below -# 'zproject.backends.ZulipLDAPAuthBackend', # LDAP, setup below -# 'zproject.backends.ZulipRemoteUserBackend', # Local SSO, setup docs on readthedocs + # 'zproject.backends.EmailAuthBackend', # Email and password; see SMTP setup below + # 'zproject.backends.GoogleMobileOauth2Backend', # Google Apps, setup below + # 'zproject.backends.GitHubAuthBackend', # GitHub auth, setup below + # 'zproject.backends.ZulipLDAPAuthBackend', # LDAP, setup below + # 'zproject.backends.ZulipRemoteUserBackend', # Local SSO, setup docs on readthedocs ) # To enable Google authentication, you need to do the following: @@ -332,7 +332,7 @@ LDAP_APPEND_DOMAIN = None # type: str # This map defines how to populate attributes of a Zulip user from LDAP. AUTH_LDAP_USER_ATTR_MAP = { -# Populate the Django user's name from the LDAP directory. + # Populate the Django user's name from the LDAP directory. "full_name": "cn", }