From e9158dd520150f841e5d6aeef5c6a2f889432aa4 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 23 Jan 2017 21:02:39 -0800 Subject: [PATCH] lint: Clean up E121 PEP-8 rule. --- api/integrations/twitter/twitter-bot | 8 ++++---- api/integrations/twitter/twitter-search-bot | 8 ++++---- contrib_bots/bots/john/john.py | 12 ++++++------ docs/conf.py | 10 +++++----- tools/check-provision | 2 +- tools/lint-all | 4 ++-- zerver/lib/cache.py | 3 +-- zerver/lib/digest.py | 6 +++--- zerver/lib/export.py | 2 +- zerver/management/commands/deactivate_user.py | 2 +- zerver/tests/test_signup.py | 4 ++-- zerver/tests/tests.py | 4 ++-- zerver/views/webhooks/github.py | 6 +++--- zilencer/error_notify.py | 2 +- zproject/settings.py | 2 +- 15 files changed, 37 insertions(+), 38 deletions(-) diff --git a/api/integrations/twitter/twitter-bot b/api/integrations/twitter/twitter-bot index eb078309c3..e3ae2ae8e4 100755 --- a/api/integrations/twitter/twitter-bot +++ b/api/integrations/twitter/twitter-bot @@ -150,10 +150,10 @@ else: for status in statuses[::-1][:options.limit_tweets]: composed = "%s (%s)" % (status.user.name, status.user.screen_name) message = { - "type": "stream", - "to": [options.stream], - "subject": composed, - "content": status.text, + "type": "stream", + "to": [options.stream], + "subject": composed, + "content": status.text, } ret = client.send_message(message) diff --git a/api/integrations/twitter/twitter-search-bot b/api/integrations/twitter/twitter-search-bot index a10bca7cfd..b1f7353ecf 100755 --- a/api/integrations/twitter/twitter-search-bot +++ b/api/integrations/twitter/twitter-search-bot @@ -176,10 +176,10 @@ for status in statuses[::-1][:opts.limit_tweets]: search_term_used = "mentions" message = { - "type": "stream", - "to": [opts.stream], - "subject": search_term_used, - "content": url, + "type": "stream", + "to": [opts.stream], + "subject": search_term_used, + "content": url, } ret = client.send_message(message) diff --git a/contrib_bots/bots/john/john.py b/contrib_bots/bots/john/john.py index d68d317ecb..ccfce658aa 100644 --- a/contrib_bots/bots/john/john.py +++ b/contrib_bots/bots/john/john.py @@ -32,12 +32,12 @@ def create_chat_bot(no_learn): storage_adapter="chatterbot.storage.JsonFileStorageAdapter", logic_adapters= [ - "chatterbot.logic.MathematicalEvaluation", - { - "import_path": "chatterbot.logic.BestMatch", - "response_selection_method": "chatterbot.response_selection.get_random_response", - "statement_comparison_function": "chatterbot.comparisons.levenshtein_distance" - }], + "chatterbot.logic.MathematicalEvaluation", + { + "import_path": "chatterbot.logic.BestMatch", + "response_selection_method": "chatterbot.response_selection.get_random_response", + "statement_comparison_function": "chatterbot.comparisons.levenshtein_distance" + }], output_adapter="chatterbot.output.OutputFormatAdapter", output_format='text', database=DATABASE_PATH, diff --git a/docs/conf.py b/docs/conf.py index dfd5310e61..9e316ea640 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -232,8 +232,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'zulip-contributor-docs.tex', u'Zulip Documentation', - u'The Zulip Team', 'manual'), + (master_doc, 'zulip-contributor-docs.tex', u'Zulip Documentation', + u'The Zulip Team', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -276,9 +276,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'zulip-contributor-docs', u'Zulip Documentation', - author, 'zulip-contributor-docs', 'Documentation for contributing to Zulip.', - 'Miscellaneous'), + (master_doc, 'zulip-contributor-docs', u'Zulip Documentation', + author, 'zulip-contributor-docs', 'Documentation for contributing to Zulip.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. diff --git a/tools/check-provision b/tools/check-provision index 3e57e991b9..1d061e4cad 100755 --- a/tools/check-provision +++ b/tools/check-provision @@ -12,7 +12,7 @@ sys.path.insert(0, root_dir) from tools.lib.test_script import ( get_provisioning_status, - ) +) def run(): # type: () -> None diff --git a/tools/lint-all b/tools/lint-all index f42162297e..de53fbf04e 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -87,7 +87,7 @@ def check_pep8(files): # ignored. It either doesn't fit with the style of the project or should # actually be cleaned up. # - 'E121', 'E123', 'E126', 'E226', 'E241', 'E261', 'E302', + 'E123', 'E126', 'E226', 'E241', 'E261', 'E302', 'E305', 'E306', 'E401', 'E501', 'E702', 'E711', 'E712', 'E713', 'E714', 'E741', @@ -235,7 +235,7 @@ def build_custom_checkers(by_lang): {'pattern': '^#+[A-Za-z0-9]', 'strip': '\n', 'description': 'Missing space after # in heading'}, - ] # type: RuleList + ] # type: RuleList js_rules = cast(RuleList, [ {'pattern': '[^_]function\(', 'description': 'The keyword "function" should be followed by a space'}, diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index 77f055efca..96961f623f 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -403,8 +403,7 @@ def flush_stream(sender, **kwargs): if kwargs.get('update_fields') is None or 'name' in kwargs['update_fields'] and \ UserProfile.objects.filter( Q(default_sending_stream=stream) | - Q(default_events_register_stream=stream) - ).exists(): + Q(default_events_register_stream=stream)).exists(): cache_delete(active_bot_dicts_in_realm_cache_key(stream.realm)) # TODO: Rename to_dict_cache_key_id and to_dict_cache_key diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py index 629b0977aa..60dee604bb 100644 --- a/zerver/lib/digest.py +++ b/zerver/lib/digest.py @@ -88,13 +88,13 @@ 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]] + 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)} + 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 647117c778..4d4b6894b9 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -260,7 +260,7 @@ class Config(object): self.table, self.id_source[0], self.virtual_parent.table, - )) + )) def export_from_config(response, config, seed_object=None, context=None): diff --git a/zerver/management/commands/deactivate_user.py b/zerver/management/commands/deactivate_user.py index e6c203f0a4..4315793f9a 100644 --- a/zerver/management/commands/deactivate_user.py +++ b/zerver/management/commands/deactivate_user.py @@ -40,7 +40,7 @@ class Command(BaseCommand): UserProfile.objects.filter( is_bot=True, is_active=True, bot_owner=user_profile ).count() - )) + )) if not options["for_real"]: print("This was a dry run. Pass -f to actually deactivate.") diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index be43b24c69..fbc49d6555 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -479,7 +479,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): @@ -503,7 +503,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/tests.py b/zerver/tests/tests.py index 0377605f8d..b32a5f810d 100644 --- a/zerver/tests/tests.py +++ b/zerver/tests/tests.py @@ -992,7 +992,7 @@ class BotTest(ZulipTestCase): 'full_name': 'The Bot of Hamlet', 'short_name': 'hambot', 'default_sending_stream': 'Denmark', - } + } result = self.client_post("/json/bots", bot_info) self.assert_json_error(result, 'Insufficient permission') @@ -1055,7 +1055,7 @@ class BotTest(ZulipTestCase): 'full_name': 'The Bot of Hamlet', 'short_name': 'hambot', 'default_events_register_stream': 'Denmark', - } + } result = self.client_post("/json/bots", bot_info) self.assert_json_error(result, 'Insufficient permission') diff --git a/zerver/views/webhooks/github.py b/zerver/views/webhooks/github.py index 3509399824..055c05a108 100644 --- a/zerver/views/webhooks/github.py +++ b/zerver/views/webhooks/github.py @@ -49,7 +49,7 @@ def github_pull_request_content(payload): action, pull_request['html_url'], pull_request['number'] - ) + ) def github_issues_content(payload): # type: (Mapping[Text, Any]) -> Text @@ -70,7 +70,7 @@ def github_issues_content(payload): action, issue['html_url'], issue['number'], - ) + ) def github_object_commented_content(payload, type): # type: (Mapping[Text, Any], Text) -> Text @@ -104,7 +104,7 @@ def get_pull_request_or_issue_subject(repository, payload_object, type): type=type, id=payload_object['number'], title=payload_object['title'] - ) + ) def github_generic_subject(noun, topic_focus, blob): # type: (Text, Text, Mapping[Text, Any]) -> Text diff --git a/zilencer/error_notify.py b/zilencer/error_notify.py index c6f8d9e5bd..43d3bafe40 100644 --- a/zilencer/error_notify.py +++ b/zilencer/error_notify.py @@ -98,7 +98,7 @@ def zulip_server_error(report): internal_send_message(realm, 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)) + user_info, stack_trace, request_repr)) def email_server_error(report): # type: (Dict[str, Any]) -> None diff --git a/zproject/settings.py b/zproject/settings.py index 90e6f6ab3d..e0c7f7a696 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -558,7 +558,7 @@ if PRODUCTION: {'var_name': 'NAGIOS_STAGING_RECEIVE_BOT', 'email_template': 'nagios-staging-receive-bot@%s', 'name': 'Nagios Staging Receive Bot'}, - ] + ] INTERNAL_BOT_DOMAIN = "zulip.com"