soldni / springs

A set of utilities to turn Dataclasses into useful configuration managers.
https://springs.soldaini.net
MIT License
11 stars 2 forks source link

nargs=1 in argparse produces list instead of value #14

Closed volksen closed 1 year ago

volksen commented 1 year ago

Hi,

thank for your great package. Exactly what I was looking for. I think, I found a bug in commandline.py in the CliFlags class You are using nargs=1 in Flags Save and log-level which produces a list instead of the value itself. (see: https://docs.python.org/3/library/argparse.html#nargs)

When I run the following code on python 3.10.6 with the latest argparse and springs: python app.py -l WARNING I get the following error: TypeError: unhashable type: 'list' Same happens with option -s for save.

Removing nargs=1 fixes the issue in my opinion.

soldni commented 1 year ago

Thank you @volksen for reporting this issue! Just fixed it in mainline and released 1.12.2 on PyPi.