Skip to content

Commit 1811170

Browse files
Fix linting and formatting issues, ensure tests pass
1 parent f2fff48 commit 1811170

20 files changed

+56
-38
lines changed

zulipterminal/api_types.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Types from the Zulip API, translated into python, to improve type checking
33
"""
4+
45
# NOTE: Only modify this file if it leads to a better match to the types used
56
# in the API at http://zulip.com/api
67

zulipterminal/cli/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,4 +695,4 @@ def print_setting(setting: str, data: SettingData, suffix: str = "") -> None:
695695

696696

697697
if __name__ == "__main__":
698-
main()
698+
main()

zulipterminal/config/keys.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,11 @@ def display_key_for_urwid_key(urwid_key: str) -> str:
548548
if urwid_map_key in urwid_key:
549549
urwid_key = urwid_key.replace(urwid_map_key, display_map_key)
550550
display_key = [
551-
keyboard_key.capitalize()
552-
if len(keyboard_key) > 1 and keyboard_key[0].islower()
553-
else keyboard_key
551+
(
552+
keyboard_key.capitalize()
553+
if len(keyboard_key) > 1 and keyboard_key[0].islower()
554+
else keyboard_key
555+
)
554556
for keyboard_key in urwid_key.split()
555557
]
556558
return " ".join(display_key)

zulipterminal/config/themes.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
"""
22
Styles and their colour mappings in each theme, with helper functions
33
"""
4+
45
from typing import Any, Dict, List, Optional, Tuple, Union
56

67
from pygments.token import STANDARD_TYPES, _TokenType
78

89
from zulipterminal.config.color import Background, term16
910
from zulipterminal.themes import (
10-
gruvbox_dark_high_contrast,
1111
gruvbox_dark,
12-
gruvbox_light,
13-
zt_blue, zt_dark,
14-
zt_light,
12+
gruvbox_dark_high_contrast,
1513
gruvbox_dark_low_contrast,
14+
gruvbox_light,
1615
gruvbox_light_high_contrast,
17-
gruvbox_light_low_contrast
18-
16+
gruvbox_light_low_contrast,
17+
zt_blue,
18+
zt_dark,
19+
zt_light,
1920
)
2021

2122

@@ -109,8 +110,7 @@
109110
"gruvbox_dark_high_contrast": gruvbox_dark_high_contrast,
110111
"gruvbox_dark_low_contrast": gruvbox_dark_low_contrast,
111112
"gruvbox_light_high_contrast": gruvbox_light_high_contrast,
112-
"gruvbox_light_low_contrast": gruvbox_light_low_contrast,
113-
# "sample": sample,
113+
"gruvbox_light_low_contrast": gruvbox_light_low_contrast,
114114
}
115115

116116
# These are older aliases to some of the above, for compatibility

zulipterminal/core.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ def __init__(
119119
# Register new ^C handler
120120
signal.signal(
121121
signal.SIGINT,
122-
self.prompting_exit_handler
123-
if self.exit_confirmation
124-
else self.no_prompt_exit_handler,
122+
(
123+
self.prompting_exit_handler
124+
if self.exit_confirmation
125+
else self.no_prompt_exit_handler
126+
),
125127
)
126128

127129
def raise_exception_in_main_thread(
@@ -745,4 +747,4 @@ def main(self) -> None:
745747

746748
finally:
747749
self.restore_stdout()
748-
self.loop.screen.tty_signal_keys(*old_signal_list)
750+
self.loop.screen.tty_signal_keys(*old_signal_list)

zulipterminal/helper.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,11 @@ def sort_unread_topics(
171171
return sorted(
172172
unread_topics.keys(),
173173
key=lambda stream_topic: (
174-
stream_list.index(stream_topic[0])
175-
if stream_topic[0] in stream_list
176-
else len(stream_list),
174+
(
175+
stream_list.index(stream_topic[0])
176+
if stream_topic[0] in stream_list
177+
else len(stream_list)
178+
),
177179
stream_topic[1],
178180
),
179181
)

zulipterminal/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ def toggle_stream_muted_status(self, stream_id: int) -> None:
14051405
SubscriptionSettingChange(
14061406
stream_id=stream_id,
14071407
property="is_muted",
1408-
value=not self.is_muted_stream(stream_id)
1408+
value=not self.is_muted_stream(stream_id),
14091409
# True for muting and False for unmuting.
14101410
)
14111411
]

zulipterminal/themes/colors_gruvbox.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
For color reference see:
99
https://github.com/morhetz/gruvbox/blob/master/colors/gruvbox.vim
1010
"""
11+
1112
from enum import Enum
1213

1314
from zulipterminal.config.color import color_properties
@@ -81,4 +82,4 @@ class GruvBoxColor(Enum):
8182
# fmt: on
8283

8384

84-
DefaultBoldColor = color_properties(GruvBoxColor, "BOLD")
85+
DefaultBoldColor = color_properties(GruvBoxColor, "BOLD")

zulipterminal/themes/gruvbox_dark.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This theme uses the default color scheme.
55
For further details on themefiles look at the theme contribution guide.
66
"""
7+
78
from pygments.styles.material import MaterialStyle
89

910
from zulipterminal.config.color import Background
@@ -88,4 +89,4 @@
8889
}
8990
}
9091
}
91-
# fmt: on
92+
# fmt: on

zulipterminal/themes/gruvbox_dark_high_contrast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@
9898
}
9999
}
100100
}
101-
# fmt: on
101+
# fmt: on

zulipterminal/themes/gruvbox_dark_low_contrast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@
9898
}
9999
}
100100
}
101-
# fmt: on
101+
# fmt: on

zulipterminal/themes/gruvbox_light.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
For further details on themefiles look at the theme contribution guide
1010
"""
11+
1112
from pygments.styles.solarized import SolarizedLightStyle
1213

1314
from zulipterminal.config.color import Background

zulipterminal/themes/gruvbox_light_high_contrast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@
9898
}
9999
}
100100
}
101-
# fmt: on
101+
# fmt: on

zulipterminal/themes/gruvbox_light_low_contrast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@
9898
}
9999
}
100100
}
101-
# fmt: on
101+
# fmt: on

zulipterminal/themes/zt_blue.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This theme uses the default color scheme.
55
For further details on themefiles look at the theme contribution guide
66
"""
7+
78
from pygments.styles.zenburn import ZenburnStyle
89

910
from zulipterminal.config.color import Background

zulipterminal/themes/zt_dark.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This theme uses the default color scheme.
55
For further details on themefiles look at the theme contribution guide.
66
"""
7+
78
from pygments.styles.material import MaterialStyle
89

910
from zulipterminal.config.color import Background

zulipterminal/themes/zt_light.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This theme uses the default color scheme.
55
For further details on themefiles look at the theme contribution guide.
66
"""
7+
78
from pygments.styles.perldoc import PerldocStyle
89

910
from zulipterminal.config.color import Background

zulipterminal/ui_tools/boxes.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,11 @@ def autocomplete_users(
581581

582582
# Append user_id's to users with the same names.
583583
user_names_with_distinct_duplicates = [
584-
f"{user['full_name']}|{user['user_id']}"
585-
if user_names_counter[user["full_name"]] > 1
586-
else user["full_name"]
584+
(
585+
f"{user['full_name']}|{user['user_id']}"
586+
if user_names_counter[user["full_name"]] > 1
587+
else user["full_name"]
588+
)
587589
for user in sorted_matching_users
588590
]
589591

zulipterminal/ui_tools/messages.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,16 @@ def reactions_view(
285285

286286
reaction_texts = [
287287
(
288-
"reaction_mine"
289-
if my_user_id in [id[0] for id in ids]
290-
else "reaction",
291-
f" :{reaction}: {len(ids)} "
292-
if len(reactions) > MAXIMUM_USERNAMES_VISIBLE
293-
else f" :{reaction}: {', '.join([id[1] for id in ids])} ",
288+
(
289+
"reaction_mine"
290+
if my_user_id in [id[0] for id in ids]
291+
else "reaction"
292+
),
293+
(
294+
f" :{reaction}: {len(ids)} "
295+
if len(reactions) > MAXIMUM_USERNAMES_VISIBLE
296+
else f" :{reaction}: {', '.join([id[1] for id in ids])} "
297+
),
294298
)
295299
for reaction, ids in reaction_stats.items()
296300
]
@@ -837,9 +841,7 @@ def update_message_author_status(self) -> bool:
837841
return author_is_present
838842

839843
@classmethod
840-
def transform_content(
841-
cls, content: Any, server_url: str
842-
) -> Tuple[
844+
def transform_content(cls, content: Any, server_url: str) -> Tuple[
843845
Tuple[None, Any],
844846
Dict[str, Tuple[str, int, bool]],
845847
List[Tuple[str, str]],

zulipterminal/unicode_emojis.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Unicode emoji data, synchronized semi-regularly with the server source
33
"""
4+
45
# Ignore long lines
56
# ruff: noqa: E501
67

0 commit comments

Comments
 (0)