Skip to content

bpo-40511: fix unnecessary flashing of calltips#20910

Merged
terryjreedy merged 13 commits into
python:masterfrom
taleinat:bpo-40511/IDLE-fix-parens-flashing-calltip
Nov 2, 2020
Merged

bpo-40511: fix unnecessary flashing of calltips#20910
terryjreedy merged 13 commits into
python:masterfrom
taleinat:bpo-40511/IDLE-fix-parens-flashing-calltip

Conversation

@taleinat

@taleinat taleinat commented Jun 16, 2020

Copy link
Copy Markdown
Contributor

@roseman roseman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried it out, looks good!

@taleinat

Copy link
Copy Markdown
Contributor Author

Thanks for trying this out and giving some feedback, @roseman!

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this patch fixes flashing in at least one case each of parens in string and bytes literals, comments, and expressions.

My first code concern is whether each new line is needed. I suspect some are either not or are not the best fix.

My second is whether the fix introduces regressions. Might tips be suppressed when needed? I tested both nested function calls such as int(float(a)) ('float(' open a float tip, 'a)' closes it and restores the int tip) and forced opens at various places. These continue working. To completely understand the new code and be more confident, I need to look at hyperparser.

I outlined a new non-gui open_calltip testcase and am willing to write it. A slightly different approach would be to add the new test code examples to the hyperparser test and then mock hyperparser for these tests.

Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py
@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@taleinat

taleinat commented Oct 28, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @terryjreedy! 🙏

I have made the requested changes; please review again.

I outlined a new non-gui open_calltip testcase and am willing to write it. A slightly different approach would be to add the new test code examples to the hyperparser test and then mock hyperparser for these tests.

Let me know if you'd like me to write such tests or if you'd rather do so yourself.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate existing bug for another issue: if an inner call has no tip, the outer tip is closed anyway (a correct thing to do) but not restored when the the inner call is completed with ')'. To fix, we might either stack outer tips or flag nested tips.

But I don't want to make additional code changes (other than a docstring and a revised comment) until we have tests, which I will start now.

Comment thread Lib/idlelib/calltip.py Outdated
Comment on lines +60 to +62
sur_paren = hp.get_surrounding_brackets('(')
if not sur_paren:
# Not inside parentheses: Don't open a calltip, and close one if
# currently open.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not sur_paren:
# Not inside parentheses: Don't open a calltip, and close one if
# currently open.
if not sur_paren: # Outer call just closed by releasing ).

See response to your response below.

@taleinat taleinat Nov 1, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typing ')' is not the only case where this branch will be reached: it can also happen in various other cases via force_open_calltip_event().

Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py
Comment thread Lib/idlelib/calltip.py Outdated
# in a string or the opener for a tuple: Do nothing.
return

# At this point, the current index is after an opening parenthesis, in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might later think about rewording or condensing the added comments, but tests are a higher priority.

@bedevere-bot

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@terryjreedy

Copy link
Copy Markdown
Member

I think the tests I added are sufficient for this issue. open_calltip is covered except for some of the if branches. I plan to follow-up with a separate test PR, aiming for 100% coverage.

@terryjreedy

Copy link
Copy Markdown
Member

Tal, if you are too busy now, do you mind if I finish this so I can continue with followups?

@taleinat

taleinat commented Nov 1, 2020

Copy link
Copy Markdown
Contributor Author

@terryjreedy, I have made the requested changes; please review again.

I've also refactored the new code in test_calltip a bit, and somewhat condensed the comments you mentioned.

AFAICT that should address your review requests. If I've missed something, apologies in advance, please let me know and I'll handle it quickly.

@bedevere-bot

Copy link
Copy Markdown

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the test change. The test failure was whitespace in the added docstring. My fault I presume. I will merge when the retest passes.

REs with re-specific \ escapes must be r-prefixed to avoid deprecation warning now, exception later. python -m test.test_idle prints them. I added it to the RE I added to mock Text.

@terryjreedy terryjreedy added needs backport to 3.8 type-bug An unexpected behavior, bug, or error labels Nov 2, 2020
@terryjreedy terryjreedy merged commit da7bb7b into python:master Nov 2, 2020
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-23093 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-23094 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
miss-islington added a commit that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@taleinat taleinat deleted the bpo-40511/IDLE-fix-parens-flashing-calltip branch November 2, 2020 06:57
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants