bpo-21261: IDLE - add completion of dict sting keys#15169
Conversation
There was a problem hiding this comment.
Tested using the IDLE shell from the PR branch. OS: Arch Linux 5.2.3.
Test for str
Before tab:

After tab:

Test for bytes
Before tab:

After tab:

Looks like it's working as intended, nicely done! I also tested to ensure that excessively_long_key and didn't auto-complete when using d[b'e and the same for d['t -> d['thanks taleinat'. I intentionally used a space instead of an underscore for the second one (even if it goes against naming convention) to ensure there weren't any issues there. LGTM.
Sorry, something went wrong.
|
@aeros167, I've addressed all of the issues you brought up, plus your suggestions. I've also completed the implementation and added a ton of tests. If you have the time to give this another go, that would be great! |
Sorry, something went wrong.
|
@terryjreedy, in order to have many of the tests not require a GUI, I've expanded the existing I'm a bit worried about the long-term maintenance of this, though Tkinter changes little enough that it may be negligible. If you prefer that I roll back these additions and just have the relevant tests require having a working GUI environment, I'm fine with that too. |
Sorry, something went wrong.
|
Thanks @taleinat, I'll run through the tests again later tonight and report back with the results. |
Sorry, something went wrong.
|
I believe the change to What's New 3.8 will prevent the auto backport to 3.7, where the file does not exist. I have usually changed What's New in separate issues, currently bpos 33821 and 33821. (That is partly because What's New has been an after thought.) Since the change to the earliest version (now WN 3.7) will backport all the way, just the change to WN 3.8 needs to be pulled to a separate PR, also attached to 21261, that is only backported to 3.8. After 3.8.0, when What's New 3.9 is added, I will add an issue for that and 3 separate PRs will be needed to avoid manual backport. |
Sorry, something went wrong.
I'm happy to execute that manual backport. It's simpler for me than having separate PRs. |
Sorry, something went wrong.
Also added tests for this case, as well as for typing an opening bracket in a string, which should not trigger dict key completion.
|
I've fixed completions after opening brackets when there are no available dict key completions, e.g. At the same time, I've removed all cases where dict keys were mixed with global variables in the completion list, as requested by @terryjreedy. @terryjreedy, that addresses all outstanding issues with this PR. |
Sorry, something went wrong.
|
I have made the requested changes; please review again. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
Sorry, something went wrong.
# Conflicts: # Doc/whatsnew/3.8.rst
23ee864 to
38c28f2
Compare
November 14, 2019 11:08
|
I've merged in the updated This is still waiting for @terryjreedy's review. |
Sorry, something went wrong.
# Conflicts: # Doc/library/idle.rst # Lib/idlelib/autocomplete.py # Lib/idlelib/autocomplete_w.py # Lib/idlelib/idle_test/test_autocomplete.py
|
I must say that I'm especially sad that this has not made it into IDLE. :( |
Sorry, something went wrong.
|
I did not proper cognize until today that mixing in the tab list had been undone. Moving on... I want to handle mock-tk stuff separately. I believe that your patch would supersede those of issue 18504. I am reserving comments and change request for that or a new issue. I will make the new PR if you want. Nothing should be removed from this patch until obsoleted by merging the new PR. As for dict string key completion: I am surprised (and not happy) that a seemingly simple and marginally useful addition should nearly double the code in autocomplete.py. So I will be looking to see if anything can be shrunk. I redid all the experiments discussed in my bug list with string keys and a very short delay All the lists look correct. The main issue I encountered was navigating the list by typing partial entries. I discussed this as part of post on the issue about reconsidering inclusion of bytes keys. |
Sorry, something went wrong.
|
Changed title to reflect that string key completion works in editor (once code is run, as with imports and definitions) and upon request. |
Sorry, something went wrong.
Indeed, I'm not convinced that including this feature is worth the extra code and effort. Removing the support for bytes would help somewhat, but the support for string keys would still be complex. I'd feel fine if we decided not to implement this feature: If it means that the work in making this PR helped us make the decision, then it was worth it! |
Sorry, something went wrong.
|
Closing in favor of a newer version of this PR, GH-26039. |
Sorry, something went wrong.
This is a new implementation, created from scratch. I intentionally didn't base this on PR GH-1511 after reviewing it thoroughly.
Note that completion is intentionally limited to keys of type str and bytes only.
Additional changes made in this PR:
https://bugs.python.org/issue21261