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

zsh duplicates suggestions #505

Open
FlorianPommerening opened this issue Sep 12, 2024 · 0 comments
Open

zsh duplicates suggestions #505

FlorianPommerening opened this issue Sep 12, 2024 · 0 comments

Comments

@FlorianPommerening
Copy link

This might be related to #504 but I think it is something else: when calling the script like this python ./foo.py, I get duplicate suggestions. Of course it could also be an issue with zsh or my setup of it, so I hope other people can confirm it they also see this.

To reproduce

Test environment:

  • Ubuntu 24.04
  • Python 3.12.3
  • argcomplete 3.1.4-1ubuntu0.1 (this is 3.1.4 with a patch back-ported from 3.3.0 to make it compatible with Python 12.3)
  • zsh 5.9

I tested this with the following file foo.py

#!/usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK

import argcomplete, argparse

parser = argparse.ArgumentParser()

argcomplete.autocomplete(parser)
./foo.py <TAB>        # works fine
python foo.py <TAB>   # works fine
python ./foo.py <TAB> # duplicate suggestions

Suggestions for the last option show up twice in the generated list:

--help                                                                                                                                                                                                                                                                                                                            
-h                                                                                                                                                                                                                                                                                                                                
-- show this help message and exit                                                                                                                                                                                                                                                                                                
--help                                                                                                                                                                                                                                                                                                                            
-h                                                                                                                                                                                                                                                                                                                                
-- show this help message and exit 

Output with _ARC_DEBUG=1

The suggestions are generated once with WORDS: ['python', './foo.py'] and once with WORDS: ['./foo.py'] where in both cases, LINE: 'python ./foo.py '.

python ./foo.py                                  
word ./foo.py split, lexer state: ' '
In trailing whitespace

LINE: 'python ./foo.py ' 
POINT: 16 
PREQUOTE: '' 
PREFIX: '' 
SUFFIX: '' 
WORDS: ['python', './foo.py']
Active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
Visited positionals: [MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
invoking parser with ['./foo.py']
parsed args: (Namespace(), ['./foo.py'])
all active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
active_parser: MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
optional options: ['-h', '--help']
next_positional: None
Active actions (L=0): []
active options: ['-h', '--help']
display completions: {'-h': 'show this help message and exit', '--help': 'show this help message and exit'}

Returning completions: ['-h:show this help message and exit', '--help:show this help message and exit']

word ./foo.py split, lexer state: ' '
In trailing whitespace

LINE: 'python ./foo.py ' 
POINT: 16 
PREQUOTE: '' 
PREFIX: '' 
SUFFIX: '' 
WORDS: ['./foo.py']
Active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
Visited positionals: [MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
invoking parser with []
parsed args: (Namespace(), [])
all active parsers: [MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)]
active_parser: MonkeyPatchedIntrospectiveArgumentParser(prog='foo.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
optional options: ['-h', '--help']
next_positional: None
Active actions (L=0): []
active options: ['-h', '--help']
display completions: {'-h': 'show this help message and exit', '--help': 'show this help message and exit'}

Returning completions: ['-h:show this help message and exit', '--help:show this help message and exit']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant