Is it better to add lots of fields, or have a few ...
# plugins
p
Is it better to add lots of fields, or have a few dict args with some light post init validation?
w
In terms of targets?
For my targets (assuming that’s what you’re referring to), I don’t know what the “best” idea is, but as it’s a public user API, my preference is single item fields (like, 1 key, with a string/int/list value), with defaults if possible, with unique help lines. I find that dicts have a weird experience on the command line, and even in build files - where they’re harder to reason about, harder to type, and just more convoluted. The exception to that is when you want unknown stuff added by the user, and don’t want to limit them (e.g.
envvars
)
p
Yes in terms of targets
What about if some of the fields are only valid based on another field? Eg, one field on the target is like a
mode
, and then the fields that are valid change based on that? I'm wondering about creating 4
PythonArtifact
style classes for use with 1 target type, or 4 distinct target types, or just include all the fields in one target type and ignore anything that doesn't apply?
Now that I've typed that, I think separate target types is probably best.
w
I’m trying to think if we have something like that - at the very least, we’d hopefully have some validations
But yeah, in that case, I’d personally probably have multiple targets, but maybe there’s a canonical less-boilerplatey way