Skip to content

Commit

Permalink
Fix argcomplete 'default_completer' error. (Azure#1793)
Browse files Browse the repository at this point in the history
- Prev. argcomplete.autocomplete() could not take a default_completer. Now, it does so we can’t subclass CompletionFinder anymore.
- Require argcomplete 1.8.0 now as the change isn’t backwards compatible.
  • Loading branch information
derekbekoe authored Jan 19, 2017
1 parent 25de881 commit 6e40240
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
adal==0.4.3
applicationinsights==0.10.0
argcomplete==1.3.0
argcomplete==1.8.0
colorama==0.3.7
jmespath
mock==1.3.0
Expand Down
12 changes: 3 additions & 9 deletions src/azure-cli-core/azure/cli/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ def __call__(self, prefix, **kwargs):
argcomplete.completers.ChoicesCompleter = CaseInsensitiveChoicesCompleter


class EmptyDefaultCompletionFinder(argcomplete.CompletionFinder):

def __init__(self, *args, **kwargs):
super(EmptyDefaultCompletionFinder, self).__init__(*args, default_completer=lambda _: (),
**kwargs)


def enable_autocomplete(parser):
argcomplete.autocomplete = EmptyDefaultCompletionFinder()
argcomplete.autocomplete(parser, validator=lambda c, p: c.lower().startswith(p.lower()))
argcomplete.autocomplete = argcomplete.CompletionFinder()
argcomplete.autocomplete(parser, validator=lambda c, p: c.lower().startswith(p.lower()),
default_completer=lambda _: ())


class AzCliCommandParser(argparse.ArgumentParser):
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
DEPENDENCIES = [
'adal>=0.4.3',
'applicationinsights',
'argcomplete>=1.3.0',
'argcomplete>=1.8.0',
'azure-cli-nspkg',
'azure-mgmt-trafficmanager==0.30.0rc6',
'azure-mgmt-dns==0.30.0rc6',
Expand Down

0 comments on commit 6e40240

Please sign in to comment.