Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create special types that parse singletons as list for user convenience #39

Open
apirogov opened this issue Sep 6, 2022 · 0 comments
Open
Labels
enhancement New feature or request internals Technical and subtle issues users are (usually) not aware of

Comments

@apirogov
Copy link
Collaborator

apirogov commented Sep 6, 2022

Technically, we probably could provide for List and Set 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")

@apirogov apirogov added enhancement New feature or request discussion labels Sep 6, 2022
@apirogov apirogov added the internals Technical and subtle issues users are (usually) not aware of label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request internals Technical and subtle issues users are (usually) not aware of
Projects
None yet
Development

No branches or pull requests

1 participant