ConfigArgParse icon indicating copy to clipboard operation
ConfigArgParse copied to clipboard

abbreviated options are ignored

Open ihadanny opened this issue 6 years ago • 2 comments

my config.ini:

banana=original_banana

if I run with full argument name, I get the expected result:

python test_configargparse.py --banana new_banana
new_banana

if I run with abbreviated argument name (--ban instead of --banana), I get unexpected behaviour:

python test_configargparse.py --ban new_banana 
original_banana

code for test_configargparse.py

import os, configargparse as ap
parser = ap.ArgumentParser(default_config_files=["config.ini"])
parser.add_argument('--banana',dest='banana')
options = parser.parse_args()
print(options.banana)

versions = ConfigArgParse==0.13.0, Python 2.7.10

is this a bug or am I missing something obvious?? it's a very basic feature in a very established module...

NOTE: this feature is explicitly documented in https://docs.python.org/3/library/argparse.html

allows long options to be abbreviated to a prefix, if the abbreviation is unambiguous (the prefix matches a unique option)

see also https://stackoverflow.com/questions/53848275/configargparse-ignores-abbreviated-options

ihadanny avatar Dec 19 '18 11:12 ihadanny

This seems like a bug. If impossible to fix, the difference with argparse behavior should be documented I guess.

ronhanson avatar Jan 31 '19 15:01 ronhanson

This is linked to my issue: https://github.com/bw2/ConfigArgParse/issues/217

mathisloevenich avatar Oct 28 '21 10:10 mathisloevenich