Skip to content

Commit

Permalink
python: Tweak some magic trailing commas to avoid Black bugs.
Browse files Browse the repository at this point in the history
psf/black#1658
psf/black#1671

Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk committed Sep 3, 2020
1 parent f302abc commit 4aa4c92
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tools/lib/pretty_print.py
Expand Up @@ -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
Expand Down Expand Up @@ -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']:
Expand Down
4 changes: 2 additions & 2 deletions zerver/lib/actions.py
Expand Up @@ -1217,7 +1217,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',
Expand Down Expand Up @@ -4116,7 +4116,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()],
)
Expand Down
2 changes: 1 addition & 1 deletion zerver/lib/presence.py
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions zerver/lib/topic_mutes.py
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion zerver/migrations/0110_stream_is_in_zephyr_realm.py
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion zerver/tests/test_soft_deactivation.py
Expand Up @@ -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')
Expand Down

0 comments on commit 4aa4c92

Please sign in to comment.