bw2 / ConfigArgParse

A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.
MIT License
730 stars 121 forks source link

abbreviated options are ignored #134

Open ihadanny opened 5 years ago

ihadanny commented 5 years ago

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

ronhanson commented 5 years ago

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

mathisloevenich commented 3 years ago

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