Create special types that parse singletons as list for user convenience #39
Labels
enhancement
New feature or request
internals
Technical and subtle issues users are (usually) not aware of
Technically, we probably could provide for
List
andSet
something roughly equivalent to:OneOrList[T] = Union[T, List[T]]
from input point of view, but= List[T]
from instance point of view.That means, it should normalize the input to be a (possibly singleton) list (or set, respectively).
This still would need to play nicely with subtypes, pydantic doing the right thing, type checker not complaining etc, so needs a bit of thinking how to be done right.
It should not be the default, but more of a compatibility hack to extend a "single item" field with a "collection" variant in a backward-compatible way (ideally compatible with
issubtype
, or at least "semantically" and "practically")The text was updated successfully, but these errors were encountered: