From 69730a78cc3ac655e97761fe1da7348edbc8bfa1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 9 Apr 2020 20:23:40 -0700 Subject: [PATCH] python: Use trailing commas consistently. Automatically generated by the following script, based on the output of lint with flake8-comma: import re import sys last_filename = None last_row = None lines = [] for msg in sys.stdin: m = re.match( r"\x1b\[35mflake8 \|\x1b\[0m \x1b\[1;31m(.+):(\d+):(\d+): (\w+)", msg ) if m: filename, row_str, col_str, err = m.groups() row, col = int(row_str), int(col_str) if filename == last_filename: assert last_row != row else: if last_filename is not None: with open(last_filename, "w") as f: f.writelines(lines) with open(filename) as f: lines = f.readlines() last_filename = filename last_row = row line = lines[row - 1] if err in ["C812", "C815"]: lines[row - 1] = line[: col - 1] + "," + line[col - 1 :] elif err in ["C819"]: assert line[col - 2] == "," lines[row - 1] = line[: col - 2] + line[col - 1 :].lstrip(" ") if last_filename is not None: with open(last_filename, "w") as f: f.writelines(lines) Signed-off-by: Anders Kaseorg --- analytics/lib/counts.py | 6 +- .../commands/analyze_user_activity.py | 2 +- .../commands/check_analytics_state.py | 2 +- analytics/models.py | 8 +- analytics/tests/test_views.py | 8 +- analytics/views.py | 40 ++--- corporate/tests/test_stripe.py | 26 +-- docs/conf.py | 2 +- .../migrations/0002_html_escape_subject.py | 2 +- pgroonga/migrations/0003_v2_api_upgrade.py | 2 +- .../check_send_receive_time | 2 +- .../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 | 6 +- .../zulip_zephyr_mirror/check_zephyr_mirror | 2 +- scripts/lib/check_rabbitmq_queue.py | 2 +- scripts/lib/create-production-venv | 2 +- scripts/lib/create-thumbor-venv | 2 +- scripts/lib/email-mirror-postfix | 4 +- scripts/lib/node_cache.py | 4 +- scripts/lib/setup_venv.py | 6 +- scripts/lib/zulip_tools.py | 4 +- scripts/nagios/check-rabbitmq-consumers | 2 +- scripts/setup/flush-memcached | 2 +- scripts/setup/generate_secrets.py | 2 +- scripts/setup/restore-backup | 8 +- .../spiders/check_documentation.py | 2 +- tools/generate-integration-docs-screenshot | 2 +- tools/lib/gitlint-rules.py | 4 +- tools/lib/pretty_print.py | 4 +- tools/lib/provision.py | 12 +- tools/lib/provision_inner.py | 8 +- tools/lib/template_parser.py | 8 +- tools/lib/test_server.py | 2 +- tools/linter_lib/custom_check.py | 14 +- tools/run-dev.py | 8 +- tools/setup/emoji/export_emoji_names_to_csv | 2 +- tools/setup/emoji/generate_emoji_names_table | 4 +- tools/setup/emoji/import_emoji_names_from_csv | 2 +- tools/test-api | 8 +- tools/test-js-with-node | 2 +- tools/webpack | 4 +- tools/zulip-export/zulip-export | 2 +- zerver/context_processors.py | 2 +- zerver/data_import/hipchat.py | 4 +- zerver/data_import/hipchat_attachment.py | 4 +- zerver/data_import/import_util.py | 4 +- zerver/data_import/mattermost.py | 2 +- zerver/data_import/slack.py | 8 +- zerver/decorator.py | 10 +- zerver/forms.py | 2 +- zerver/lib/actions.py | 142 ++++++++--------- zerver/lib/bot_lib.py | 2 +- zerver/lib/bugdown/__init__.py | 24 +-- .../bugdown/api_arguments_table_generator.py | 2 +- .../api_return_values_table_generator.py | 2 +- zerver/lib/bugdown/fenced_code.py | 4 +- zerver/lib/bugdown/include.py | 4 +- zerver/lib/bugdown/nested_code_blocks.py | 6 +- zerver/lib/bulk_create.py | 2 +- zerver/lib/cache.py | 8 +- zerver/lib/dev_ldap_directory.py | 24 +-- zerver/lib/digest.py | 4 +- zerver/lib/display_recipient.py | 14 +- zerver/lib/email_mirror.py | 12 +- zerver/lib/email_notifications.py | 4 +- zerver/lib/emoji.py | 2 +- zerver/lib/error_notify.py | 4 +- zerver/lib/events.py | 14 +- zerver/lib/export.py | 20 +-- zerver/lib/fix_unreads.py | 12 +- zerver/lib/i18n.py | 2 +- zerver/lib/import_realm.py | 4 +- zerver/lib/integrations.py | 34 ++-- zerver/lib/message.py | 24 +-- zerver/lib/onboarding.py | 4 +- zerver/lib/outgoing_webhook.py | 4 +- zerver/lib/presence.py | 8 +- zerver/lib/rate_limiter.py | 4 +- zerver/lib/redis_utils.py | 2 +- zerver/lib/retention.py | 14 +- zerver/lib/send_email.py | 2 +- zerver/lib/soft_deactivation.py | 6 +- zerver/lib/stream_subscription.py | 2 +- zerver/lib/streams.py | 8 +- zerver/lib/test_classes.py | 26 +-- zerver/lib/test_fixtures.py | 4 +- zerver/lib/test_helpers.py | 4 +- zerver/lib/test_runner.py | 2 +- zerver/lib/thumbnail.py | 4 +- zerver/lib/topic.py | 2 +- zerver/lib/topic_mutes.py | 12 +- zerver/lib/transfer.py | 2 +- zerver/lib/upload.py | 22 +-- zerver/lib/user_status.py | 2 +- zerver/lib/users.py | 10 +- zerver/lib/webhooks/common.py | 4 +- zerver/lib/webhooks/git.py | 24 +-- zerver/lib/widget.py | 2 +- zerver/lib/zcommand.py | 2 +- zerver/management/commands/backup.py | 18 +-- .../commands/create_default_stream_groups.py | 4 +- zerver/management/commands/deactivate_user.py | 4 +- zerver/management/commands/export.py | 2 +- zerver/management/commands/fix_unreads.py | 2 +- zerver/management/commands/knight.py | 2 +- zerver/management/commands/makemessages.py | 2 +- zerver/middleware.py | 4 +- zerver/migrations/0029_realm_subdomain.py | 2 +- .../0032_verify_all_medium_avatar_images.py | 2 +- .../0033_migrate_domain_to_realmalias.py | 2 +- ...041_create_attachments_for_old_messages.py | 2 +- .../0074_fix_duplicate_attachments.py | 2 +- .../0082_index_starred_user_messages.py | 2 +- .../0083_index_mentioned_user_messages.py | 2 +- .../0095_index_unread_user_messages.py | 2 +- ...0098_index_has_alert_word_user_messages.py | 2 +- ..._index_wildcard_mentioned_user_messages.py | 2 +- zerver/migrations/0102_convert_muted_topic.py | 2 +- .../0109_mark_tutorial_status_finished.py | 2 +- .../0110_stream_is_in_zephyr_realm.py | 4 +- zerver/migrations/0112_index_muted_topics.py | 2 +- ...r_message_add_and_index_is_private_flag.py | 2 +- ...age_add_active_mobile_push_notification.py | 2 +- .../0198_preregistrationuser_invited_as.py | 2 +- .../0209_user_profile_no_empty_password.py | 4 +- ...gle_realm_digest_emails_enabled_default.py | 2 +- zerver/migrations/0223_rename_to_is_muted.py | 2 +- ...4_alter_field_realm_video_chat_provider.py | 10 +- ...27_inline_url_embed_preview_default_off.py | 2 +- ...36_remove_illegal_characters_email_full.py | 2 +- ...237_rename_zulip_realm_to_zulipinternal.py | 2 +- .../0239_usermessage_copy_id_to_bigint_id.py | 6 +- ...0_usermessage_migrate_bigint_id_into_id.py | 2 +- ...0244_message_copy_pub_date_to_date_sent.py | 4 +- .../0245_message_date_sent_finalize_part1.py | 2 +- zerver/migrations/0277_migrate_alert_word.py | 2 +- zerver/models.py | 74 ++++----- zerver/openapi/curl_param_value_generators.py | 12 +- zerver/openapi/markdown_extension.py | 12 +- zerver/openapi/openapi.py | 12 +- zerver/openapi/python_examples.py | 90 +++++------ zerver/templatetags/app_filters.py | 4 +- zerver/tests/test_alert_words.py | 2 +- zerver/tests/test_archive.py | 24 +-- zerver/tests/test_auth_backends.py | 114 ++++++------- zerver/tests/test_bots.py | 30 ++-- zerver/tests/test_bugdown.py | 80 +++++----- zerver/tests/test_cache.py | 6 +- zerver/tests/test_create_video_call.py | 10 +- zerver/tests/test_custom_profile_data.py | 34 ++-- zerver/tests/test_decorators.py | 20 +-- zerver/tests/test_docs.py | 2 +- zerver/tests/test_email_change.py | 4 +- zerver/tests/test_email_mirror.py | 14 +- zerver/tests/test_email_notifications.py | 28 ++-- zerver/tests/test_embedded_bot_system.py | 2 +- zerver/tests/test_events.py | 72 ++++----- zerver/tests/test_hipchat_importer.py | 2 +- zerver/tests/test_home.py | 18 +-- zerver/tests/test_import_export.py | 36 ++--- zerver/tests/test_integrations_dev_panel.py | 30 ++-- zerver/tests/test_mattermost_importer.py | 44 ++--- .../tests/test_message_edit_notifications.py | 18 +-- zerver/tests/test_messages.py | 150 +++++++++--------- zerver/tests/test_middleware.py | 6 +- zerver/tests/test_muting.py | 2 +- zerver/tests/test_narrow.py | 78 ++++----- zerver/tests/test_new_users.py | 6 +- zerver/tests/test_onboarding.py | 2 +- zerver/tests/test_openapi.py | 120 +++++++------- .../tests/test_outgoing_webhook_interfaces.py | 10 +- zerver/tests/test_outgoing_webhook_system.py | 10 +- zerver/tests/test_presence.py | 46 +++--- zerver/tests/test_push_notifications.py | 42 ++--- zerver/tests/test_queue_worker.py | 26 +-- zerver/tests/test_rate_limiter.py | 16 +- zerver/tests/test_reactions.py | 46 +++--- zerver/tests/test_realm.py | 8 +- zerver/tests/test_realm_emoji.py | 2 +- zerver/tests/test_redis_utils.py | 4 +- zerver/tests/test_report.py | 2 +- zerver/tests/test_retention.py | 98 ++++++------ zerver/tests/test_service_bot_system.py | 16 +- zerver/tests/test_sessions.py | 2 +- zerver/tests/test_settings.py | 8 +- zerver/tests/test_signup.py | 20 +-- zerver/tests/test_slack_importer.py | 14 +- zerver/tests/test_slack_message_conversion.py | 2 +- zerver/tests/test_soft_deactivation.py | 8 +- zerver/tests/test_submessage.py | 2 +- zerver/tests/test_subs.py | 102 ++++++------ zerver/tests/test_templates.py | 10 +- zerver/tests/test_thumbnail.py | 2 +- zerver/tests/test_tornado.py | 4 +- zerver/tests/test_typing.py | 12 +- zerver/tests/test_unread.py | 6 +- zerver/tests/test_upload.py | 16 +- zerver/tests/test_user_status.py | 2 +- zerver/tests/test_users.py | 16 +- zerver/tests/test_webhooks_common.py | 8 +- zerver/tornado/event_queue.py | 10 +- zerver/tornado/views.py | 2 +- zerver/views/alert_words.py | 4 +- zerver/views/archive.py | 4 +- zerver/views/auth.py | 12 +- zerver/views/camo.py | 2 +- zerver/views/events_register.py | 2 +- zerver/views/home.py | 8 +- zerver/views/messages.py | 22 +-- zerver/views/portico.py | 4 +- zerver/views/presence.py | 2 +- zerver/views/push_notifications.py | 2 +- zerver/views/realm_filters.py | 2 +- zerver/views/realm_icon.py | 4 +- zerver/views/registration.py | 8 +- zerver/views/report.py | 6 +- zerver/views/storage.py | 4 +- zerver/views/streams.py | 24 +-- zerver/views/submessage.py | 2 +- zerver/views/unsubscribe.py | 2 +- zerver/views/user_groups.py | 6 +- zerver/views/user_settings.py | 8 +- zerver/views/users.py | 10 +- zerver/views/video_calls.py | 2 +- zerver/webhooks/alertmanager/tests.py | 4 +- zerver/webhooks/ansibletower/view.py | 8 +- zerver/webhooks/appveyor/view.py | 2 +- zerver/webhooks/basecamp/view.py | 4 +- zerver/webhooks/beanstalk/view.py | 2 +- zerver/webhooks/beeminder/view.py | 2 +- zerver/webhooks/bitbucket/view.py | 2 +- zerver/webhooks/bitbucket2/tests.py | 40 ++--- zerver/webhooks/bitbucket2/view.py | 38 ++--- zerver/webhooks/bitbucket3/view.py | 36 ++--- zerver/webhooks/buildbot/view.py | 4 +- zerver/webhooks/circleci/view.py | 2 +- zerver/webhooks/clubhouse/tests.py | 4 +- zerver/webhooks/clubhouse/view.py | 42 ++--- zerver/webhooks/codeship/view.py | 2 +- zerver/webhooks/crashlytics/view.py | 4 +- zerver/webhooks/dialogflow/tests.py | 10 +- zerver/webhooks/freshdesk/view.py | 6 +- zerver/webhooks/front/view.py | 2 +- zerver/webhooks/gci/view.py | 2 +- zerver/webhooks/gitea/view.py | 2 +- zerver/webhooks/github/view.py | 70 ++++---- zerver/webhooks/gitlab/tests.py | 22 +-- zerver/webhooks/gitlab/view.py | 56 +++---- zerver/webhooks/gocd/tests.py | 4 +- zerver/webhooks/gocd/view.py | 2 +- zerver/webhooks/gogs/view.py | 32 ++-- zerver/webhooks/gosquared/tests.py | 2 +- zerver/webhooks/gosquared/view.py | 2 +- zerver/webhooks/grafana/view.py | 2 +- zerver/webhooks/greenhouse/view.py | 2 +- zerver/webhooks/groove/view.py | 6 +- zerver/webhooks/harbor/view.py | 4 +- zerver/webhooks/hellosign/view.py | 4 +- zerver/webhooks/helloworld/view.py | 2 +- zerver/webhooks/insping/view.py | 4 +- zerver/webhooks/intercom/tests.py | 46 +++--- zerver/webhooks/intercom/view.py | 28 ++-- zerver/webhooks/jira/view.py | 10 +- zerver/webhooks/librato/view.py | 4 +- zerver/webhooks/netlify/view.py | 2 +- zerver/webhooks/newrelic/view.py | 2 +- zerver/webhooks/opbeat/tests.py | 2 +- zerver/webhooks/opbeat/view.py | 14 +- zerver/webhooks/opsgenie/view.py | 18 +-- zerver/webhooks/papertrail/view.py | 4 +- zerver/webhooks/pingdom/view.py | 2 +- zerver/webhooks/reviewboard/view.py | 2 +- zerver/webhooks/semaphore/view.py | 6 +- zerver/webhooks/sentry/view.py | 14 +- zerver/webhooks/slack_incoming/tests.py | 10 +- zerver/webhooks/solano/view.py | 2 +- zerver/webhooks/splunk/view.py | 2 +- zerver/webhooks/stripe/tests.py | 4 +- zerver/webhooks/stripe/view.py | 4 +- zerver/webhooks/taiga/view.py | 18 +-- zerver/webhooks/teamcity/tests.py | 2 +- zerver/webhooks/teamcity/view.py | 2 +- zerver/webhooks/thinkst/tests.py | 12 +- zerver/webhooks/travis/tests.py | 6 +- zerver/webhooks/travis/view.py | 2 +- zerver/webhooks/trello/view/board_actions.py | 6 +- zerver/webhooks/trello/view/card_actions.py | 12 +- zerver/webhooks/updown/view.py | 4 +- zerver/webhooks/yo/tests.py | 2 +- zerver/webhooks/zabbix/tests.py | 2 +- zerver/webhooks/zabbix/view.py | 2 +- zerver/webhooks/zapier/view.py | 2 +- zerver/worker/queue_processors.py | 12 +- .../commands/add_mock_conversation.py | 2 +- zilencer/management/commands/populate_db.py | 8 +- .../management/commands/profile_request.py | 2 +- .../management/commands/render_messages.py | 2 +- zilencer/views.py | 4 +- zproject/backends.py | 10 +- zproject/computed_settings.py | 24 +-- zproject/dev_settings.py | 2 +- zproject/email_backends.py | 2 +- zproject/jinja2/__init__.py | 2 +- zproject/prod_settings_template.py | 4 +- zproject/test_extra_settings.py | 12 +- zproject/urls.py | 2 +- zthumbor/loaders/zloader.py | 2 +- 310 files changed, 1789 insertions(+), 1789 deletions(-) diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index ce8ab4ce14..f83346a8e1 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -325,9 +325,9 @@ def sql_data_collector( def do_pull_minutes_active(property: str, start_time: datetime, end_time: datetime, realm: Optional[Realm] = None) -> int: user_activity_intervals = UserActivityInterval.objects.filter( - end__gt=start_time, start__lt=end_time + end__gt=start_time, start__lt=end_time, ).select_related( - 'user_profile' + 'user_profile', ).values_list( 'user_profile_id', 'user_profile__realm_id', 'start', 'end') @@ -660,7 +660,7 @@ def get_count_stats(realm: Optional[Realm]=None) -> Dict[str, CountStat]: sql_data_collector( RealmCount, count_realm_active_humans_query(realm), None), CountStat.DAY, - dependencies=['active_users_audit:is_bot:day', '15day_actives::day']) + dependencies=['active_users_audit:is_bot:day', '15day_actives::day']), ] return OrderedDict([(stat.property, stat) for stat in count_stats_]) diff --git a/analytics/management/commands/analyze_user_activity.py b/analytics/management/commands/analyze_user_activity.py index 19322082e2..07d52136d2 100644 --- a/analytics/management/commands/analyze_user_activity.py +++ b/analytics/management/commands/analyze_user_activity.py @@ -24,7 +24,7 @@ def analyze_activity(options: Dict[str, Any]) -> None: continue total_duration += duration - print("%-*s%s" % (37, user_profile.email, duration,)) + print("%-*s%s" % (37, user_profile.email, duration)) print(f"\nTotal Duration: {total_duration}") print(f"\nTotal Duration in minutes: {total_duration.total_seconds() / 60.}") diff --git a/analytics/management/commands/check_analytics_state.py b/analytics/management/commands/check_analytics_state.py index 464659b68f..c1a14f0341 100644 --- a/analytics/management/commands/check_analytics_state.py +++ b/analytics/management/commands/check_analytics_state.py @@ -16,7 +16,7 @@ states = { 0: "OK", 1: "WARNING", 2: "CRITICAL", - 3: "UNKNOWN" + 3: "UNKNOWN", } class Command(BaseCommand): diff --git a/analytics/models.py b/analytics/models.py index 491e144ac0..b81ea5cff1 100644 --- a/analytics/models.py +++ b/analytics/models.py @@ -57,7 +57,7 @@ class InstallationCount(BaseCount): UniqueConstraint( fields=["property", "end_time"], condition=Q(subgroup__isnull=True), - name='unique_installation_count_null_subgroup') + name='unique_installation_count_null_subgroup'), ] def __str__(self) -> str: @@ -76,7 +76,7 @@ class RealmCount(BaseCount): UniqueConstraint( fields=["realm", "property", "end_time"], condition=Q(subgroup__isnull=True), - name='unique_realm_count_null_subgroup') + name='unique_realm_count_null_subgroup'), ] index_together = ["property", "end_time"] @@ -97,7 +97,7 @@ class UserCount(BaseCount): UniqueConstraint( fields=["user", "property", "end_time"], condition=Q(subgroup__isnull=True), - name='unique_user_count_null_subgroup') + name='unique_user_count_null_subgroup'), ] # This index dramatically improves the performance of # aggregating from users to realms @@ -120,7 +120,7 @@ class StreamCount(BaseCount): UniqueConstraint( fields=["stream", "property", "end_time"], condition=Q(subgroup__isnull=True), - name='unique_stream_count_null_subgroup') + name='unique_stream_count_null_subgroup'), ] # This index dramatically improves the performance of # aggregating from streams to realms diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.py index 6e4de62be8..1b8d1465aa 100644 --- a/analytics/tests/test_views.py +++ b/analytics/tests/test_views.py @@ -403,7 +403,7 @@ class TestSupportEndpoint(ZulipTestCase): self.assert_in_success_response(['user\n', '

King Hamlet

', 'Email: hamlet@zulip.com', 'Is active: True
', 'Admins: desdemona@zulip.com, iago@zulip.com\n', - 'class="copy-button" data-copytext="desdemona@zulip.com, iago@zulip.com"' + 'class="copy-button" data-copytext="desdemona@zulip.com, iago@zulip.com"', ], result) def check_zulip_realm_query_result(result: HttpResponse) -> None: @@ -448,19 +448,19 @@ class TestSupportEndpoint(ZulipTestCase): self.assert_in_success_response(['preregistration user\n', 'realm creation\n', 'Link: http://zulip.testserver/accounts/do_confirm/', - 'Expires in: 1\xa0day
\n' + 'Expires in: 1\xa0day
\n', ], result) def check_multiuse_invite_link_query_result(result: HttpResponse) -> None: self.assert_in_success_response(['multiuse invite\n', 'Link: http://zulip.testserver/join/', - 'Expires in: 1\xa0week, 3' + 'Expires in: 1\xa0week, 3', ], result) def check_realm_reactivation_link_query_result(result: HttpResponse) -> None: self.assert_in_success_response(['realm reactivation\n', 'Link: http://zulip.testserver/reactivate/', - 'Expires in: 1\xa0day' + 'Expires in: 1\xa0day', ], result) self.login('cordelia') diff --git a/analytics/views.py b/analytics/views.py index d818a1d229..702bb34dc6 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -401,7 +401,7 @@ def make_table(title: str, cols: List[str], rows: List[Any], has_row_class: bool content = loader.render_to_string( 'analytics/ad_hoc_query.html', - dict(data=data) + dict(data=data), ) return content @@ -590,7 +590,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str: realm_admins: Dict[str, List[str]] = defaultdict(list) for up in UserProfile.objects.select_related("realm").filter( role=UserProfile.ROLE_REALM_ADMINISTRATOR, - is_active=True + is_active=True, ): realm_admins[up.realm.string_id].append(up.delivery_email) @@ -674,7 +674,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str: content = loader.render_to_string( 'analytics/realm_summary_table.html', dict(rows=rows, num_active_sites=num_active_sites, - now=now.strftime('%Y-%m-%dT%H:%M:%SZ')) + now=now.strftime('%Y-%m-%dT%H:%M:%SZ')), ) return content @@ -688,18 +688,18 @@ def user_activity_intervals() -> Tuple[mark_safe, Dict[str, float]]: all_intervals = UserActivityInterval.objects.filter( end__gte=day_start, - start__lte=day_end + start__lte=day_end, ).select_related( 'user_profile', - 'user_profile__realm' + 'user_profile__realm', ).only( 'start', 'end', 'user_profile__delivery_email', - 'user_profile__realm__string_id' + 'user_profile__realm__string_id', ).order_by( 'user_profile__realm__string_id', - 'user_profile__delivery_email' + 'user_profile__delivery_email', ) by_string_id = lambda row: row.user_profile.realm.string_id @@ -735,7 +735,7 @@ def sent_messages_report(realm: str) -> str: cols = [ 'Date', 'Humans', - 'Bots' + 'Bots', ] query = SQL(''' @@ -833,7 +833,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]: return dict( content=content, - title=title + title=title, ) pages = [] @@ -868,7 +868,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]: 'User id', 'Name', 'Hits', - 'Last time' + 'Last time', ] pages.append(get_page(query, cols, title)) @@ -898,7 +898,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]: 'Realm', 'Client', 'Hits', - 'Last time' + 'Last time', ] pages.append(get_page(query, cols, title)) @@ -936,7 +936,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]: 'Realm', 'Client', 'Hits', - 'Last time' + 'Last time', ] pages.append(get_page(query, cols, title)) @@ -974,7 +974,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]: 'Client', 'Realm', 'Hits', - 'Last time' + 'Last time', ] pages.append(get_page(query, cols, title)) @@ -1184,7 +1184,7 @@ def get_user_activity_records_for_realm(realm: str, is_bot: bool) -> QuerySet: records = UserActivity.objects.filter( user_profile__realm__string_id=realm, user_profile__is_active=True, - user_profile__is_bot=is_bot + user_profile__is_bot=is_bot, ) records = records.order_by("user_profile__delivery_email", "-last_visit") records = records.select_related('user_profile', 'client').only(*fields) @@ -1196,11 +1196,11 @@ def get_user_activity_records_for_email(email: str) -> List[QuerySet]: 'query', 'client__name', 'count', - 'last_visit' + 'last_visit', ] records = UserActivity.objects.filter( - user_profile__delivery_email=email + user_profile__delivery_email=email, ) records = records.order_by("-last_visit") records = records.select_related('user_profile', 'client').only(*fields) @@ -1211,7 +1211,7 @@ def raw_user_activity_table(records: List[QuerySet]) -> str: 'query', 'client', 'count', - 'last_visit' + 'last_visit', ] def row(record: QuerySet) -> List[Any]: @@ -1219,7 +1219,7 @@ def raw_user_activity_table(records: List[QuerySet]) -> str: record.query, record.client.name, record.count, - format_date_for_activity_reports(record.last_visit) + format_date_for_activity_reports(record.last_visit), ] rows = list(map(row, records)) @@ -1238,13 +1238,13 @@ def get_user_activity_summary(records: List[QuerySet]) -> Dict[str, Dict[str, An if action not in summary: summary[action] = dict( count=record.count, - last_visit=record.last_visit + last_visit=record.last_visit, ) else: summary[action]['count'] += record.count summary[action]['last_visit'] = max( summary[action]['last_visit'], - record.last_visit + record.last_visit, ) if records: diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 7643ee67f2..1be9d5be65 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -245,14 +245,14 @@ class StripeTestCase(ZulipTestCase): # sanity check our 8 expected users are active self.assertEqual( UserProfile.objects.filter(realm=realm, is_active=True).count(), - 8 + 8, ) # Make sure we have active users outside our realm (to make # sure relevant queries restrict on realm). self.assertEqual( UserProfile.objects.exclude(realm=realm).filter(is_active=True).count(), - 10 + 10, ) # Our seat count excludes our guest user and bot, and @@ -633,14 +633,14 @@ class StripeTest(StripeTestCase): update_license_ledger_if_needed(realm, self.now) self.assertEqual( LicenseLedger.objects.order_by('-id').values_list('licenses', 'licenses_at_next_renewal').first(), - (12, 12) + (12, 12), ) with patch('corporate.lib.stripe.get_latest_seat_count', return_value=15): update_license_ledger_if_needed(realm, self.next_month) self.assertEqual( LicenseLedger.objects.order_by('-id').values_list('licenses', 'licenses_at_next_renewal').first(), - (15, 15) + (15, 15), ) invoice_plans_as_needed(self.next_month) @@ -662,7 +662,7 @@ class StripeTest(StripeTestCase): "amount_due": 15 * 80 * 100, "amount_paid": 0, "amount_remaining": 15 * 80 * 100, "auto_advance": True, "billing": "charge_automatically", "collection_method": "charge_automatically", "customer_email": self.example_email("hamlet"), "discount": None, "paid": False, "status": "open", - "total": 15 * 80 * 100 + "total": 15 * 80 * 100, } for key, value in invoice_params.items(): self.assertEqual(invoices[0].get(key), value) @@ -673,7 +673,7 @@ class StripeTest(StripeTestCase): "plan": None, "quantity": 15, "subscription": None, "discountable": False, "period": { "start": datetime_to_timestamp(free_trial_end_date), - "end": datetime_to_timestamp(add_months(free_trial_end_date, 12)) + "end": datetime_to_timestamp(add_months(free_trial_end_date, 12)), }, } for key, value in invoice_item_params.items(): @@ -687,14 +687,14 @@ class StripeTest(StripeTestCase): update_license_ledger_if_needed(realm, add_months(free_trial_end_date, 10)) self.assertEqual( LicenseLedger.objects.order_by('-id').values_list('licenses', 'licenses_at_next_renewal').first(), - (19, 19) + (19, 19), ) invoice_plans_as_needed(add_months(free_trial_end_date, 10)) invoices = [invoice for invoice in stripe.Invoice.list(customer=stripe_customer.id)] self.assertEqual(len(invoices), 2) invoice_params = { "amount_due": 5172, "auto_advance": True, "billing": "charge_automatically", - "collection_method": "charge_automatically", "customer_email": "hamlet@zulip.com" + "collection_method": "charge_automatically", "customer_email": "hamlet@zulip.com", } invoice_items = [invoice_item for invoice_item in invoices[0].get("lines")] self.assertEqual(len(invoice_items), 1) @@ -703,8 +703,8 @@ class StripeTest(StripeTestCase): "discountable": False, "quantity": 4, "period": { "start": datetime_to_timestamp(add_months(free_trial_end_date, 10)), - "end": datetime_to_timestamp(add_months(free_trial_end_date, 12)) - } + "end": datetime_to_timestamp(add_months(free_trial_end_date, 12)), + }, } invoice_plans_as_needed(add_months(free_trial_end_date, 12)) @@ -774,7 +774,7 @@ class StripeTest(StripeTestCase): 'Zulip Standard', 'Free Trial', str(self.seat_count), 'You are using', f'{self.seat_count} of {123} licenses', 'Your plan will be upgraded to', 'March 2, 2012', - f'{80 * 123:,.2f}', 'Billed by invoice' + f'{80 * 123:,.2f}', 'Billed by invoice', ]: self.assert_in_response(substring, response) @@ -798,7 +798,7 @@ class StripeTest(StripeTestCase): "amount_due": 123 * 80 * 100, "amount_paid": 0, "amount_remaining": 123 * 80 * 100, "auto_advance": True, "billing": "send_invoice", "collection_method": "send_invoice", "customer_email": self.example_email("hamlet"), "discount": None, "paid": False, "status": "open", - "total": 123 * 80 * 100 + "total": 123 * 80 * 100, } for key, value in invoice_params.items(): self.assertEqual(invoices[0].get(key), value) @@ -809,7 +809,7 @@ class StripeTest(StripeTestCase): "plan": None, "quantity": 123, "subscription": None, "discountable": False, "period": { "start": datetime_to_timestamp(free_trial_end_date), - "end": datetime_to_timestamp(add_months(free_trial_end_date, 12)) + "end": datetime_to_timestamp(add_months(free_trial_end_date, 12)), }, } for key, value in invoice_item_params.items(): diff --git a/docs/conf.py b/docs/conf.py index 3f9c521fb8..f11bad4cc1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -266,7 +266,7 @@ latex_documents = [ # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'zulip-contributor-docs', 'Zulip Documentation', - [author], 1) + [author], 1), ] # If true, show URL addresses after external links. diff --git a/pgroonga/migrations/0002_html_escape_subject.py b/pgroonga/migrations/0002_html_escape_subject.py index 776d4c99f2..3adfbe873d 100644 --- a/pgroonga/migrations/0002_html_escape_subject.py +++ b/pgroonga/migrations/0002_html_escape_subject.py @@ -24,5 +24,5 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(rebuild_pgroonga_index, - reverse_code=migrations.RunPython.noop) + reverse_code=migrations.RunPython.noop), ] diff --git a/pgroonga/migrations/0003_v2_api_upgrade.py b/pgroonga/migrations/0003_v2_api_upgrade.py index 1c3aa2b66d..49ae5d3cc4 100644 --- a/pgroonga/migrations/0003_v2_api_upgrade.py +++ b/pgroonga/migrations/0003_v2_api_upgrade.py @@ -32,5 +32,5 @@ DROP INDEX zerver_message_search_pgroonga; CREATE INDEX CONCURRENTLY zerver_message_search_pgroonga ON zerver_message USING pgroonga(search_pgroonga pgroonga.text_full_text_search_ops); - """]) + """]), ] 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 ba220bded7..739a78c7a4 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 @@ -82,7 +82,7 @@ states = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, timestamp: Any = None, msg: Optional[str] = None) -> None: 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 68ba489f53..32dd089e05 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 = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, msg: str) -> "NoReturn": 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 1f11d9f60d..9b19f5cbc6 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 @@ -18,7 +18,7 @@ states = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, num: 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 33305aae70..1bd65b0412 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 @@ -9,7 +9,7 @@ states = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, msg: 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 af8fd0ab86..7e66611cbf 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 @@ -18,7 +18,7 @@ states: Dict[str, int] = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, output: 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 c6b525f62a..13b1fdff8a 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 @@ -32,7 +32,7 @@ states: Dict[str, int] = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, short_msg: str, too_old: Optional[Set[Any]] = None) -> None: @@ -40,8 +40,8 @@ def report(state: str, short_msg: str, too_old: Optional[Set[Any]] = None) -> No if too_old: too_old_data = "\nLast call to get_message for recently out of date mirrors:\n" + "\n".join( ["{:>16}: {}".format(user.user_profile.email, - user.last_visit.strftime("%Y-%m-%d %H:%M %Z") - ) for user in too_old] + user.last_visit.strftime("%Y-%m-%d %H:%M %Z"), + ) for user in too_old], ) print(f"{state}: {short_msg}{too_old_data}") 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 3e9c86184c..ed7d8a9ed5 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 @@ -19,7 +19,7 @@ states: Dict[str, int] = { "OK": 0, "WARNING": 1, "CRITICAL": 2, - "UNKNOWN": 3 + "UNKNOWN": 3, } def report(state: str, data: str, last_check: float) -> None: diff --git a/scripts/lib/check_rabbitmq_queue.py b/scripts/lib/check_rabbitmq_queue.py index 2bae26d2b5..cb4095539d 100644 --- a/scripts/lib/check_rabbitmq_queue.py +++ b/scripts/lib/check_rabbitmq_queue.py @@ -36,7 +36,7 @@ states = { 0: "OK", 1: "WARNING", 2: "CRITICAL", - 3: "UNKNOWN" + 3: "UNKNOWN", } MAX_SECONDS_TO_CLEAR_FOR_BURSTS: DefaultDict[str, int] = defaultdict( diff --git a/scripts/lib/create-production-venv b/scripts/lib/create-production-venv index 37686fd450..d7b50cd76b 100755 --- a/scripts/lib/create-production-venv +++ b/scripts/lib/create-production-venv @@ -10,7 +10,7 @@ if ZULIP_PATH not in sys.path: from scripts.lib.zulip_tools import os_families, overwrite_symlink, run, parse_os_release from scripts.lib.setup_venv import ( - setup_virtualenv, get_venv_dependencies + setup_virtualenv, get_venv_dependencies, ) parser = argparse.ArgumentParser(description="Create a production virtualenv with caching") diff --git a/scripts/lib/create-thumbor-venv b/scripts/lib/create-thumbor-venv index 4dd058aa23..3ecf1bf533 100755 --- a/scripts/lib/create-thumbor-venv +++ b/scripts/lib/create-thumbor-venv @@ -10,7 +10,7 @@ if ZULIP_PATH not in sys.path: from scripts.lib.zulip_tools import os_families, run, parse_os_release from scripts.lib.setup_venv import ( - setup_virtualenv, THUMBOR_VENV_DEPENDENCIES, YUM_THUMBOR_VENV_DEPENDENCIES + setup_virtualenv, THUMBOR_VENV_DEPENDENCIES, YUM_THUMBOR_VENV_DEPENDENCIES, ) parser = argparse.ArgumentParser(description="Create a thumbor virtualenv with caching") diff --git a/scripts/lib/email-mirror-postfix b/scripts/lib/email-mirror-postfix index c8e404e118..e2cd3d58e0 100755 --- a/scripts/lib/email-mirror-postfix +++ b/scripts/lib/email-mirror-postfix @@ -94,7 +94,7 @@ def process_response_error(e: HTTPError) -> None: def send_email_mirror( - rcpt_to: str, shared_secret: str, host: str, url: str, test: bool, verify_ssl: bool + rcpt_to: str, shared_secret: str, host: str, url: str, test: bool, verify_ssl: bool, ) -> None: if not rcpt_to: print("5.1.1 Bad destination mailbox address: No missed message email address.") @@ -112,7 +112,7 @@ def send_email_mirror( request_data = { "recipient": rcpt_to, - "msg_text": msg_text + "msg_text": msg_text, } if test: exit(0) diff --git a/scripts/lib/node_cache.py b/scripts/lib/node_cache.py index cd975ced4a..42181daab2 100644 --- a/scripts/lib/node_cache.py +++ b/scripts/lib/node_cache.py @@ -23,7 +23,7 @@ def get_yarn_args(production: bool) -> List[str]: return yarn_args def generate_sha1sum_node_modules( - setup_dir: Optional[str] = None, production: bool = DEFAULT_PRODUCTION + setup_dir: Optional[str] = None, production: bool = DEFAULT_PRODUCTION, ) -> str: if setup_dir is None: setup_dir = os.path.realpath(os.getcwd()) @@ -69,7 +69,7 @@ def setup_node_modules( def do_yarn_install( target_path: str, yarn_args: List[str], - success_stamp: str + success_stamp: str, ) -> None: os.makedirs(target_path, exist_ok=True) shutil.copy('package.json', target_path) diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.py index 8b26ccd3bb..b3c696806f 100644 --- a/scripts/lib/setup_venv.py +++ b/scripts/lib/setup_venv.py @@ -98,9 +98,9 @@ YUM_THUMBOR_VENV_DEPENDENCIES = [ def get_venv_dependencies(vendor: str, os_version: str) -> List[str]: if vendor == 'ubuntu' and os_version == '20.04': - return VENV_DEPENDENCIES + [PYTHON_DEV_DEPENDENCY.format("2"), ] + return VENV_DEPENDENCIES + [PYTHON_DEV_DEPENDENCY.format("2")] elif "debian" in os_families(): - return VENV_DEPENDENCIES + [PYTHON_DEV_DEPENDENCY.format(""), ] + return VENV_DEPENDENCIES + [PYTHON_DEV_DEPENDENCY.format("")] elif "rhel" in os_families(): return REDHAT_VENV_DEPENDENCIES elif "fedora" in os_families(): @@ -238,7 +238,7 @@ def get_logfile_name(venv_path: str) -> str: return "{}/setup-venv.log".format(venv_path) def create_log_entry( - target_log: str, parent: str, copied_packages: Set[str], new_packages: Set[str] + target_log: str, parent: str, copied_packages: Set[str], new_packages: Set[str], ) -> None: venv_path = os.path.dirname(target_log) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index f7cd132285..dce756d64c 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -84,7 +84,7 @@ def parse_cache_script_args(description: str) -> argparse.Namespace: def get_deploy_root() -> str: return os.path.realpath( - os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")) + os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")), ) def get_deployment_version(extract_path: str) -> str: @@ -271,7 +271,7 @@ def get_caches_to_be_purged(caches_dir: str, caches_in_use: Set[str], threshold_ return caches_to_purge def purge_unused_caches( - caches_dir: str, caches_in_use: Set[str], cache_type: str, args: argparse.Namespace + caches_dir: str, caches_in_use: Set[str], cache_type: str, args: argparse.Namespace, ) -> None: all_caches = {os.path.join(caches_dir, cache) for cache in os.listdir(caches_dir)} caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, args.threshold_days) diff --git a/scripts/nagios/check-rabbitmq-consumers b/scripts/nagios/check-rabbitmq-consumers index 59977446e7..cf4bf7e0ca 100755 --- a/scripts/nagios/check-rabbitmq-consumers +++ b/scripts/nagios/check-rabbitmq-consumers @@ -17,7 +17,7 @@ states = { 0: "OK", 1: "WARNING", 2: "CRITICAL", - 3: "UNKNOWN" + 3: "UNKNOWN", } if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']: diff --git a/scripts/setup/flush-memcached b/scripts/setup/flush-memcached index e8e7130a05..d9c59ddd4c 100755 --- a/scripts/setup/flush-memcached +++ b/scripts/setup/flush-memcached @@ -18,5 +18,5 @@ pylibmc.Client( binary=True, username=settings.MEMCACHED_USERNAME, password=settings.MEMCACHED_PASSWORD, - behaviors=settings.CACHES["default"]["OPTIONS"] # type: ignore[index] # settings not typed properly + behaviors=settings.CACHES["default"]["OPTIONS"], # type: ignore[index] # settings not typed properly ).flush_all() diff --git a/scripts/setup/generate_secrets.py b/scripts/setup/generate_secrets.py index 8a8fa111c5..864c684ec7 100755 --- a/scripts/setup/generate_secrets.py +++ b/scripts/setup/generate_secrets.py @@ -149,7 +149,7 @@ def generate_secrets(development: bool = False) -> None: with open(filename, "a") as f: f.write( "# Set a Redis password based on zulip-secrets.conf\n" - "requirepass '%s'\n" % (redis_password,) + "requirepass '%s'\n" % (redis_password,), ) break diff --git a/scripts/setup/restore-backup b/scripts/setup/restore-backup index f8eae9e31f..00f3b3e713 100755 --- a/scripts/setup/restore-backup +++ b/scripts/setup/restore-backup @@ -70,7 +70,7 @@ def restore_backup(tarball_file: IO[bytes]) -> None: assert not any("|" in name or "|" in path for name, path in paths) transform_args = [ r"--transform=s|^zulip-backup/{}(/.*)?$|{}\1|x".format( - re.escape(name), path.replace("\\", r"\\") + re.escape(name), path.replace("\\", r"\\"), ) for name, path in paths ] @@ -89,12 +89,12 @@ def restore_backup(tarball_file: IO[bytes]) -> None: run( [ os.path.join( - settings.DEPLOY_ROOT, "scripts", "setup", "terminate-psql-sessions" + settings.DEPLOY_ROOT, "scripts", "setup", "terminate-psql-sessions", ), "zulip", "zulip", "zulip_base", - ] + ], ) as_postgres = ["su", "-s", "/usr/bin/env", "-", "--", POSTGRES_USER] run(as_postgres + ["dropdb", "--if-exists", "--", db_name]) @@ -130,7 +130,7 @@ def restore_backup(tarball_file: IO[bytes]) -> None: [ os.path.join(settings.DEPLOY_ROOT, "scripts", "zulip-puppet-apply"), "-f", - ] + ], ) # Now, restore the the database backup using pg_restore. This diff --git a/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py b/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py index 534e56cfc7..861553dad4 100755 --- a/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py +++ b/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py @@ -12,7 +12,7 @@ def get_start_url() -> List[str]: start_file = os.path.join(dir_path, os.path.join(*[os.pardir] * 4), "docs/_build/html/index.html") return [ - pathlib.Path(os.path.abspath(start_file)).as_uri() + pathlib.Path(os.path.abspath(start_file)).as_uri(), ] diff --git a/tools/generate-integration-docs-screenshot b/tools/generate-integration-docs-screenshot index 0b28d3c122..c7b419e511 100755 --- a/tools/generate-integration-docs-screenshot +++ b/tools/generate-integration-docs-screenshot @@ -236,5 +236,5 @@ else: parser.error( "Could not find configuration for integration. " "You can specify a fixture file to use, using the --fixture flag. " - "Or add a configuration to zerver.lib.integrations.DOC_SCREENSHOT_CONFIG" + "Or add a configuration to zerver.lib.integrations.DOC_SCREENSHOT_CONFIG", ) diff --git a/tools/lib/gitlint-rules.py b/tools/lib/gitlint-rules.py index b909de126a..810267dd44 100644 --- a/tools/lib/gitlint-rules.py +++ b/tools/lib/gitlint-rules.py @@ -69,7 +69,7 @@ WORD_SET = { 'testing', 'tested', # 'tests' excluded to reduce false negative 'truncates', 'truncating', 'truncated', 'updates', 'updating', 'updated', - 'uses', 'using', 'used' + 'uses', 'using', 'used', } imperative_forms = sorted([ @@ -135,7 +135,7 @@ class ImperativeMood(LineRule): violation = RuleViolation(self.id, self.error_msg.format( word=first_word, imperative=imperative, - title=commit.message.title + title=commit.message.title, )) violations.append(violation) diff --git a/tools/lib/pretty_print.py b/tools/lib/pretty_print.py index 2e03597206..6f72984f4b 100644 --- a/tools/lib/pretty_print.py +++ b/tools/lib/pretty_print.py @@ -85,7 +85,7 @@ def pretty_print_html(html: str, num_spaces: int = 4) -> str: adjustment=adjustment, indenting=True, adjust_offset_until=token.line, - ignore_lines=[] + ignore_lines=[], ) if token.kind in ('handlebars_start', 'django_start'): info.update(dict(depth=new_depth - 1, indenting=False)) @@ -98,7 +98,7 @@ def pretty_print_html(html: str, num_spaces: int = 4) -> str: tag=token.tag, token_kind=token.kind, extra_indent=stack[-1]['extra_indent'], - ignore_lines=[] + ignore_lines=[], ) stack.append(info) elif (token.kind in ('html_end', 'handlebars_end', 'html_singleton_end', diff --git a/tools/lib/provision.py b/tools/lib/provision.py index 341327eedb..7d949ba5ae 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -55,7 +55,7 @@ try: os.remove(os.path.join(VAR_DIR_PATH, 'zulip-test-symlink')) os.symlink( os.path.join(ZULIP_PATH, 'README.md'), - os.path.join(VAR_DIR_PATH, 'zulip-test-symlink') + os.path.join(VAR_DIR_PATH, 'zulip-test-symlink'), ) os.remove(os.path.join(VAR_DIR_PATH, 'zulip-test-symlink')) except OSError: @@ -130,7 +130,7 @@ COMMON_DEPENDENCIES = [ "libxss1", "fonts-freefont-ttf", "libappindicator1", - "xdg-utils" + "xdg-utils", # Puppeteer dependencies end here. ] @@ -152,7 +152,7 @@ COMMON_YUM_DEPENDENCIES = COMMON_DEPENDENCIES + [ "freetype", "freetype-devel", "fontconfig-devel", - "libstdc++" + "libstdc++", ] + YUM_THUMBOR_VENV_DEPENDENCIES BUILD_PGROONGA_FROM_SOURCE = False @@ -168,7 +168,7 @@ if vendor == 'debian' and os_version in [] or vendor == 'ubuntu' and os_version "libgroonga-dev", "libmsgpack-dev", "clang-9", - "llvm-9-dev" + "llvm-9-dev", ] ] + VENV_DEPENDENCIES elif "debian" in os_families(): @@ -244,7 +244,7 @@ def install_apt_deps(deps_to_install: List[str]) -> None: "env", "DEBIAN_FRONTEND=noninteractive", "apt-get", "-y", "install", "--no-install-recommends", ] - + deps_to_install + + deps_to_install, ) def install_yum_deps(deps_to_install: List[str]) -> None: @@ -411,7 +411,7 @@ def main(options: argparse.Namespace) -> "NoReturn": provision_inner, *(["--force"] if options.is_force else []), *(["--build-release-tarball-only"] if options.is_build_release_tarball_only else []), - ] + ], ) if __name__ == "__main__": diff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.py index cd71b86c19..3f09e9ed8e 100755 --- a/tools/lib/provision_inner.py +++ b/tools/lib/provision_inner.py @@ -128,7 +128,7 @@ def need_to_run_build_pygments_data() -> bool: return is_digest_obsolete( "build_pygments_data_hash", build_pygments_data_paths(), - [pygments_version] + [pygments_version], ) def need_to_run_compilemessages() -> bool: @@ -155,7 +155,7 @@ def need_to_run_configure_rabbitmq(settings_list: List[str]) -> bool: obsolete = is_digest_obsolete( 'last_configure_rabbitmq_hash', configure_rabbitmq_paths(), - settings_list + settings_list, ) if obsolete: @@ -204,7 +204,7 @@ def main(options: argparse.Namespace) -> int: write_new_digest( 'build_pygments_data_hash', build_pygments_data_paths(), - [pygments_version] + [pygments_version], ) else: print("No need to run `tools/setup/build_pygments_data`.") @@ -240,7 +240,7 @@ def main(options: argparse.Namespace) -> int: write_new_digest( 'last_configure_rabbitmq_hash', configure_rabbitmq_paths(), - [settings.RABBITMQ_PASSWORD] + [settings.RABBITMQ_PASSWORD], ) else: print("No need to run `scripts/setup/configure-rabbitmq.") diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index 311297a7ea..124f500dfd 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -160,8 +160,8 @@ def tokenize(text: str) -> List[Token]: e.message, state.line, state.col, - e.line_content - ) + e.line_content, + ), ) line_span = len(s.split('\n')) @@ -171,7 +171,7 @@ def tokenize(text: str) -> List[Token]: tag=tag.strip(), line=state.line, col=state.col, - line_span=line_span + line_span=line_span, ) tokens.append(token) advance(len(s)) @@ -183,7 +183,7 @@ def tokenize(text: str) -> List[Token]: tag=tag, line=state.line, col=state.col, - line_span=1 + line_span=1, ) tokens.append(token) diff --git a/tools/lib/test_server.py b/tools/lib/test_server.py index be325233a8..5a1a66429e 100644 --- a/tools/lib/test_server.py +++ b/tools/lib/test_server.py @@ -51,7 +51,7 @@ def server_is_up(server: "subprocess.Popen[bytes]", log_file: Optional[str]) -> @contextmanager def test_server_running(force: bool=False, external_host: str='testserver', - log_file: Optional[str]=None, dots: bool=False, use_db: bool=True + log_file: Optional[str]=None, dots: bool=False, use_db: bool=True, ) -> Iterator[None]: log = sys.stdout if log_file: diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 649f613cd0..b33eafb79b 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -60,13 +60,13 @@ shebang_rules: List["Rule"] = [ 'description': "Use `#!/usr/bin/env foo` instead of `#!/path/foo`" " for interpreters other than sh."}, {'pattern': '^#!/usr/bin/env python$', - 'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`."} + 'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`."}, ] trailing_whitespace_rule: "Rule" = { 'pattern': r'\s+$', 'strip': '\n', - 'description': 'Fix trailing whitespace' + 'description': 'Fix trailing whitespace', } whitespace_rules: List["Rule"] = [ # This linter should be first since bash_rules depends on it. @@ -446,8 +446,8 @@ bash_rules = RuleList( 'include_only': {'scripts/'}, 'exclude': { 'scripts/lib/install', - 'scripts/setup/configure-rabbitmq' - }, }, + 'scripts/setup/configure-rabbitmq', + }}, *whitespace_rules[0:1], ], shebang_rules=shebang_rules, @@ -554,7 +554,7 @@ html_rules: List["Rule"] = whitespace_rules + prose_style_rules + [ {'pattern': r'title="[^{\:]', 'exclude_line': { ('templates/zerver/app/markdown_help.html', - ':heart:') + ':heart:'), }, 'exclude': {"templates/zerver/emails", "templates/analytics/realm_details.html", "templates/analytics/support.html"}, 'description': "`title` value should be translatable."}, @@ -691,7 +691,7 @@ json_rules = RuleList( {'pattern': r'":["\[\{]', 'exclude': {'zerver/webhooks/', 'zerver/tests/fixtures/'}, 'description': 'Require space after : in JSON'}, - ] + ], ) markdown_docs_length_exclude = { @@ -737,7 +737,7 @@ markdown_rules = RuleList( ], max_length=120, length_exclude=markdown_docs_length_exclude, - exclude_files_in='templates/zerver/help/' + exclude_files_in='templates/zerver/help/', ) help_markdown_rules = RuleList( diff --git a/tools/run-dev.py b/tools/run-dev.py index 1ee92c8475..10615e874f 100755 --- a/tools/run-dev.py +++ b/tools/run-dev.py @@ -203,7 +203,7 @@ def fetch_request(url: str, callback: Any, **kwargs: Any) -> "Generator[Callable connect_timeout=240.0, request_timeout=240.0, decompress_response=False, - **kwargs + **kwargs, ) client = httpclient.AsyncHTTPClient() # wait for response @@ -218,7 +218,7 @@ class BaseHandler(web.RequestHandler): target_port: int def _add_request_headers( - self, exclude_lower_headers_list: Optional[List[str]] = None + self, exclude_lower_headers_list: Optional[List[str]] = None, ) -> httputil.HTTPHeaders: exclude_lower_headers_list = exclude_lower_headers_list or [] headers = httputil.HTTPHeaders() @@ -284,7 +284,7 @@ class BaseHandler(web.RequestHandler): headers=self._add_request_headers(["upgrade-insecure-requests"]), follow_redirects=False, body=getattr(self.request, 'body'), - allow_nonstandard_methods=True + allow_nonstandard_methods=True, ) except httpclient.HTTPError as e: if hasattr(e, 'response') and e.response: @@ -329,7 +329,7 @@ class Application(web.Application): (r"/api/v1/events.*", TornadoHandler), (r"/webpack.*", WebPackHandler), (r"/thumbor.*", ThumborHandler if using_thumbor() else ErrorHandler), - (r"/.*", DjangoHandler) + (r"/.*", DjangoHandler), ] super().__init__(handlers, enable_logging=enable_logging) diff --git a/tools/setup/emoji/export_emoji_names_to_csv b/tools/setup/emoji/export_emoji_names_to_csv index d7d8717e9a..da1ab25932 100755 --- a/tools/setup/emoji/export_emoji_names_to_csv +++ b/tools/setup/emoji/export_emoji_names_to_csv @@ -89,7 +89,7 @@ def main() -> None: args = parser.parse_args() prepare_sorting_info() - output_data = [column_names, ] + output_data = [column_names] explanation_lines: List[str] = [] with open(args.input_file_path) as fp: for line in fp.readlines(): diff --git a/tools/setup/emoji/generate_emoji_names_table b/tools/setup/emoji/generate_emoji_names_table index 77a21ed39b..71ecd8341e 100755 --- a/tools/setup/emoji/generate_emoji_names_table +++ b/tools/setup/emoji/generate_emoji_names_table @@ -132,7 +132,7 @@ def generate_emoji_code_to_emoji_names_maps() -> None: if emoji_code in reverse_unified_reactions_map: reverse_unified_reactions_map[emoji_code].append(name) else: - reverse_unified_reactions_map[emoji_code] = [name, ] + reverse_unified_reactions_map[emoji_code] = [name] for emoji_code in reverse_unified_reactions_map: emoji_code_to_gemoji_names[emoji_code] = ", ".join(reverse_unified_reactions_map[emoji_code]) @@ -146,7 +146,7 @@ def generate_emoji_code_to_emoji_names_maps() -> None: for emoji_code in EMOJI_NAME_MAPS: canonical_name = EMOJI_NAME_MAPS[emoji_code]["canonical_name"] aliases = EMOJI_NAME_MAPS[emoji_code]["aliases"] - names = [canonical_name, ] + names = [canonical_name] names.extend(aliases) emoji_code_to_zulip_names[emoji_code] = ", ".join(names) diff --git a/tools/setup/emoji/import_emoji_names_from_csv b/tools/setup/emoji/import_emoji_names_from_csv index 5cf7d16859..f59977f359 100755 --- a/tools/setup/emoji/import_emoji_names_from_csv +++ b/tools/setup/emoji/import_emoji_names_from_csv @@ -57,7 +57,7 @@ def check_valid_emoji_name(emoji_name: str) -> None: def check_emoji_names(canonical_name: str, aliases: List[str]) -> None: if canonical_name == 'X': return - names_to_check = [canonical_name, ] + aliases + names_to_check = [canonical_name] + aliases for name in names_to_check: check_valid_emoji_name(name) check_uniqueness(name) diff --git a/tools/test-api b/tools/test-api index 07c1d5dcfb..7685dd012e 100755 --- a/tools/test-api +++ b/tools/test-api @@ -51,7 +51,7 @@ with test_server_running(force=options.force, external_host='zulipdev.com:9981') client = Client( email=email, api_key=api_key, - site=site + site=site, ) # Prepare a generic bot client for curl testing @@ -62,7 +62,7 @@ with test_server_running(force=options.force, external_host='zulipdev.com:9981') bot_client = Client( email=email, api_key=api_key, - site=site + site=site, ) # Prepare the non-admin client @@ -73,7 +73,7 @@ with test_server_running(force=options.force, external_host='zulipdev.com:9981') nonadmin_client = Client( email=email, api_key=api_key, - site=site + site=site, ) test_the_api(client, nonadmin_client) @@ -84,7 +84,7 @@ with test_server_running(force=options.force, external_host='zulipdev.com:9981') client = Client( email=email, api_key='X'*32, - site=site + site=site, ) test_invalid_api_key(client) diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 7d3f0aa3a4..0f9a16d55c 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -279,7 +279,7 @@ def enforce_proper_coverage(coverage_json: Any) -> bool: glob.glob('static/js/*.ts') + glob.glob('static/shared/js/*.js') + glob.glob('static/shared/js/*.ts') + - glob.glob('static/js/billing/*.js') + glob.glob('static/js/billing/*.js'), ) enforce_fully_covered = all_js_files - EXEMPT_FILES diff --git a/tools/webpack b/tools/webpack index dcc170f016..1187e0bb42 100755 --- a/tools/webpack +++ b/tools/webpack @@ -39,7 +39,7 @@ def build_for_dev_server(host: str, port: str, minify: bool, disable_host_check: # We add the hot flag using the cli because it takes care # of addition to entry points and adding the plugin # automatically - '--hot' + '--hot', ] if minify: webpack_args.append('--optimize-minimize') @@ -99,7 +99,7 @@ def build_for_most_tests() -> None: entries[entry] = [{ "name": f"{entry}.js", "publicPath": f"http://localhost:3000/webpack-stub/{entry}-stubentry.js", - "path": f"/stubfolder/{entry}-stubfile.js" + "path": f"/stubfolder/{entry}-stubfile.js", }] stat_data = { "status": "done", diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export index 3ac431fd34..3072588c39 100755 --- a/tools/zulip-export/zulip-export +++ b/tools/zulip-export/zulip-export @@ -84,5 +84,5 @@ for msg in result['messages']: filename = f"zulip-{options.stream}.json" with open(filename, 'wb') as f: f.write(json.dumps(messages, indent=0, sort_keys=False).encode('utf-8')) -print("%d messages exported to %s" % (len(messages), filename,)) +print("%d messages exported to %s" % (len(messages), filename)) sys.exit(0) diff --git a/zerver/context_processors.py b/zerver/context_processors.py index c4798cd3a8..a0bda24c60 100644 --- a/zerver/context_processors.py +++ b/zerver/context_processors.py @@ -188,7 +188,7 @@ def login_context(request: HttpRequest) -> Dict[str, Any]: # by the desktop client. We expand it with IDs of the