django-returns: Meaningful Django utils based on Functional Programming

Looking for feedback :slightly_smiling_face:

django-returns is a tiny layer on top of Django’s ORM that lets you opt into returns containers when you want explicit success/failure return types instead of exceptions.

Can mypy enforce that you don’t just ignore the return value and/or error type?

In strict mode, yes.

Example:

author = Author(name="Test Author")
result = author.save_result()
assert result.name

Produces:

error: Item "Success[None]" of "Success[None] | Failure[Exception]" has no attribute "name"  [union-attr]
error: Item "Failure[Exception]" of "Success[None] | Failure[Exception]" has no attribute "name"  [union-attr]

For the error type, I didn’t get to specifying which exact Exceptions each Failure returns yet, if that’s what you mean.