From d6e38e2a5c8ec2353bb64a33a3d4f44fc7cad8c1 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 23 Jan 2017 21:34:26 -0800 Subject: [PATCH] lint: Clean up E123 PEP-8 rule. --- analytics/lib/counts.py | 2 +- api/examples/create-user | 2 +- api/integrations/trac/zulip_trac.py | 2 +- api/zulip/__init__.py | 2 +- bots/check-mirroring | 6 ++--- bots/irc-mirror.py | 4 +-- bots/jabber_mirror_backend.py | 4 +-- bots/log2zulip | 2 +- contrib_bots/bot_lib.py | 2 +- contrib_bots/bots/foursquare/foursquare.py | 2 +- docs/conf.py | 4 +-- .../check_send_receive_time | 4 +-- .../check_postgres_replication_lag | 2 +- .../zulip_postgres_appdb/check_fts_update_log | 2 +- .../check_postgres_backup | 2 +- .../check_personal_zephyr_mirrors | 2 +- .../check_user_zephyr_mirror_liveness | 4 +-- .../zulip_zephyr_mirror/check_zephyr_mirror | 2 +- tools/lint-all | 14 +++++----- zerver/lib/actions.py | 2 +- zerver/lib/cache_helpers.py | 2 +- zerver/lib/db.py | 4 +-- zerver/lib/digest.py | 2 +- zerver/lib/export.py | 5 ++-- zerver/lib/test_runner.py | 2 +- zerver/migrations/0001_initial.py | 2 +- zerver/models.py | 2 +- zerver/tests/test_bugdown.py | 6 ++--- zerver/tests/test_decorators.py | 16 ++++++------ zerver/tests/test_events.py | 26 +++++++++---------- zerver/tests/test_messages.py | 2 +- zerver/tests/test_subs.py | 4 +-- zerver/tests/tests.py | 21 ++++++--------- zerver/views/integrations.py | 2 +- zerver/views/unsubscribe.py | 2 +- zerver/views/webhooks/freshdesk.py | 2 +- zerver/views/webhooks/github_webhook.py | 2 +- zerver/views/webhooks/taiga.py | 9 +++---- zerver/worker/queue_processors.py | 2 +- zilencer/management/commands/populate_db.py | 8 +++--- zproject/backends.py | 2 +- zproject/legacy_urls.py | 2 +- zproject/prod_settings_template.py | 2 +- zproject/settings.py | 17 ++++++------ 44 files changed, 101 insertions(+), 109 deletions(-) diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index fe6dfee065..3b78b5a3c8 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -350,4 +350,4 @@ COUNT_STATS = { 'messages_sent_to_stream:is_bot:hour': CountStat( 'messages_sent_to_stream:is_bot', zerver_count_message_by_stream, {}, (UserProfile, 'is_bot'), CountStat.HOUR, False) - } +} diff --git a/api/examples/create-user b/api/examples/create-user index 351e91f96b..a9c156d410 100755 --- a/api/examples/create-user +++ b/api/examples/create-user @@ -52,4 +52,4 @@ print(client.create_user({ 'password': options.new_password, 'full_name': options.new_full_name, 'short_name': options.new_short_name - })) +})) diff --git a/api/integrations/trac/zulip_trac.py b/api/integrations/trac/zulip_trac.py index 24187e9af0..0e17fca83b 100644 --- a/api/integrations/trac/zulip_trac.py +++ b/api/integrations/trac/zulip_trac.py @@ -80,7 +80,7 @@ def send_update(ticket, content): "to": config.STREAM_FOR_NOTIFICATIONS, "content": content, "subject": trac_subject(ticket) - }) + }) class ZulipPlugin(Component): implements(ITicketChangeListener) diff --git a/api/zulip/__init__.py b/api/zulip/__init__.py index 93650fef57..ddbdc75a2f 100644 --- a/api/zulip/__init__.py +++ b/api/zulip/__init__.py @@ -288,7 +288,7 @@ class Client(object): client_name=self.client_name, vendor=vendor, vendor_version=vendor_version, - ) + ) def do_api_query(self, orig_request, url, method="POST", longpolling=False, files=None): # type: (Mapping[str, Any], str, str, bool, List[IO]) -> Dict[str, Any] diff --git a/bots/check-mirroring b/bots/check-mirroring index 3a18a01ee1..449fbb3a02 100755 --- a/bots/check-mirroring +++ b/bots/check-mirroring @@ -90,7 +90,7 @@ if options.sharded: ("tabbott-nagios-test-12", "d"), ("tabbott-nagios-test-11", "e"), ("tabbott-nagios-test-9", "f"), - ] + ] for (stream, test) in test_streams: if stream == "message": continue @@ -99,7 +99,7 @@ else: test_streams = [ ("message", "p"), ("tabbott-nagios-test", "a"), - ] + ] def print_status_and_exit(status): # type: (int) -> None @@ -262,7 +262,7 @@ for key, (stream, test) in hzkeys.items(): "subject": "test", "content": str(key), "to": stream, - }) + }) receive_zephyrs() logger.info("Sent Zulip messages!") diff --git a/bots/irc-mirror.py b/bots/irc-mirror.py index 9d5c5cb78d..ddfae93799 100755 --- a/bots/irc-mirror.py +++ b/bots/irc-mirror.py @@ -69,7 +69,7 @@ class IRCBot(irc.bot.SingleServerIRCBot): "type": "private", "to": "username@example.com", "content": content, - })) + })) def on_pubmsg(self, c, e): # type: (ServerConnection, Event) -> None @@ -87,7 +87,7 @@ class IRCBot(irc.bot.SingleServerIRCBot): "to": stream, "subject": "IRC", "content": content, - })) + })) def on_dccmsg(self, c, e): # type: (ServerConnection, Event) -> None diff --git a/bots/jabber_mirror_backend.py b/bots/jabber_mirror_backend.py index 48cc29a381..8abbfcef17 100755 --- a/bots/jabber_mirror_backend.py +++ b/bots/jabber_mirror_backend.py @@ -171,7 +171,7 @@ class JabberToZulipBot(ClientXMPP): type = "private", to = recipient, content = msg["body"], - ) + ) ret = self.zulipToJabber.client.send_message(zulip_message) if ret.get("result") != "success": logging.error(str(ret)) @@ -199,7 +199,7 @@ class JabberToZulipBot(ClientXMPP): subject = subject, to = stream, content = msg["body"], - ) + ) ret = self.zulipToJabber.client.send_message(zulip_message) if ret.get("result") != "success": logging.error(str(ret)) diff --git a/bots/log2zulip b/bots/log2zulip index 533cd5df7b..839581bd75 100755 --- a/bots/log2zulip +++ b/bots/log2zulip @@ -45,7 +45,7 @@ def send_log_zulip(file_name, count, lines, extra=""): "to": "logs", "subject": "%s on %s" % (file_name, platform.node()), "content": content, - }) + }) def process_lines(raw_lines, file_name): # type: (List[str], str) -> None diff --git a/contrib_bots/bot_lib.py b/contrib_bots/bot_lib.py index e083068d9c..89fa68e4bd 100644 --- a/contrib_bots/bot_lib.py +++ b/contrib_bots/bot_lib.py @@ -85,7 +85,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file): message=message, client=restricted_client, state_handler=state_handler - ) + ) signal.signal(signal.SIGINT, exit_gracefully) diff --git a/contrib_bots/bots/foursquare/foursquare.py b/contrib_bots/bots/foursquare/foursquare.py index 22ce9248b1..e68ac4cc9c 100644 --- a/contrib_bots/bots/foursquare/foursquare.py +++ b/contrib_bots/bots/foursquare/foursquare.py @@ -80,7 +80,7 @@ Example Inputs: subject=message['subject'], to=message['display_recipient'], content=letter, - )) + )) def handle_message(self, message, client, state_handler): words = message['content'].split() diff --git a/docs/conf.py b/docs/conf.py index 9e316ea640..d1696140df 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -296,8 +296,8 @@ texinfo_documents = [ from recommonmark.parser import CommonMarkParser source_parsers = { - '.md': CommonMarkParser, - } + '.md': CommonMarkParser, +} # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: 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 f4ec235756..aefb922538 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 @@ -96,7 +96,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } +} def report(state, timestamp, msg=None): # type: (str, Any, Optional[str]) -> None @@ -177,7 +177,7 @@ else: "content": msg_to_send, "subject": "time to send", "to": recipient.email, - }) + }) msg_content = [] # type: List[str] diff --git a/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag b/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag index 3ebb62c8dc..d490dedc23 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag +++ b/puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_postgres_replication_lag @@ -14,7 +14,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } +} def report(state, msg): # type: (str, str) -> None diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log b/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log index 6f9b39d756..2e4117c1d0 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log +++ b/puppet/zulip/files/nagios_plugins/zulip_postgres_appdb/check_fts_update_log @@ -19,7 +19,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } +} def report(state, num): # type: (str, str) -> None diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup b/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup index 1e85030f54..50f01911f2 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup +++ b/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup @@ -13,7 +13,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } +} def report(state, msg): # type: (str, str) -> None diff --git a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors index b108a48018..bd20332be9 100755 --- a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors +++ b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors @@ -20,7 +20,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } # type: Dict[str, int] +} # type: Dict[str, int] def report(state, output): # type: (str, str) -> None diff --git a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_user_zephyr_mirror_liveness b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_user_zephyr_mirror_liveness index 36a1d55396..c63db9fa99 100755 --- a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_user_zephyr_mirror_liveness +++ b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_user_zephyr_mirror_liveness @@ -35,7 +35,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } # type: Dict[str, int] +} # type: Dict[str, int] def report(state, short_msg, too_old=None): # type: (str, str, Set[Any]) -> None @@ -45,7 +45,7 @@ def report(state, short_msg, too_old=None): ["%16s: %s" % (user.user_profile.email, user.last_visit.strftime("%Y-%m-%d %H:%M %Z") ) for user in too_old] - ) + ) print("%s: %s%s" % (state, short_msg, too_old_data)) exit(states[state]) diff --git a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror index 8e7cdfbd9f..97cea89f51 100755 --- a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror +++ b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror @@ -20,7 +20,7 @@ states = { "WARNING": 1, "CRITICAL": 2, "UNKNOWN": 3 - } # type: Dict[str, int] +} # type: Dict[str, int] def report(state, data, last_check): # type: (str, str, float) -> None diff --git a/tools/lint-all b/tools/lint-all index fea5344465..9489aaea08 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. # - 'E123', 'E126', 'E226', 'E261', 'E302', + 'E126', 'E226', 'E261', 'E302', 'E401', 'E501', 'E702', # @@ -227,7 +227,7 @@ def build_custom_checkers(by_lang): 'exclude': set(['zerver/lib/bugdown/codehilite.py', 'tools/travis/success-http-headers.txt']), 'description': 'Fix tab-based whitespace'}, - ] # type: RuleList + ] # type: RuleList markdown_whitespace_rules = list([rule for rule in whitespace_rules if rule['pattern'] != '\s+$']) + [ # Two spaces trailing a line with other content is okay--it's a markdown line break. # This rule finds one space trailing a non-space, three or more trailing spaces, and @@ -284,7 +284,7 @@ def build_custom_checkers(by_lang): 'exclude': set(['tools/lint-all']), 'description': 'Argument to report_error should be a literal string enclosed ' 'by i18n.t()'}, - ]) + whitespace_rules + ]) + whitespace_rules python_rules = cast(RuleList, [ {'pattern': '^(?!#)@login_required', 'description': '@login_required is unsupported; use @zulip_login_required'}, @@ -401,12 +401,12 @@ def build_custom_checkers(by_lang): 'scripts/lib/setup_venv.py', 'tools/lint-all']), 'description': 'Explicit python invocations should not include a version'} - ]) + whitespace_rules + ]) + whitespace_rules bash_rules = [ {'pattern': '#!.*sh [-xe]', 'description': 'Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches' ' to set -x|set -e'}, - ] + whitespace_rules[0:1] # type: RuleList + ] + whitespace_rules[0:1] # type: RuleList css_rules = cast(RuleList, [ {'pattern': '^[^:]*:\S[^:]*;$', 'description': "Missing whitespace after : in CSS"}, @@ -420,7 +420,7 @@ def build_custom_checkers(by_lang): 'strip': '\n'}, {'pattern': '{\w', 'description': "Missing whitespace after '{' in CSS (should be newline)."}, - ]) + whitespace_rules # type: RuleList + ]) + whitespace_rules # type: RuleList prose_style_rules = [ {'pattern': '[^\/\#\-\"]([jJ]avascript)', # exclude usage in hrefs/divs 'description': "javascript should be spelled JavaScript"}, @@ -446,7 +446,7 @@ def build_custom_checkers(by_lang): ':heart:') ]), 'description': "`title` value should be translatable."}, - ] # type: RuleList + ] # type: RuleList handlebars_rules = html_rules + [ {'pattern': "[<]script", 'description': "Do not use inline