From the review of #2:
parser.setdefaults work, however i'd like to update/use Argument class to handle this behaviour.
Current state
src/funcsort/main.py declares its flags declaratively:
sort_module = Argument("sort-module", action=Actions.STORE_BOOL, default=True, ...)
respect_dependencies = Argument("respect-dependencies", action=Actions.STORE_BOOL, default=True, ...)
but those default=True values are effectively dead, because line 48 overrides them:
parser.set_defaults(check=False, diff=False, recursive=True, sort_module=None, respect_dependencies=None)
The None sentinel is deliberate: it is what lets the config file win unless the user passes the flag explicitly (main.py:85-86). STORE_BOOL registers a --flag/--no-flag pair, and there is currently no way to express "unset" through Argument alone — hence the set_defaults escape hatch.
Desired state
The fix belongs in the herogold.argparse package: Argument / Actions.STORE_BOOL should support a tri-state default natively (True / False / unset), so main.py can drop parser.set_defaults entirely and keep the declarative _Cli block as the single source of truth.
Follow-up
When this is solved, re-review the config/CLI merge lines:
If we can simplify/couple args and settings, this line must be reviewed again.
main.py:85-86:
sort_module = settings.sort_module if args.sort_module is None else args.sort_module
respect_dependencies = settings.respect_dependencies if args.respect_dependencies is None else args.respect_dependencies
Related: #4 (config declaration boilerplate).
From the review of #2:
Current state
src/funcsort/main.pydeclares its flags declaratively:but those
default=Truevalues are effectively dead, because line 48 overrides them:The
Nonesentinel is deliberate: it is what lets the config file win unless the user passes the flag explicitly (main.py:85-86).STORE_BOOLregisters a--flag/--no-flagpair, and there is currently no way to express "unset" throughArgumentalone — hence theset_defaultsescape hatch.Desired state
The fix belongs in the herogold.argparse package:
Argument/Actions.STORE_BOOLshould support a tri-state default natively (True/False/ unset), somain.pycan dropparser.set_defaultsentirely and keep the declarative_Cliblock as the single source of truth.Follow-up
When this is solved, re-review the config/CLI merge lines:
main.py:85-86:Related: #4 (config declaration boilerplate).