Skip to content
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

IDLE: Add import statement completion #61440

Open
RamchandraApte mannequin opened this issue Feb 19, 2013 · 8 comments
Open

IDLE: Add import statement completion #61440

RamchandraApte mannequin opened this issue Feb 19, 2013 · 8 comments
Labels
3.10 only security fixes topic-IDLE type-feature A feature request or enhancement

Comments

@RamchandraApte
Copy link
Mannequin

RamchandraApte mannequin commented Feb 19, 2013

BPO 17238
Nosy @terryjreedy, @serwy, @vadmium, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2013-02-19.15:32:51.210>
labels = ['expert-IDLE', 'type-feature', '3.10']
title = 'IDLE: Add import statement completion'
updated_at = <Date 2020-07-07.20:31:48.608>
user = 'https://bugs.python.org/RamchandraApte'

bugs.python.org fields:

activity = <Date 2020-07-07.20:31:48.608>
actor = 'terry.reedy'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['IDLE']
creation = <Date 2013-02-19.15:32:51.210>
creator = 'Ramchandra Apte'
dependencies = []
files = []
hgrepos = []
issue_num = 17238
keywords = []
message_count = 8.0
messages = ['182392', '191227', '191260', '271199', '271216', '271348', '370848', '373246']
nosy_count = 5.0
nosy_names = ['terry.reedy', 'roger.serwy', 'Ramchandra Apte', 'martin.panter', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue17238'
versions = ['Python 3.10']

@RamchandraApte
Copy link
Mannequin Author

RamchandraApte mannequin commented Feb 19, 2013

[patch under development]
I propose to add completions for
import <tab>
from <tab>
from x import <tab>

Also, if one types imp.<tab> , IDLE should import the module and list dir(module).
(There will be an option to disable/enable the last two completion cases as some users object to it importing modules for completion)

@RamchandraApte RamchandraApte mannequin added topic-IDLE type-feature A feature request or enhancement labels Feb 19, 2013
@serwy serwy mannequin changed the title Enhance import statement completion IDLE: Enhance import statement completion Apr 7, 2013
@terryjreedy
Copy link
Member

Making a list of all possible modules is harder than a list of attributes. With relative imports, I am not sure its even possible to sensible make a list of every entry that would work.

@RamchandraApte
Copy link
Mannequin Author

RamchandraApte mannequin commented Jun 16, 2013

I have a patch ready; have to make it ready (PEP-8-compliance etc.) and then
I can send it.

On 16 June 2013 00:52, Terry J. Reedy <report@bugs.python.org> wrote:

Terry J. Reedy added the comment:

Making a list of all possible modules is harder than a list of attributes.
With relative imports, I am not sure its even possible to sensible make a
list of every entry that would work.

----------


Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue17238\>


@vadmium
Copy link
Member

vadmium commented Jul 25, 2016

Even if your patch isn’t quite ready, it may (have been) better than nothing :)

I had the idea to share stuff between Idle completion and Readline completion, but after looking at the Idle code, it did not seem very practical in general. But maybe you can at least use some ideas, test cases, or share the low level code from bpo-25419. E.g. my patch there has method _import_matches() that takes a path of packages and yields (sub)module names, and method _from_import_matches() that also yields module attribute names.

@terryjreedy
Copy link
Member

I change 'enhance' to 'add' because there is no 'import completion' now.

Ramchandra, when replying by email, delete the quoted email. But do submit a patch even is less than perfect.

The idea of autoimporting a name to complete an attribute is separate from the idea of doing something special in import statements. Autoimport is the subject of bpo-18766, which has a patch and my thoughts so far. So this issue is only about import statements.

Martin, I just opened bpo-27609 as an umbrella issue for multiple completion issues. I am not happy with the current IDLE completion code. Does any of the readline completion code depend on function provided by readline, or is it all an extension of readline, using logic in Python?

@terryjreedy terryjreedy changed the title IDLE: Enhance import statement completion IDLE: Add import statement completion Jul 25, 2016
@vadmium
Copy link
Member

vadmium commented Jul 26, 2016

The readline completion code does not strictly depend on on Readline, although currently it is modelled after its quirky API. But we can change that by adding a more general API.

In <https://bugs.python.org/issue25419#msg266320\>, I suggested an API “complete_code(code) -> list of modules, attributes, globals, etc.” In the Readline case, you pass in the line of code up to the cursor, and it would return possible completions. Perhaps Idle might pass in multiple lines of code. There could also be a predefined global namespace, either as another parameter, or preloaded into a completer object.

When I briefly looked at the Idle code a while back, it did not seem easy for me to adapt to this sort of API. But maybe you have a better idea of what could be done.

@terryjreedy
Copy link
Member

I opened bpo-40892 for using rlcomplete suffixes.
I should look as bpo-25419 for patch and messages for import ideas.

@terryjreedy terryjreedy added the 3.10 only security fixes label Jun 7, 2020
@terryjreedy
Copy link
Member

+1 for import completion. Above, I misspelled 'rlcompleter' as 'rlcomplete'. When I just tried to import it as part of responding to bpo-41230, the wrong name did not work. I wish I could have stopped with 'import rl'<tab>. To add a note to bpo-37765, I tried 'import keywords'. Nope, no 's'. 'import ke'<tab> would have been nice. I suspect that some beginners have as much trouble with names they have no recently used.

im<tab> would work if keywords were added to the tab completion list. bpo-37765.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes topic-IDLE type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

2 participants