From 3b301f522bcf87d3d1381bb7b63af93890ef0b88 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 2 Sep 2020 20:49:50 -0700 Subject: [PATCH] python: Tweak some magic trailing commas to avoid Black bugs. https://github.com/psf/black/issues/1658 https://github.com/psf/black/issues/1671 Signed-off-by: Anders Kaseorg --- tools/lib/pretty_print.py | 4 ++-- zerver/lib/actions.py | 4 ++-- zerver/lib/presence.py | 2 +- zerver/lib/topic_mutes.py | 4 ++-- zerver/migrations/0110_stream_is_in_zephyr_realm.py | 2 +- zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py | 2 +- zerver/migrations/0244_message_copy_pub_date_to_date_sent.py | 2 +- zerver/tests/test_soft_deactivation.py | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/lib/pretty_print.py b/tools/lib/pretty_print.py index 006b2ac675e49..6daea1a5521d8 100644 --- a/tools/lib/pretty_print.py +++ b/tools/lib/pretty_print.py @@ -40,7 +40,7 @@ def pretty_print_html(html: str, num_spaces: int = 4) -> str: if token.kind in ('html_start', 'handlebars_start', 'handlebars_singleton', 'html_singleton', 'django_start', 'jinja2_whitespace_stripped_type2_start', - 'jinja2_whitespace_stripped_start') and stack[-1]['tag'] != 'pre': + 'jinja2_whitespace_stripped_start',) and stack[-1]['tag'] != 'pre': # An HTML start tag should only cause a new indent if we # are on a new line. if (token.tag not in ('extends', 'include', 'else', 'elif') and @@ -100,7 +100,7 @@ def pretty_print_html(html: str, num_spaces: int = 4) -> str: stack.append(info) elif (token.kind in ('html_end', 'handlebars_end', 'html_singleton_end', 'django_end', 'handlebars_singleton_end', - 'jinja2_whitespace_stripped_end') and + 'jinja2_whitespace_stripped_end',) and (stack[-1]['tag'] != 'pre' or token.tag == 'pre')): info = stack.pop() if info['block']: diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index c8c2a1695c660..2b72817ad71c0 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1201,7 +1201,7 @@ def should_send(setting: str, row: Dict[str, Any]) -> bool: if user_ids: query = UserProfile.objects.filter( - is_active=True, + is_active=True ).values( 'id', 'enable_online_push_notifications', @@ -4101,7 +4101,7 @@ def do_mark_all_as_read(user_profile: UserProfile, client: Client) -> int: do_clear_mobile_push_notifications_for_ids([user_profile.id], all_push_message_ids) msgs = UserMessage.objects.filter( - user_profile=user_profile, + user_profile=user_profile ).extra( where=[UserMessage.where_unread()], ) diff --git a/zerver/lib/presence.py b/zerver/lib/presence.py index a2d97a8a909e0..b298a3487c96e 100644 --- a/zerver/lib/presence.py +++ b/zerver/lib/presence.py @@ -157,7 +157,7 @@ def get_status_dict_by_realm(realm_id: int, slim_presence: bool = False) -> Dict presence_rows = list(query) mobile_query = PushDeviceToken.objects.distinct( - 'user_id', + 'user_id' ).values_list( 'user_id', flat=True, diff --git a/zerver/lib/topic_mutes.py b/zerver/lib/topic_mutes.py index 2e98365321f0f..6bbae12edc601 100644 --- a/zerver/lib/topic_mutes.py +++ b/zerver/lib/topic_mutes.py @@ -11,7 +11,7 @@ def get_topic_mutes(user_profile: UserProfile) -> List[Tuple[str, str, float]]: rows = MutedTopic.objects.filter( - user_profile=user_profile, + user_profile=user_profile ).values( 'stream__name', 'topic_name', @@ -107,7 +107,7 @@ def mute_cond(row: Dict[str, Any]) -> Selectable: def build_topic_mute_checker(user_profile: UserProfile) -> Callable[[int, str], bool]: rows = MutedTopic.objects.filter( - user_profile=user_profile, + user_profile=user_profile ).values( 'recipient_id', 'topic_name', diff --git a/zerver/migrations/0110_stream_is_in_zephyr_realm.py b/zerver/migrations/0110_stream_is_in_zephyr_realm.py index b7270a20d06b0..e1134d5de60c8 100644 --- a/zerver/migrations/0110_stream_is_in_zephyr_realm.py +++ b/zerver/migrations/0110_stream_is_in_zephyr_realm.py @@ -14,7 +14,7 @@ def populate_is_zephyr(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> for realm in realms: Stream.objects.filter( - realm_id=realm.id, + realm_id=realm.id ).update( is_in_zephyr_realm=True, ) diff --git a/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py b/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py index 313f325b4d1f2..b31ccb7716e59 100644 --- a/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py +++ b/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py @@ -29,7 +29,7 @@ def copy_id_to_bigid(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> No return # TODO: is the below lookup fast enough, considering there's no index on bigint_id? - first_uncopied_id = UserMessage.objects.filter(bigint_id__isnull=True, + first_uncopied_id = UserMessage.objects.filter(bigint_id__isnull=True ).aggregate(Min('id'))['id__min'] # Note: the below id can fall in a segment # where bigint_id = id already, but it's not a big problem diff --git a/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py b/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py index 0f6b5be820b15..304b60cb914b9 100644 --- a/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py +++ b/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py @@ -26,7 +26,7 @@ def copy_pub_date_to_date_sent(apps: StateApps, schema_editor: DatabaseSchemaEdi # Nothing to do return - first_uncopied_id = Message.objects.filter(date_sent__isnull=True, + first_uncopied_id = Message.objects.filter(date_sent__isnull=True ).aggregate(Min('id'))['id__min'] # Note: the below id can fall in a segment # where date_sent = pub_date already, but it's not a big problem diff --git a/zerver/tests/test_soft_deactivation.py b/zerver/tests/test_soft_deactivation.py index 745e5e0c232b9..2a9b47a45970b 100644 --- a/zerver/tests/test_soft_deactivation.py +++ b/zerver/tests/test_soft_deactivation.py @@ -250,7 +250,7 @@ def test_reactivate_user_if_soft_deactivated(self) -> None: def last_realm_audit_log_entry(event_type: int) -> RealmAuditLog: return RealmAuditLog.objects.filter( - event_type=event_type, + event_type=event_type ).order_by('-event_time')[0] long_term_idle_user = self.example_user('hamlet')