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:
Anders Kaseorg
2020-09-02 20:49:50 -07:00
committed by Tim Abbott
parent f91d287447
commit 3b301f522b
8 changed files with 11 additions and 11 deletions

View File

@@ -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']:

View File

@@ -1201,7 +1201,7 @@ def get_recipient_info(recipient: Recipient,
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()],
)

View File

@@ -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,

View File

@@ -11,7 +11,7 @@ from zerver.models import MutedTopic, UserProfile, get_stream
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 exclude_topic_mutes(conditions: List[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',

View File

@@ -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,
)

View File

@@ -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

View File

@@ -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

View File

@@ -250,7 +250,7 @@ class SoftDeactivationMessageTest(ZulipTestCase):
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')