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

abbreviations mess up the priority order of arguments #217

Open
mathisloevenich opened this issue Mar 3, 2021 · 2 comments
Open

abbreviations mess up the priority order of arguments #217

mathisloevenich opened this issue Mar 3, 2021 · 2 comments

Comments

@mathisloevenich
Copy link

mathisloevenich commented Mar 3, 2021

In my scenrio I have values being set in the config file like:
ignore = [errors]

Starting my script with:
htcanalyze --ignore recources

will override the internal list ignore = [recources]

HOWEVER, when I only use the prefix:
htcanalyze --ign recources

it will result in ignore = [errors].

In this case the config values will not be overwritten, which will result in different user experiences cause no error is thrown due to the ability of argparse on matching prefixes.

This is related to the issue of my project:
psyinfra/HTCAnalyze#90

@mathisloevenich mathisloevenich changed the title prefix matching values are not overwriting the config variables prefix matching values are not (handled) prioritized Mar 3, 2021
@bw2
Copy link
Owner

bw2 commented Mar 15, 2021

This is a bug. The problem is at least partly due to
https://github.com/bw2/ConfigArgParse/blob/master/configargparse.py#L1032

checking for exact matches without first converting prefixes to their corresponding full option names.
A PR to fix this would be appreciated.

@bw2
Copy link
Owner

bw2 commented Jul 1, 2021

Replacing

return any(
potential_arg in arg_names for potential_arg in potential_command_line_args
)

with

return any(
        arg_name.startswith(potential_arg) for potential_arg in potential_command_line_args for arg_name in arg_names
    )

should fix this, but argparse has since added an allow_abbrev arg, so will need to add handling for that before this can be fixed.

@mathisloevenich mathisloevenich changed the title prefix matching values are not (handled) prioritized allow_abbrev does not overwrite config arguments when an abbreviation was used Oct 28, 2021
@mathisloevenich mathisloevenich changed the title allow_abbrev does not overwrite config arguments when an abbreviation was used abbreviations mess up the priority order of arguments Oct 28, 2021
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

2 participants