pypi ConfigArgParse 1.9.0

3 hours ago

Behavior changes

A false value for a flag now overrides lower-priority sources (#365, #105)

Previously, setting a flag (an arg that takes no value, such as store_true, store_false, count or store_const) to false in an environment variable or a higher-priority config file added nothing to the command line, so a true for the same flag in a lower-priority config file still turned it on. Now the false value counts as setting the flag, and lower-priority config files no longer set it. For example, VERBOSE=false now wins over verbose = true in a config file. Args that take a value are unchanged.

A bare -- in a list value is now an error

A list value from a config file or environment variable, such as items = [a, --], used to put a bare -- on the command line, which ended option parsing and turned the user's own command-line options after it into positional args. It now fails with an error that names the key.

Fixes

  • Options after -- on the command line no longer block other sources (#363). In prog -- --level, --level is a positional arg, so environment variables and config files can still set --level.
  • IniConfigParser.serialize() escapes % (#364), so values like %Y-%m-%d read back unchanged, and a saved %(name)s is no longer replaced by another key's value when the file is loaded.
  • Saved config files keep store_false and store_const values (#360). write_config_file() now writes true or false according to whether the flag was given, rather than the value the flag stores.
  • ConfigparserConfigFileParser reads files that only have a [DEFAULT] section (#362), including the files its own serialize() writes.
  • ConfigparserConfigFileParser round trip: values written by serialize() read back the same in more cases (for example strings that look like lists, and list elements containing # or ;), a value that will be cut short by a # or ; comment now produces a warning, and interpolation errors name only the key, not the value, which may be a secret.

Full changelog: v1.8.0...v1.9.0

Don't miss a new ConfigArgParse release

NewReleases is sending notifications on new releases.