Author terry.reedy
Recipients taleinat, terry.reedy
Date 2019-08-12.05:10:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565586611.64.0.973161953384.issue37821@roundup.psfhosted.org>
In-reply-to
Content
I think the current behavior is intended.  The IDLE doc Completions subsection, written by Kurt Kaiser in help.text and copied to idle.rst in #5066, has this paragraph 

Completions are currently limited to those in the namespaces. Names in an Editor window which are not via __main__ and sys.modules will not be found.  Run the module once with your imports to correct this situation. Note that IDLE itself places quite a few modules in sys.modules, so much can be found by default, e.g. the re module."

The second sentence is garbled but says that things in sys.modules *will* be found.  The fourth sentence points out that sys.modules has many things imported by IDLE, not by user code, so they can be found *without running one's code*.  The example is "import re...re." and re completions pop up.  I noted on #18766 that cleaning up run.py made this *feature* less useful.  It appears that this issue and your patch are about disable this intended feature.  I don't agree.

To put it another way, "If a shell exists, completion should use the namespace used for evaluating code in the shell." is not correct.  The intended behavior is to complete if at all possible.  #18766 is about expanding 'possible'.

To constantly maximize 'possible', one would run after every name-binding statement (an extreme version of the 3rd sentence above).  I sometimes come close to that, though more to catch typos  and rerun tests as I go.

You are correct that entering 're.DOTALL' by completion without also entering the required corresponding import results in a NameError when running the code .  But the same is true if one enters the same 're.DOTALL' by key.  Either way, one has entered the attribute where and when wanted; the NameError says "now go back up and add the import".

What is odd to me is that you seem happy using the more numerous non-user IDLE imports when there is no Shell.  That would mean that users would initially be better off killing the shell when starting to edit.  To me, the logic of restricting completions when there is a shell would mean no completions when there is not.
History
Date User Action Args
2019-08-12 05:10:13terry.reedysetrecipients: + terry.reedy, taleinat
2019-08-12 05:10:11terry.reedysetmessageid: <1565586611.64.0.973161953384.issue37821@roundup.psfhosted.org>
2019-08-12 05:10:11terry.reedylinkissue37821 messages
2019-08-12 05:10:11terry.reedycreate