This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients josh.r, martin.panter, serhiy.storchaka
Date 2016-05-25.08:02:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464163381.93.0.904697039808.issue25419@psf.upfronthosting.co.za>
In-reply-to
Content
I moved all the calls targetting the readline module into a ReadlineCompleter subclass. However the logic for parsing “import” statements still exists in the base Completer class in private methods. An overview of the two classes:

class Completer:
    def complete(self, text, state):
        self._get_matches(text)
    def _get_matches(text):
        # Only completes global and object.attr names, like before
    def _code_matches(self, code, ...):
        # Completes import statements, otherwise returns (None, ...)

class ReadlineCompleter(Completer):  # New public class
    def complete(self, text, state):
        # Moved Yury’s Tab insertion logic here
        return super().complete(...)
    def _get_matches(text):
        code = readline.get_line_buffer()[:readline.get_endidx()]
        self._code_matches(code)
        super()._get_matches(text)  # Fallback to existing behaviour

Perhaps the _code_matches() and related methods could be turned into more general public APIs, e.g. complete_code(code) -> list of modules, attributes, globals, etc. But that would affect global_matches() and attr_matches(), which I have not touched so far.

Other changes:
* Limit underscore-prefixed completions, consistent with Issue 25011; see new _filter_identifiers() method
* Changed the demo in the documentation; attributes like __doc__ are omitted by default
* Removed workaround for non-ASCII input in favour of fixing Issue 16182
History
Date User Action Args
2016-05-25 08:03:03martin.pantersetrecipients: + martin.panter, serhiy.storchaka, josh.r
2016-05-25 08:03:01martin.pantersetmessageid: <1464163381.93.0.904697039808.issue25419@psf.upfronthosting.co.za>
2016-05-25 08:03:01martin.panterlinkissue25419 messages
2016-05-25 08:03:01martin.pantercreate