-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-21261: IDLE - add completion of dict sting keys #15169
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
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.
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.
@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! |
@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. |
Thanks @taleinat, I'll run through the tests again later tonight and report back with the results. |
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. |
I'm happy to execute that manual backport. It's simpler for me than having separate PRs. |
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. |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
# Conflicts: # Doc/whatsnew/3.8.rst
23ee864
to
38c28f2
Compare
I've merged in the updated This is still waiting for @terryjreedy's review. |
# 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. :( |
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. |
Changed title to reflect that string key completion works in editor (once code is run, as with imports and definitions) and upon request. |
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! |
Closing in favor of a newer version of this PR, GH-26039. |
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