returns
returns copied to clipboard
Consider adding `NonEmptyList`
Currently, Python does not have any valid type elements to work with lists.
And while List itself is good enough for collections and other things, sometimes we need to explicitly mark some list to have at least one argument.
Related: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
@sobolevn i would like to contribute. But should this type be a part of returns? I came here googling for NonEmptyList type and definitely didn't expect to find something related in returns package :grin:
You can create a new package :)
@sobolevn well, actually if the point of returns is to "Make your functions return something meaningful, typed, and safe!", then i guess it makes sense to have NonEmptyList here. Is it ok if i put it somewhere in returns.primitives.types? :thinking:
I found this issue via web search. The feature request is valid, but rather than every developer will maintains own type hints, I think it makes sense to collaborate with maintainers of an existing solution, e.g. https://github.com/annotated-types/annotated-types or Pydantic.
@sobolevn maybe returns is not the place for this type! Thinking about what we have now it doesn't make much sense on adding a NonEmptyList type just to provide our implementation while people can rely in specific libraries for that like phaton-types NonEmpty