Message266320
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 |
|
Date |
User |
Action |
Args |
2016-05-25 08:03:03 | martin.panter | set | recipients:
+ martin.panter, serhiy.storchaka, josh.r |
2016-05-25 08:03:01 | martin.panter | set | messageid: <1464163381.93.0.904697039808.issue25419@psf.upfronthosting.co.za> |
2016-05-25 08:03:01 | martin.panter | link | issue25419 messages |
2016-05-25 08:03:01 | martin.panter | create | |
|