DEV Community

Discussion on: The Maybe data type in JavaScript

Collapse
 
sobolevn profile image
Nikita Sobolev

If you ever use Python, we also have Maybe, Either, and other monads (compatible with mypy and type-hints): github.com/dry-python/returns

GitHub logo dry-python / returns

Make your functions return something meaningful, typed, and safe!

Returns logo


Build Status Coverage Status Documentation Status Python Version wemake-python-styleguide Checked with mypy


Make your functions return something meaningful, typed, and safe!

Features

  • Provides a bunch of primitives to write declarative business logic
  • Enforces better architecture
  • Fully typed with annotations and checked with mypy, PEP561 compatible
  • Has a bunch of helpers for better composition
  • Pythonic and pleasant to write and to read 🐍
  • Support functions and coroutines, framework agnostic
  • Easy to start: has lots of docs, tests, and tutorials

Installation

pip install returns

You might also want to configure mypy correctly and install our plugin to fix this existing issue:

# In setup.cfg or mypy.ini:
[mypy]
plugins =
  returns.contrib.mypy.decorator_plugin

We also recommend to use the same mypy settings we use.

Make sure you know how to get started, check out our docs!

Contents

Collapse
 
aminnairi profile image
Amin • Edited

Whoa! That's so cool!!!

I'm nowhere near a good Python developer unfortunately, but I'll keep that repo in case I start getting really into Python for my next big project.

Thanks!