hey folks, is there a way to have an optional Mult...
# plugins
c
hey folks, is there a way to have an optional MultipleSourcesField?
OptionalSingleSourcesField
implements optionality by setting
expected_num_files: ClassVar[int | range] = range(0, 2)
, but just putting a large number (or the largest number) as the upper bound seems like a hack. Having no files matching the glob yields "Unmatched glob from ..."
I can also just leave the
default
off, which I think in this case makes more sense, but isn't a fully general solution for "might have any number of optional files including 0"
c
here’s how I’ve done this for the synthetic lockfiles (so no generic support, but “easy” to do) https://github.com/pantsbuild/pants/blob/8d0a4ce96a370162338e832eae8d154a3f04da1e/src/python/pants/core/target_types.py#L887-L897