mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
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 <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
f91d287447
commit
3b301f522b
@@ -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',
|
if token.kind in ('html_start', 'handlebars_start', 'handlebars_singleton',
|
||||||
'html_singleton', 'django_start',
|
'html_singleton', 'django_start',
|
||||||
'jinja2_whitespace_stripped_type2_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
|
# An HTML start tag should only cause a new indent if we
|
||||||
# are on a new line.
|
# are on a new line.
|
||||||
if (token.tag not in ('extends', 'include', 'else', 'elif') and
|
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)
|
stack.append(info)
|
||||||
elif (token.kind in ('html_end', 'handlebars_end', 'html_singleton_end',
|
elif (token.kind in ('html_end', 'handlebars_end', 'html_singleton_end',
|
||||||
'django_end', 'handlebars_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')):
|
(stack[-1]['tag'] != 'pre' or token.tag == 'pre')):
|
||||||
info = stack.pop()
|
info = stack.pop()
|
||||||
if info['block']:
|
if info['block']:
|
||||||
|
|||||||
@@ -1201,7 +1201,7 @@ def get_recipient_info(recipient: Recipient,
|
|||||||
|
|
||||||
if user_ids:
|
if user_ids:
|
||||||
query = UserProfile.objects.filter(
|
query = UserProfile.objects.filter(
|
||||||
is_active=True,
|
is_active=True
|
||||||
).values(
|
).values(
|
||||||
'id',
|
'id',
|
||||||
'enable_online_push_notifications',
|
'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)
|
do_clear_mobile_push_notifications_for_ids([user_profile.id], all_push_message_ids)
|
||||||
|
|
||||||
msgs = UserMessage.objects.filter(
|
msgs = UserMessage.objects.filter(
|
||||||
user_profile=user_profile,
|
user_profile=user_profile
|
||||||
).extra(
|
).extra(
|
||||||
where=[UserMessage.where_unread()],
|
where=[UserMessage.where_unread()],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ def get_status_dict_by_realm(realm_id: int, slim_presence: bool = False) -> Dict
|
|||||||
presence_rows = list(query)
|
presence_rows = list(query)
|
||||||
|
|
||||||
mobile_query = PushDeviceToken.objects.distinct(
|
mobile_query = PushDeviceToken.objects.distinct(
|
||||||
'user_id',
|
'user_id'
|
||||||
).values_list(
|
).values_list(
|
||||||
'user_id',
|
'user_id',
|
||||||
flat=True,
|
flat=True,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from zerver.models import MutedTopic, UserProfile, get_stream
|
|||||||
|
|
||||||
def get_topic_mutes(user_profile: UserProfile) -> List[Tuple[str, str, float]]:
|
def get_topic_mutes(user_profile: UserProfile) -> List[Tuple[str, str, float]]:
|
||||||
rows = MutedTopic.objects.filter(
|
rows = MutedTopic.objects.filter(
|
||||||
user_profile=user_profile,
|
user_profile=user_profile
|
||||||
).values(
|
).values(
|
||||||
'stream__name',
|
'stream__name',
|
||||||
'topic_name',
|
'topic_name',
|
||||||
@@ -107,7 +107,7 @@ def exclude_topic_mutes(conditions: List[Selectable],
|
|||||||
|
|
||||||
def build_topic_mute_checker(user_profile: UserProfile) -> Callable[[int, str], bool]:
|
def build_topic_mute_checker(user_profile: UserProfile) -> Callable[[int, str], bool]:
|
||||||
rows = MutedTopic.objects.filter(
|
rows = MutedTopic.objects.filter(
|
||||||
user_profile=user_profile,
|
user_profile=user_profile
|
||||||
).values(
|
).values(
|
||||||
'recipient_id',
|
'recipient_id',
|
||||||
'topic_name',
|
'topic_name',
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ def populate_is_zephyr(apps: StateApps, schema_editor: DatabaseSchemaEditor) ->
|
|||||||
|
|
||||||
for realm in realms:
|
for realm in realms:
|
||||||
Stream.objects.filter(
|
Stream.objects.filter(
|
||||||
realm_id=realm.id,
|
realm_id=realm.id
|
||||||
).update(
|
).update(
|
||||||
is_in_zephyr_realm=True,
|
is_in_zephyr_realm=True,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def copy_id_to_bigid(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> No
|
|||||||
return
|
return
|
||||||
|
|
||||||
# TODO: is the below lookup fast enough, considering there's no index on bigint_id?
|
# 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']
|
).aggregate(Min('id'))['id__min']
|
||||||
# Note: the below id can fall in a segment
|
# Note: the below id can fall in a segment
|
||||||
# where bigint_id = id already, but it's not a big problem
|
# where bigint_id = id already, but it's not a big problem
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def copy_pub_date_to_date_sent(apps: StateApps, schema_editor: DatabaseSchemaEdi
|
|||||||
# Nothing to do
|
# Nothing to do
|
||||||
return
|
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']
|
).aggregate(Min('id'))['id__min']
|
||||||
# Note: the below id can fall in a segment
|
# Note: the below id can fall in a segment
|
||||||
# where date_sent = pub_date already, but it's not a big problem
|
# where date_sent = pub_date already, but it's not a big problem
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ class SoftDeactivationMessageTest(ZulipTestCase):
|
|||||||
|
|
||||||
def last_realm_audit_log_entry(event_type: int) -> RealmAuditLog:
|
def last_realm_audit_log_entry(event_type: int) -> RealmAuditLog:
|
||||||
return RealmAuditLog.objects.filter(
|
return RealmAuditLog.objects.filter(
|
||||||
event_type=event_type,
|
event_type=event_type
|
||||||
).order_by('-event_time')[0]
|
).order_by('-event_time')[0]
|
||||||
|
|
||||||
long_term_idle_user = self.example_user('hamlet')
|
long_term_idle_user = self.example_user('hamlet')
|
||||||
|
|||||||
Reference in New Issue
Block a user