-
-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add help text on how to interact with message links. #1478
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sushmey I left some preliminary feedback. Please let me know here or on czo if you have points that I've not answered.
zulipterminal/ui_tools/views.py
Outdated
widgets.append( | ||
urwid.AttrWrap(strip, None if index % 2 else "popup_contrast") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be better moved into the loop:
- updating the the loop index in the loop is confusing
- do we want the category wrapped in popup_contrast?
- maybe we could style the second column title differently to the category title?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes updating the loop index is confusing. Figured out a better way to get what I expected.
No we don't need to wrap the popup_contrast. I did it because I was trying to make it visually discernible, updated it to work without the wrap.
We can have a discussion about the style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't necessarily need to think about a style in this first version, but at the time it struck me as an additional motivator for adjusting the loop.
e2d625f
to
8916629
Compare
I believe I covered your questions so far in the stream or here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sushmey It'd be great to get the category headings infrastructure merged, so I left some more feedback on what you have here 👍
Please do reply if you have other issues with the typing.
tests/ui_tools/test_popups.py
Outdated
[ | ||
"contents", | ||
"column_widths", | ||
"expected_instance", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance
is rather vague - what does this function return?
I believe each part of the instance
is essentially a row, which we don't mention in the docstring and maybe in the code that uses it, but could be a useful refactor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the parameter name to expected_widget_type
to be more descriptive since the docstring also mentions that the function is returning list of widgets.
Re second part, are you saying each widget of the list is essentially a row and that the docstring needs a refactor? I feel the current docstring is good enough, it does return a list of widgets that is used to make the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using widget
is consistent with the current docstring and terms used 👍
The second point was my noting that the code might be more readable if we referred to the returned data as rows; widgets are any UI element, so are less specific.
tests/ui_tools/test_popups.py
Outdated
"widget_with_str", | ||
], | ||
) | ||
def test_make_table_with_categories( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this test is great, but it does focus on the urwid form of the output, so it may be worth adding a suffix to the test name to emphasize that, eg. __instances
based on your naming elsewhere (which can be improved).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an __instances
suffix. Although I wonder if this implies there's a test that focuses on make_table_with_categories
as a whole and not on some specific thing like instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it could suggest another test exists, but also means it won't conflict with another later ;) If there are multiple tests for a function, my preferred form now is to separate the function and the intention behind the test.
I suggested __instances
since that's what you were checking in the test, and used in the expected part of the test case name, as per another comment - so let's sync them up if you think the updated expected parameter name is better :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'e used types
everywhere instead of instance because it seems more intuitive than instances
. So let's change it to __types
in the function name also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that'd be good 👍
8916629
to
62008af
Compare
This is not a part of this PR. This is just to resolve issue zulip#1226.
5a41187
to
fbad442
Compare
fbad442
to
09b5850
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sushmey Glad to see you got the types sorted 👍 There seems to be a failing test? Maybe try check-branch
locally, to see what commit is failing?
I replied to some previous comments and left a few more inline.
The PR could do with removing the exploratory parts, eg. commented out, and that would make it clearer what exactly is changing.
tests/ui_tools/test_popups.py
Outdated
widgets = self.pop_up_view.make_table_with_categories(contents, column_widths) | ||
for index, widget in enumerate(widgets): | ||
assert isinstance(widget, expected_widget_type[index]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only thought on rereading this would be to suggest zip
, since it's clearer.
One caveat with zip
is that it pauses at the shorter, but we should test that the length is the same in any case, since that would be a bigger issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zip is used to combine two iterables, right? Not sure how we can use that here.
Edit: Just realised what you meant.
assert len(widgets) == len(expected_widget_type)
for widget, expected_type in zip(widgets,expected_widget_type):
assert isinstance(widget, expected_type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I already saw you changed it in the code :)
@@ -1603,7 +1611,7 @@ def __init__( | |||
full_raw_message_keys = "[{}]".format( | |||
", ".join(map(str, display_keys_for_command("FULL_RAW_MESSAGE"))) | |||
) | |||
msg_info = [ | |||
msg_info: PopUpViewTableContent = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I mentioned this might be an option previously, but you should be able to skip this and therefore not need the isinstance assert further below.
Without the explicit typing, mypy will know it's a list, so accept that it's mutable (modifiable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work otherwise since PopUpViewTableContent
also has types which doesn't support append so need an explicit assertion.
I can't not explicitly type it as PopUpViewTableContent
since Mypy assumes it to be the type of the first data assigned to it.
zulipterminal/ui_tools/views.py
Outdated
if isinstance(category, tuple) and isinstance(content, list): | ||
content.append(category) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't pick up on this before, but the isinstance check on the content allows mypy to treat the content as mutable. That allows the code you have to work, but also makes the use of Sequence
pointless - the code here does not work unless it is specifically a list being passed in.
Is there a reason the other style of category heading cannot be added to the widgets here, rather than copied into the content?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing it out. There was no reason to put it as content. Changed it and removed the condition too.
Updating the function `make_table_with_categories`. So that right aligned hint text can be appended to heading.
Amend `calculate_table_widths` to add case of category with help text.
09b5850
to
8ba5ad7
Compare
What does this PR do, and why?
External discussion & connections
How did you test this?
Self-review checklist for each commit
Visual changes