Make GConfiguration constructor args effective (factory/variation/runno)#12
Open
zhaozhiwen wants to merge 1 commit into
Open
Make GConfiguration constructor args effective (factory/variation/runno)#12zhaozhiwen wants to merge 1 commit into
zhaozhiwen wants to merge 1 commit into
Conversation
The argparse defaults for --factory/--variation/--run were truthy
("sqlite"/"default"/1), and __init__ resolved each as
`self.args.X if self.args.X else <ctor_arg>`. Because the CLI value was
always truthy (its default), the constructor fallback never fired:
GConfiguration(exp, sys, factory="ascii", variation="run2", runno=5)
silently produced sqlite/default/1 — programmatic configuration was
impossible.
Set the argparse defaults to None so "not provided" is detectable, move
the effective defaults onto the constructor parameters (sqlite/default/1),
and fall back with `is not None`. This keeps the documented CLI-over-
constructor precedence while making constructor arguments actually work.
Verified: constructor args take effect with no CLI flags, bare defaults
resolve to sqlite/default/1, and CLI flags still override the constructor
(Python 3.12).
Fixes gemc#6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The argparse defaults for
--factory/--variation/--runwere truthy ("sqlite"/"default"/1), and__init__resolved each asself.args.X if self.args.X else <ctor_arg>. Because the CLI value was always truthy (its default), the constructor fallback never fired:GConfiguration(exp, sys, factory="ascii", variation="run2", runno=5)silently producedsqlite/default/1— programmatic configuration was impossible.Set the argparse defaults to
Noneso "not provided" is detectable, move the effective defaults onto the constructor parameters, and fall back withis not None. This keeps the documented CLI-over-constructor precedence while making constructor arguments actually work.Validation: constructor args take effect with no CLI flags, bare defaults resolve to sqlite/default/1, and CLI flags still override the constructor (Python 3.12).
Fixes #6