That was fun I was actually planning on using this code, but turns out a much better and more mature option already exists. https://github.com/dry-python/returns