-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-94520: Make CallTips selectable in IDLE #143029
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,24 +93,20 @@ class SB: __call__ = None | |
| non-overlapping occurrences of the pattern in string by the | ||
| replacement repl. repl can be either a string or a callable; | ||
| if a string, backslash escapes in it are processed. If it is | ||
| a callable, it's passed the Match object and must return''') | ||
| a callable, it's passed the Match object and must return | ||
| a replacement string to be used.''') | ||
| tiptest(p.sub, '''\ | ||
| (repl, string, count=0) | ||
| Return the string obtained by replacing the leftmost \ | ||
| non-overlapping occurrences o...''') | ||
| Return the string obtained by replacing the leftmost non-overlapping \ | ||
| occurrences of pattern in string by the replacement repl.''') | ||
|
|
||
| def test_signature_wrap(self): | ||
| def test_signature(self): | ||
| if textwrap.TextWrapper.__doc__ is not None: | ||
| self.assertEqual(get_spec(textwrap.TextWrapper), '''\ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we avoid only checking the first line? please check the entire docstring (it also helps reducing the diff) |
||
| (width=70, initial_indent='', subsequent_indent='', expand_tabs=True, | ||
| replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, | ||
| drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, | ||
| placeholder=' [...]') | ||
| Object for wrapping/filling text. The public interface consists of | ||
| the wrap() and fill() methods; the other methods are just there for | ||
| subclasses to override in order to tweak the default behaviour. | ||
| If you want to completely replace the main wrapping algorithm, | ||
| you\'ll probably have to override _wrap_chunks().''') | ||
| self.assertEqual(get_spec(textwrap.TextWrapper).split('\n')[0], '''\ | ||
| (width=70, initial_indent='', subsequent_indent='', expand_tabs=True, \ | ||
| replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, \ | ||
| drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, \ | ||
| placeholder=' [...]')''') | ||
|
|
||
| def test_properly_formatted(self): | ||
|
|
||
|
|
@@ -127,16 +123,14 @@ def baz(s='a'*100, z='b'*100): | |
| indent = calltip._INDENT | ||
|
|
||
| sfoo = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\ | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\ | ||
| "aaaaaaaaaa')" | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')" | ||
| sbar = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\ | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we changing those tests? |
||
| "aaaaaaaaaa')\nHello Guido" | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"\ | ||
| "\nHello Guido" | ||
| sbaz = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\ | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\ | ||
| "aaaaaaaaaa', z='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"\ | ||
| "bbbbbbbbbbbbbbbbb\n" + indent + "bbbbbbbbbbbbbbbbbbbbbb"\ | ||
| "bbbbbbbbbbbbbbbbbbbbbb')" | ||
| "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',"\ | ||
| " z='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"\ | ||
| "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')" | ||
|
|
||
| for func,doc in [(foo, sfoo), (bar, sbar), (baz, sbaz)]: | ||
| with self.subTest(func=func, doc=doc): | ||
|
|
@@ -145,29 +139,7 @@ def baz(s='a'*100, z='b'*100): | |
| def test_docline_truncation(self): | ||
| def f(): pass | ||
| f.__doc__ = 'a'*300 | ||
| self.assertEqual(get_spec(f), f"()\n{'a'*(calltip._MAX_COLS-3) + '...'}") | ||
|
|
||
| @unittest.skipIf(MISSING_C_DOCSTRINGS, | ||
| "Signature information for builtins requires docstrings") | ||
| def test_multiline_docstring(self): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we removing this test? |
||
| # Test fewer lines than max. | ||
| self.assertEqual(get_spec(range), | ||
| "range(stop) -> range object\n" | ||
| "range(start, stop[, step]) -> range object") | ||
|
|
||
| # Test max lines | ||
| self.assertEqual(get_spec(bytes), '''\ | ||
| bytes(iterable_of_ints) -> bytes | ||
| bytes(string, encoding[, errors]) -> bytes | ||
| bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer | ||
| bytes(int) -> bytes object of size given by the parameter initialized with null bytes | ||
| bytes() -> empty bytes object''') | ||
|
|
||
| def test_multiline_docstring_2(self): | ||
| # Test more than max lines | ||
| def f(): pass | ||
| f.__doc__ = 'a\n' * 15 | ||
| self.assertEqual(get_spec(f), '()' + '\na' * calltip._MAX_LINES) | ||
| self.assertEqual(get_spec(f), "()\n%s" % ('a'*300)) | ||
|
|
||
| def test_functions(self): | ||
| def t1(): 'doc' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| Make CallTips selectable | ||
|
|
||
| The text display widget in the "CalltipWindow" has been changed from | ||
| "tk.Label" to "ScrolledText", and now the text in the "Calltip" window can | ||
| be selected with mouse. The display size of the "CalltipWindow" is set to | ||
| the smaller value between the size when using the "tk.Label" widget and the | ||
| default size of "tk.Text". When the displayed text exceeds the display area | ||
| of the "ScrolledText" window, showing the vertical scrollbar; otherwise, | ||
| hiding the scrollbar. Since more text can be displayed, "argspec" is no | ||
| longer truncated, and the tests related to the max lines or text truncation | ||
| have been removed from the unit tests. Contributed by Shixian Li. | ||
|
Comment on lines
+1
to
+11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pleae make it shorter. There is a lot of text and I don't think everything is needed. |
||
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 think we are still checking the wrapping here so I would prefer keeping the test name.