diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index e0cb1c2ab3..d41f49a952 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -168,7 +168,7 @@ def do_aggregate_to_summary_table(stat, end_time, interval): def do_pull_from_zerver(stat, start_time, end_time, interval): # type: (CountStat, datetime, datetime, str) -> None zerver_table = stat.zerver_count_query.zerver_table._meta.db_table # type: ignore - join_args = ' '.join('AND %s.%s = %s' % (zerver_table, key, value) \ + join_args = ' '.join('AND %s.%s = %s' % (zerver_table, key, value) for key, value in stat.filter_args.items()) if stat.group_by is None: subgroup = 'NULL' diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py index e40f628527..1a27f4508f 100644 --- a/analytics/tests/test_counts.py +++ b/analytics/tests/test_counts.py @@ -77,7 +77,7 @@ class AnalyticsTestCase(TestCase): self.assertEqual(table.objects.filter(realm=realm, property=property, interval=interval, - end_time=end_time) \ + end_time=end_time) .filter(**kwargs).values_list('value', flat=True)[0], value) diff --git a/api/bin/zulip-send b/api/bin/zulip-send index 16815dce2f..7144720bb1 100755 --- a/api/bin/zulip-send +++ b/api/bin/zulip-send @@ -42,7 +42,7 @@ def do_send_message(client, message_data): '''Sends a message and optionally prints status about the same.''' if message_data['type'] == 'stream': - log.info('Sending message to stream "%s", subject "%s"... ' % \ + log.info('Sending message to stream "%s", subject "%s"... ' % (message_data['to'], message_data['subject'])) else: log.info('Sending message to %s... ' % message_data['to']) diff --git a/api/integrations/asana/zulip_asana_mirror b/api/integrations/asana/zulip_asana_mirror index b832d1a781..029de0a260 100755 --- a/api/integrations/asana/zulip_asana_mirror +++ b/api/integrations/asana/zulip_asana_mirror @@ -208,9 +208,9 @@ def process_new_events(): """ # In task queries, Asana only exposes IDs for projects and users, so we need # to look up the mappings. - projects = dict((elt["id"], elt["name"]) for elt in \ + projects = dict((elt["id"], elt["name"]) for elt in fetch_from_asana("/projects")["data"]) - users = dict((elt["id"], elt["name"]) for elt in \ + users = dict((elt["id"], elt["name"]) for elt in fetch_from_asana("/users")["data"]) cutoff = since() diff --git a/api/zulip/__init__.py b/api/zulip/__init__.py index ef3c000429..c85bba1637 100644 --- a/api/zulip/__init__.py +++ b/api/zulip/__init__.py @@ -312,7 +312,7 @@ class Client(object): return False if self.verbose: if not query_state["had_error_retry"]: - sys.stdout.write("zulip API(%s): connection error%s -- retrying." % \ + sys.stdout.write("zulip API(%s): connection error%s -- retrying." % (url.split(API_VERSTRING, 2)[0], error_string,)) query_state["had_error_retry"] = True else: diff --git a/bots/check-mirroring b/bots/check-mirroring index c4ec5c01db..72b1aa19bf 100755 --- a/bots/check-mirroring +++ b/bots/check-mirroring @@ -328,11 +328,11 @@ for key in all_keys: continue if key in zhkeys: (stream, test) = zhkeys[key] - logger.warning("%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s" % \ + logger.warning("%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s" % (key, z_key_counts[key], h_key_counts[key], test, stream)) if key in hzkeys: (stream, test) = hzkeys[key] - logger.warning("%10s: z got %s. h got %s. Sent via Zulip(%s): class %s" % \ + logger.warning("%10s: z got %s. h got %s. Sent via Zulip(%s): class %s" % (key, z_key_counts[key], h_key_counts[key], test, stream)) logger.error("") logger.error("Summary of specific problems:") diff --git a/bots/jabber_mirror_backend.py b/bots/jabber_mirror_backend.py index 3a84b00a95..683783f2d9 100755 --- a/bots/jabber_mirror_backend.py +++ b/bots/jabber_mirror_backend.py @@ -317,7 +317,7 @@ user and mirrors messages sent to Jabber rooms to Zulip. Defaults to parser.add_option('--zulip-email-suffix', default=None, action='store', - help= \ + help= '''Add the specified suffix to the local part of email addresses constructed from JIDs and nicks before sending requests to the Zulip server, and remove the suffix before sending requests to the Jabber server. For example, specifying 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 69a9251f78..6972496107 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 @@ -50,9 +50,9 @@ now = datetime.datetime.utcnow() all_users = UserActivity.objects.filter(query__in=["get_events_backend", "/api/v1/events"], client__name="zephyr_mirror") -new_inactive_users = [user for user in all_users if user.last_visit.replace(tzinfo=None) < \ +new_inactive_users = [user for user in all_users if user.last_visit.replace(tzinfo=None) < now - datetime.timedelta(minutes=10)] -old_inactive_users = [user for user in new_inactive_users if user.last_visit.replace(tzinfo=None) < \ +old_inactive_users = [user for user in new_inactive_users if user.last_visit.replace(tzinfo=None) < now - datetime.timedelta(minutes=60)] recently_inactive_users = set(new_inactive_users) - set(old_inactive_users) diff --git a/tools/lint-all b/tools/lint-all index 9b4cb1a456..fddc97e955 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -85,7 +85,7 @@ def check_pep8(files): 'E402', 'E501', 'W503', 'E711', 'E128', 'E226', 'E126', 'E121', 'E123', 'E266', 'E265', 'E261', 'E221', 'E241', 'E712', 'E702', 'E401', 'E115', 'E114', 'E731', 'E302', 'E129', - 'E741', 'E714', 'W391', 'E713', 'E502', 'E305', 'E251', 'E306', + 'E741', 'E714', 'W391', 'E713', 'E305', 'E251', 'E306', ] pep8 = subprocess.Popen( ['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))], diff --git a/tools/minify-js b/tools/minify-js index 07980264cd..b678b04462 100755 --- a/tools/minify-js +++ b/tools/minify-js @@ -87,8 +87,8 @@ CLOSURE_BINARY = '/usr/bin/closure-compiler' if not os.path.exists(CLOSURE_BINARY): CLOSURE_BINARY = 'tools/closure-compiler/run' if not os.path.exists(CLOSURE_BINARY): - print("closure-compiler not installed; the Vagrant tools/provision.py installs it via apt "\ - "or you can manually unpack http://dl.google.com/closure-compiler/compiler-latest.zip to "\ + print("closure-compiler not installed; the Vagrant tools/provision.py installs it via apt " + "or you can manually unpack http://dl.google.com/closure-compiler/compiler-latest.zip to " "tools/closure-compiler") sys.exit(1) diff --git a/zerver/decorator.py b/zerver/decorator.py index 1abae57f4d..f438b31599 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -595,7 +595,7 @@ def rate_limit(domain='all'): user = None if not user: - logging.error("Requested rate-limiting on %s but user is not authenticated!" % \ + logging.error("Requested rate-limiting on %s but user is not authenticated!" % func.__name__) return func(request, *args, **kwargs) diff --git a/zerver/forms.py b/zerver/forms.py index ab30e3751c..48c391f65b 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -63,7 +63,7 @@ class RegistrationForm(forms.Form): realm_name = forms.CharField(max_length=100, required=False) realm_subdomain = forms.CharField(max_length=40, required=False) realm_org_type = forms.ChoiceField(((Realm.COMMUNITY, 'Community'), - (Realm.CORPORATE, 'Corporate')), \ + (Realm.CORPORATE, 'Corporate')), initial=Realm.COMMUNITY, required=False) if settings.TERMS_OF_SERVICE: diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 6bf7ccdda2..ac33a724dd 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -229,7 +229,7 @@ def send_signup_message(sender, signups_stream, user_profile, if user_profile.realm.notifications_stream is not None and user_count > 1: internal_send_message(sender, "stream", user_profile.realm.notifications_stream.name, - "New users", "%s just signed up for Zulip. Say hello!" % \ + "New users", "%s just signed up for Zulip. Say hello!" % (user_profile.full_name,), realm=user_profile.realm) @@ -2809,7 +2809,7 @@ def gather_subscriptions_helper(user_profile): stream_ids = set([sub["recipient__type_id"] for sub in sub_dicts]) all_streams = get_active_streams(user_profile.realm).select_related( - "realm").values("id", "name", "invite_only", "realm_id", \ + "realm").values("id", "name", "invite_only", "realm_id", "realm__domain", "email_token", "description") stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids] @@ -2824,7 +2824,7 @@ def gather_subscriptions_helper(user_profile): never_subscribed = [] # Deactivated streams aren't in stream_hash. - streams = [stream_hash[sub["recipient__type_id"]] for sub in sub_dicts \ + streams = [stream_hash[sub["recipient__type_id"]] for sub in sub_dicts if sub["recipient__type_id"] in stream_hash] streams_subscribed_map = dict((sub["recipient__type_id"], sub["active"]) for sub in sub_dicts) diff --git a/zerver/lib/cache_helpers.py b/zerver/lib/cache_helpers.py index 0661b5cc0a..f602bd72dd 100644 --- a/zerver/lib/cache_helpers.py +++ b/zerver/lib/cache_helpers.py @@ -94,6 +94,6 @@ def fill_remote_cache(cache): cache_set_many(items_for_remote_cache, timeout=3600*24) items_for_remote_cache = {} cache_set_many(items_for_remote_cache, timeout=3600*24*7) - logging.info("Succesfully populated %s cache! Consumed %s remote cache queries (%s time)" % \ + logging.info("Succesfully populated %s cache! Consumed %s remote cache queries (%s time)" % (cache, get_remote_cache_requests() - remote_cache_requests_start, round(get_remote_cache_time() - remote_cache_time_start, 2))) diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py index f7fd030708..dfcc9e1f55 100644 --- a/zerver/lib/digest.py +++ b/zerver/lib/digest.py @@ -87,7 +87,7 @@ def gather_hot_conversations(user_profile, stream_messages): count = conversation_length[h] # We'll display up to 2 messages from the conversation. - first_few_messages = [user_message.message for user_message in \ + first_few_messages = [user_message.message for user_message in stream_messages.filter( message__recipient__type_id=stream_id, message__subject=subject)[:2]] @@ -189,7 +189,7 @@ def handle_digest_email(user_profile_id, cutoff): user_profile, [pm.message for pm in pms[:pms_limit]]) template_payload['remaining_unread_pms_count'] = min(0, len(pms) - pms_limit) - home_view_recipients = [sub.recipient for sub in \ + home_view_recipients = [sub.recipient for sub in Subscription.objects.filter( user_profile=user_profile, active=True, diff --git a/zerver/management/commands/import.py b/zerver/management/commands/import.py index f72a656246..8c6d3b89e0 100644 --- a/zerver/management/commands/import.py +++ b/zerver/management/commands/import.py @@ -47,7 +47,7 @@ Usage: ./manage.py import [--destroy-rebuild-database] [--import-into-nonempty] # type: (Model) -> None count = model.objects.count() if count: - print("Zulip instance is not empty, found %d rows in %s table. " \ + print("Zulip instance is not empty, found %d rows in %s table. " % (count, model._meta.db_table)) print("You may use --destroy-rebuild-database to destroy and rebuild the database prior to import.") exit(1) diff --git a/zerver/tests/test_narrow.py b/zerver/tests/test_narrow.py index 43a3303ff0..f8fcd5ca36 100644 --- a/zerver/tests/test_narrow.py +++ b/zerver/tests/test_narrow.py @@ -710,8 +710,8 @@ class GetOldMessagesTest(ZulipTestCase): for type in bad_types: # Rotate through every bad type for every integer # parameter, one at a time. - post_params = dict(other_params + [(param, type)] + \ - [(other_param, 0) for other_param in \ + post_params = dict(other_params + [(param, type)] + + [(other_param, 0) for other_param in int_params[:idx] + int_params[idx + 1:]] ) result = self.client_get("/json/messages", post_params) diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index cdbfcd32c6..bd6e13b645 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -105,7 +105,7 @@ 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 \ + 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) diff --git a/zerver/views/users.py b/zerver/views/users.py index 429b1d4432..797247e7cb 100644 --- a/zerver/views/users.py +++ b/zerver/views/users.py @@ -229,7 +229,7 @@ def add_bot_backend(request, user_profile, full_name=REQ(), short_name=REQ(), 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 \ + default_sending_stream.is_public() and not subscribed_to_stream(user_profile, default_sending_stream)): return json_error(_('Insufficient permission')) diff --git a/zerver/views/webhooks/stash.py b/zerver/views/webhooks/stash.py index f8e9d4e06c..15876fa958 100644 --- a/zerver/views/webhooks/stash.py +++ b/zerver/views/webhooks/stash.py @@ -27,7 +27,7 @@ def api_stash_webhook(request, user_profile, payload=REQ(argument_type='body'), branch_name = payload["refChanges"][0]["refId"].split("/")[-1] commit_entries = payload["changesets"]["values"] commits = [(entry["toCommit"]["displayId"], - entry["toCommit"]["message"].split("\n")[0]) for \ + entry["toCommit"]["message"].split("\n")[0]) for entry in commit_entries] head_ref = commit_entries[-1]["toCommit"]["displayId"] except KeyError as e: