Skip to content

Commit 3612ce4

Browse files
committed
refactor: Replace 'PM' with 'DM'.
refactor: Lint - Type consistency (mypy). refactor: Install & test - CPython 3.7 (ubuntu), codecov. refactor: Install & test - CPython 3.7 (ubuntu), codecov (2). refactor: Install & test - CPython 3.7 (ubuntu), codeco (3). refactor: Install & test - CPython 3.7 (ubuntu), codeco (4).
1 parent f41b33a commit 3612ce4

16 files changed

+52
-53
lines changed

docs/FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ through autocomplete depend upon the context automatically.
369369
* `P` (with stream color) if the stream is valid and private,
370370
* `` if the stream is invalid.
371371

372-
![PM recipients header](https://user-images.githubusercontent.com/55916430/118403345-9d422800-b68b-11eb-9005-6d2af74adab9.png)
372+
![DM recipients header](https://user-images.githubusercontent.com/55916430/118403345-9d422800-b68b-11eb-9005-6d2af74adab9.png)
373373

374374
**NOTE:** If a direct message recipient's name contains comma(s) (`,`), they
375375
are currently treated as comma-separated recipients.

tests/config/test_keys.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_display_key_for_urwid_key(urwid_key: str, display_key: str) -> None:
144144
COMMAND_TO_DISPLAY_KEYS = [
145145
("NEXT_LINE", ["Down", "Ctrl n"]),
146146
("TOGGLE_STAR_STATUS", ["Ctrl s", "*"]),
147-
("ALL_PM", ["P"]),
147+
("ALL_DM", ["P"]),
148148
]
149149

150150

tests/conftest.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,13 @@ def extra_stream_msg_template() -> Message:
500500

501501

502502
@pytest.fixture
503-
def dm_template() -> Message:
503+
def pm_template() -> Message:
504504
recipients = display_recipient_factory([(5179, "Boo Boo"), (5140, "Foo Foo")])
505505
return msg_template_factory(537287, "private", 1520918736, recipients=recipients)
506506

507507

508508
@pytest.fixture
509-
def group_dm_template() -> Message:
509+
def group_pm_template() -> Message:
510510
recipients = display_recipient_factory(
511511
[(5179, "Boo Boo"), (5140, "Foo Foo"), (5180, "Bar Bar")]
512512
)
@@ -519,12 +519,12 @@ def private_message_fixture(request: Any) -> Message:
519519

520520

521521
@pytest.fixture(
522-
params=["stream_msg_template", "dm_template", "group_dm_template"],
523-
ids=["stream_message", "dm_message", "group_dm_message"],
522+
params=["stream_msg_template", "pm_template", "group_pm_template"],
523+
ids=["stream_message", "pm_message", "group_pm_message"],
524524
)
525525
def message_fixture(request: Any) -> Message:
526526
"""
527-
Acts as a parametrize fixture for stream msg, dms and group_dms.
527+
Acts as a parametrize fixture for stream msg, dms and group_pms.
528528
"""
529529
# `request` currently does not have an exported Pytest type.
530530
# TODO: Use the exported type when it's made available.
@@ -535,8 +535,8 @@ def message_fixture(request: Any) -> Message:
535535
@pytest.fixture
536536
def messages_successful_response(
537537
stream_msg_template: Message,
538-
dm_template: Message,
539-
group_dm_template: Message,
538+
pm_template: Message,
539+
group_pm_template: Message,
540540
) -> Dict[str, Any]:
541541
"""
542542
A successful response from a /messages API query.
@@ -546,8 +546,8 @@ def messages_successful_response(
546546
"anchor": 10000000000000000,
547547
"messages": [
548548
stream_msg_template,
549-
dm_template,
550-
group_dm_template,
549+
pm_template,
550+
group_pm_template,
551551
],
552552
"result": "success",
553553
"msg": "",
@@ -634,10 +634,10 @@ def topics() -> List[str]:
634634
],
635635
ids=[
636636
"stream_mention__stream_wildcard",
637-
"stream+dm_mention__no_wildcard",
638-
"no_mention__stream+dm_wildcard",
639-
"stream+group_mention__dm_wildcard",
640-
"dm_mention__stream+group_wildcard",
637+
"stream+pm_mention__no_wildcard",
638+
"no_mention__stream+pm_wildcard",
639+
"stream+group_mention__pm_wildcard",
640+
"pm_mention__stream+group_wildcard",
641641
"group_mention__all_wildcard",
642642
"all_mention__stream_wildcard",
643643
"stream+group_mention__wildcard",
@@ -1060,7 +1060,7 @@ def initial_index() -> Index:
10601060

10611061
@pytest.fixture
10621062
def empty_index(
1063-
stream_msg_template: Message, dm_template: Message, group_dm_template: Message
1063+
stream_msg_template: Message, pm_template: Message, group_pm_template: Message
10641064
) -> Index:
10651065
return deepcopy(
10661066
Index(
@@ -1079,8 +1079,8 @@ def empty_index(
10791079
lambda: {},
10801080
{
10811081
stream_msg_template["id"]: stream_msg_template,
1082-
dm_template["id"]: dm_template,
1083-
group_dm_template["id"]: group_dm_template,
1082+
pm_template["id"]: pm_template,
1083+
group_pm_template["id"]: group_pm_template,
10841084
},
10851085
),
10861086
)
@@ -1140,7 +1140,7 @@ def index_multiple_topic_msg(
11401140
@pytest.fixture
11411141
def index_user(empty_index: Index) -> Index:
11421142
"""
1143-
Expected index of initial_data when model.narrow = [['dm_with',
1143+
Expected index of initial_data when model.narrow = [['pm_with',
11441144
11451145
"""
11461146
user_ids = frozenset({5179, 5140})
@@ -1153,7 +1153,7 @@ def index_user(empty_index: Index) -> Index:
11531153
@pytest.fixture
11541154
def index_user_multiple(empty_index: Index) -> Index:
11551155
"""
1156-
Expected index of initial_data when model.narrow = [['dm_with',
1156+
Expected index of initial_data when model.narrow = [['pm_with',
11571157
11581158
"""
11591159
user_ids = frozenset({5179, 5140, 5180})

tests/model/test_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3989,7 +3989,7 @@ def test__handle_user_settings_event(self, mocker, model, value):
39893989

39903990
@pytest.mark.parametrize("setting", [True, False])
39913991
def test_update_pm_content_in_desktop_notifications(self, mocker, model, setting):
3992-
setting_name = "dm_content_in_desktop_notifications"
3992+
setting_name = "pm_content_in_desktop_notifications"
39933993
event = {
39943994
"type": "update_global_notifications",
39953995
"notification_name": setting_name,

tests/ui/test_ui_tools.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ def test_keypress_NEXT_UNREAD_TOPIC_no_stream(
942942
assert mid_col_view.controller.narrow_to_topic.called is False
943943
assert return_value == key
944944

945-
@pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_PM"))
946-
def test_keypress_NEXT_UNREAD_PM_stream(
945+
@pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_DM"))
946+
def test_keypress_NEXT_UNREAD_DM_stream(
947947
self, mid_col_view, mocker, key, widget_size
948948
):
949949
size = widget_size(mid_col_view)
@@ -959,8 +959,8 @@ def test_keypress_NEXT_UNREAD_PM_stream(
959959
contextual_message_id=1,
960960
)
961961

962-
@pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_PM"))
963-
def test_keypress_NEXT_UNREAD_PM_no_dm(
962+
@pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_DM"))
963+
def test_keypress_NEXT_UNREAD_DM_no_dm(
964964
self, mid_col_view, mocker, key, widget_size
965965
):
966966
size = widget_size(mid_col_view)
@@ -1152,7 +1152,7 @@ def mock_external_classes(self, mocker):
11521152
def test_menu_view(self, mocker):
11531153
self.streams_view = mocker.patch(VIEWS + ".LeftColumnView.streams_view")
11541154
home_button = mocker.patch(VIEWS + ".HomeButton")
1155-
dm_button = mocker.patch(VIEWS + ".PMButton")
1155+
dm_button = mocker.patch(VIEWS + ".DMButton")
11561156
starred_button = mocker.patch(VIEWS + ".StarredButton")
11571157
mocker.patch(VIEWS + ".urwid.ListBox")
11581158
mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker")

tests/ui/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@pytest.mark.parametrize(
1414
"msg, narrow, muted_streams, is_muted_topic_return_value, muted",
1515
[
16-
( # PM TEST
16+
( # DM TEST
1717
{
1818
"type": "private",
1919
# ...

tests/ui_tools/test_buttons.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from zulipterminal.config.symbols import CHECK_MARK, MUTE_MARKER
1111
from zulipterminal.ui_tools.buttons import (
1212
DecodedStream,
13+
DMButton,
1314
EmojiButton,
1415
MessageLinkButton,
1516
ParsedNarrowLink,
16-
PMButton,
1717
StarredButton,
1818
StreamButton,
1919
TopButton,
@@ -179,13 +179,13 @@ def test_update_widget(
179179
set_attr_map.assert_called_once_with({None: top_button.label_style})
180180

181181

182-
class TestPMButton:
182+
class TestDMButton:
183183
def test_button_text_length(self, mocker: MockerFixture, count: int = 10) -> None:
184-
dm_button = PMButton(controller=mocker.Mock(), count=count)
184+
dm_button = DMButton(controller=mocker.Mock(), count=count)
185185
assert len(dm_button.label_text) == 20
186186

187187
def test_button_text_title(self, mocker: MockerFixture, count: int = 10) -> None:
188-
dm_button = PMButton(controller=mocker.Mock(), count=count)
188+
dm_button = DMButton(controller=mocker.Mock(), count=count)
189189
title_text = dm_button.label_text[:-3].strip()
190190
assert title_text == "Direct messages"
191191

tests/ui_tools/test_messages.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def test_main_view_renders_slash_me(self, mocker, message, content, is_me_messag
827827
ids=[
828828
"different_stream_before",
829829
"different_topic_before",
830-
"PM_before",
830+
"DM_before",
831831
],
832832
)
833833
def test_main_view_generates_stream_header(
@@ -887,7 +887,7 @@ def test_main_view_generates_stream_header(
887887
"stream_before",
888888
],
889889
)
890-
def test_main_view_generates_PM_header(
890+
def test_main_view_generates_DM_header(
891891
self, mocker, message, to_vary_in_last_message
892892
):
893893
last_message = dict(message, **to_vary_in_last_message)
@@ -1041,7 +1041,7 @@ def test_msg_generates_search_and_header_bar(
10411041
assert header_bar[0].text.startswith(assert_header_bar)
10421042
assert search_bar.text_to_fill == assert_search_bar
10431043

1044-
# Assume recipient (PM/stream/topic) header is unchanged below
1044+
# Assume recipient (DM/stream/topic) header is unchanged below
10451045
@pytest.mark.parametrize(
10461046
"message",
10471047
[

zulipterminal/config/keys.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class KeyBinding(TypedDict):
214214
'help_text': 'View all messages',
215215
'key_category': 'narrowing',
216216
},
217-
'ALL_PM': {
217+
'ALL_DM': {
218218
'keys': ['P'],
219219
'help_text': 'View all direct messages',
220220
'key_category': 'narrowing',
@@ -234,7 +234,7 @@ class KeyBinding(TypedDict):
234234
'help_text': 'Next unread topic',
235235
'key_category': 'narrowing',
236236
},
237-
'NEXT_UNREAD_PM': {
237+
'NEXT_UNREAD_DM': {
238238
'keys': ['p'],
239239
'help_text': 'Next unread direct message',
240240
'key_category': 'narrowing',
@@ -346,7 +346,7 @@ class KeyBinding(TypedDict):
346346
'help_text': 'Show/hide user information',
347347
'key_category': 'user_list',
348348
},
349-
'NARROW_TO_USER_PM': {
349+
'NARROW_TO_USER_DM': {
350350
# Added to clarify functionality of button activation,
351351
# as opposed to opening user profile or other effects.
352352
# Implementation uses ACTIVATE_BUTTON command.

zulipterminal/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,15 @@ def narrow_to_user(
645645
) -> None:
646646
self._narrow_to(
647647
anchor=contextual_message_id,
648-
dm_with=", ".join(recipient_emails),
648+
pm_with=", ".join(recipient_emails),
649649
)
650650

651651
def narrow_to_all_messages(
652652
self, *, contextual_message_id: Optional[int] = None
653653
) -> None:
654654
self._narrow_to(anchor=contextual_message_id)
655655

656-
def narrow_to_all_pm(self, *, contextual_message_id: Optional[int] = None) -> None:
656+
def narrow_to_all_dm(self, *, contextual_message_id: Optional[int] = None) -> None:
657657
self._narrow_to(anchor=contextual_message_id, pms=True)
658658

659659
def narrow_to_all_starred(self) -> None:

zulipterminal/ui.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
260260
elif (
261261
is_command_key("SEARCH_MESSAGES", key)
262262
or is_command_key("NEXT_UNREAD_TOPIC", key)
263-
or is_command_key("NEXT_UNREAD_PM", key)
263+
or is_command_key("NEXT_UNREAD_DM", key)
264264
or is_command_key("STREAM_MESSAGE", key)
265265
or is_command_key("DIRECT_MESSAGE", key)
266266
):
@@ -269,7 +269,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
269269
self.body.focus_col = 1
270270
self.middle_column.keypress(size, key)
271271
return key
272-
elif is_command_key("ALL_PM", key):
272+
elif is_command_key("ALL_DM", key):
273273
self.dm_button.activate(key)
274274
elif is_command_key("ALL_STARRED", key):
275275
self.starred_button.activate(key)

zulipterminal/ui_tools/boxes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ def __init__(self, view: Any) -> None:
8787
# Set to int for stream box only
8888
self.stream_id: Optional[int]
8989

90-
# Used in PM and stream boxes
91-
# (empty list implies PM box empty, or not initialized)
90+
# Used in DM and stream boxes
91+
# (empty list implies DM box empty, or not initialized)
9292
# Prioritizes autocomplete in message body
9393
self.recipient_user_ids: List[int]
9494

95-
# Updates server on PM typing events
95+
# Updates server on DM typing events
9696
# Is separate from recipient_user_ids because we
9797
# don't include the user's own id in this list
9898
self.typing_recipient_user_ids: List[int]
@@ -168,7 +168,7 @@ def _set_regular_and_typing_recipient_user_ids(
168168
self.typing_recipient_user_ids = list()
169169

170170
def send_stop_typing_status(self) -> None:
171-
# Send 'stop' updates only for PM narrows, when there are recipients
171+
# Send 'stop' updates only for DM narrows, when there are recipients
172172
# to send to and a prior 'start' status has already been sent.
173173
if (
174174
self.compose_box_status == "open_with_private"

zulipterminal/ui_tools/buttons.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ def __init__(self, *, controller: Any, count: int) -> None:
143143
)
144144

145145

146-
class PMButton(TopButton):
146+
class DMButton(TopButton):
147147
def __init__(self, *, controller: Any, count: int) -> None:
148-
button_text = f"Direct messages [{primary_display_key_for_command('ALL_PM')}]"
148+
button_text = f"Direct messages [{primary_display_key_for_command('ALL_DM')}]"
149149

150150
super().__init__(
151151
controller=controller,

zulipterminal/ui_tools/messages.py

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ def need_recipient_header(self) -> bool:
146146
else:
147147
raise RuntimeError("Invalid message type")
148148

149-
def _is_direct_message_to_self(self) -> bool:
150149
def _is_direct_message_to_self(self) -> bool:
151150
recipient_list = self.message["display_recipient"]
152151
return (

zulipterminal/ui_tools/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_msg_box_list(
5858

5959
# The SIM114 warnings are ignored here since combining the branches would be less clear
6060
def is_muted(msg: Message, model: Any) -> bool:
61-
# PMs cannot be muted
61+
# DMs cannot be muted
6262
if msg["type"] == "private": # noqa: SIM114
6363
return False
6464
# In a topic narrow

zulipterminal/ui_tools/views.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
from zulipterminal.server_url import near_message_url
4747
from zulipterminal.ui_tools.boxes import PanelSearchBox
4848
from zulipterminal.ui_tools.buttons import (
49+
DMButton,
4950
EmojiButton,
5051
HomeButton,
5152
MentionedButton,
5253
MessageLinkButton,
53-
PMButton,
5454
StarredButton,
5555
StreamButton,
5656
TopicButton,
@@ -629,7 +629,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
629629
topic_name=topic,
630630
)
631631
return key
632-
elif is_command_key("NEXT_UNREAD_PM", key):
632+
elif is_command_key("NEXT_UNREAD_DM", key):
633633
# narrow to next unread dm
634634
dm = self.model.get_next_unread_pm()
635635
if dm is None:
@@ -640,7 +640,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
640640
contextual_message_id=dm,
641641
)
642642
elif is_command_key("DIRECT_MESSAGE", key):
643-
# Create new PM message
643+
# Create new DM message
644644
self.footer.private_box_view()
645645
self.set_focus("footer")
646646
self.footer.focus_position = 0
@@ -793,7 +793,7 @@ def menu_view(self) -> Any:
793793
self.view.home_button = HomeButton(controller=self.controller, count=count)
794794

795795
count = self.model.unread_counts.get("all_dms", 0)
796-
self.view.dm_button = PMButton(controller=self.controller, count=count)
796+
self.view.dm_button = DMButton(controller=self.controller, count=count)
797797

798798
self.view.mentioned_button = MentionedButton(
799799
controller=self.controller,

0 commit comments

Comments
 (0)