bw2 / ConfigArgParse

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

Handle pathlib Path used as default_config_files #293

Open YoannQDQ opened 4 months ago

YoannQDQ commented 4 months ago

Having Path objects in the default_config_files make it impossible to display the help (-h) message

from pathlib import Path

import configargparse

p = configargparse.ArgumentParser(default_config_files=[Path("~/.my_settings.ini")])
p.add("geotiff")
p.add("--flag", help="Flag that can be set in the config file")

options = p.parse_args()

Running the above snippet with -h will trigger a TypeError: sequence item 0: expected str instance, PosixPath found.

This PR just casts the default_config_files to str in the help message.