do-notation and type aliasesNone values gracefullydo notationattempt decorator__slots__ correctness with slotscheckπ New Year Release! π
typing_extensions>=4.0mypy>=0.930@safe, @maybe, @future, etc.
Because we now use ParamSpec type to properly type decorators__slots__ not being set properly in containers and their base classes__slots__ not being set properly in containers and their base classesResult containersMaybe containerIOResult containerhypothesis plugin, now we detect
when type cannot be constructed and give a clear error message@safe will handle_Nothing a singletonflow function to be fasterassert_trace was not catching containers
from @safe-wrapped functionsβ Adds Higher Kinded Types partial support
π₯ Breaking : drops python3.6 support
π₯ Breaking : makes our mypy plugin not optional, but required!
π₯ Breaking : changes all RequiresContext-based type arguments order,
previously we used to specify _EnvType as the first type argument,
now it is the last one. This is done to respect new HKT rules
π₯ Breaking : renames .rescue to .lash
π₯ Breaking : removes all old interfaces from primitives/interfaces.py,
π use new typeclasses instead
π₯ Breaking : Maybe is fully reworked to be lawful
π₯ Breaking : removes value_or pointfree method,
because it is impossible to express with HKT
π₯ Breaking : removes .value_or, .unwrap, and .failure methods
from FutureResult and RequiresContext-based types,
π» because we do require these methods to raise an exception on failure,
π» but these methods were lazy and did not raise the required exception
π₯ Breaking : changes how is_successful is typed:
now we allow any Unwrappable interface instances there,
including custom ones
π₯ Breaking : changes UnwrapFailedError constructor,
now it does accept an Unwrappable instance instead of a BaseContainer
π₯ Breaking : removes .fix method from all containers,
π also removes fix pointfree function
π₯ Breaking : Removes coalesce function,
because it is impossible to properly type it
π₯ Breaking : Removes all Context* based types with .ask() method,
π use new .ask() methods on the Reader-based containers
π₯ Breaking : Now Future and FutureResult can be awaited multiple times
π₯ Breaking : Removes .unify() method from several containers,
π use unify() pointfree function instead
π₯ Breaking : Removes .from_iterable method from all containers,
π instead adds better iterables support,
we now have returns.iterables module with Fold helper
π₯ Breaking : Renames property empty to no_args of
all RequiresContext-based classes
β Adds new public interfaces: see returns.interfaces
β Adds methods package with several helpful things inside
β Adds FutureSuccess and FutureFailure unit functions
to be similar to Result and IOResult
β Adds .swap method to Result, IOResult, FutureResult,
and other result based containers
Adds .modify_env method to all RequiresContext* types
β Adds .rescue to Maybe
β Adds .equals methods to types that can be compared directly:
Result, Maybe, IO, IOResult
Adds missing from_requires_context_future_result to RequiresContext
Adds .from_optional and .bind_optional to Maybe container
Adds __slots__ to UnwrapFailedError with halted_container
π Changes flatten to work with KindN and any possible container
β Adds a helper to test traces to our pytest plugin
β Adds cond function to pointfree and methods packages
β Adds compose_result HKT method and pointfree function
β Adds unify HKT pointfree function
β Adds bimap pointfree function
Adds unwrap_or_failure function to methods package
β Adds collect_trace helper function for better development experience
β Adds hypothesis intergration and pre-defined "monad laws as values"
β Adds assert_equal method to our pytest plugin
flow workspipe works,RequiresContextFutureResult was not supported by pytest pluginpartial behaviour in an edge case, #618 .apply method of IOResult was working incorrectly,IOFailure(2)IOFailure(1).apply(IOFailure(2))safe(tap(...)) was revealing invalid types sometimesInterfaces, HKT, and Methods pages__str__ method in BaseContainer class to __repr__ methodQuickstart guideSpecial thanks to:
Announcement: https://sobolevn.me/2020/06/how-async-should-have-been
π₯ Breaking : renames mypy plugin from decorator_plugin to returns_plugin
because of a complete rewrite and lots of new features
π₯ Breaking : changes @safe, @impure, impure_safe, @maybe semantics:
they do not work with async functions anymore;
now you are forced to use Future and its helpers
to work with async functions
π₯ Breaking : renames Maybe.new to Maybe.from_value.
π Because all our other containers support this protocol.
Only Maybe was different, sorry for that!
π₯ Breaking : renames .from_success() to .from_value(),
there's no need in two separate methods
π₯ Breaking : renames .from_successful_io() to .from_io(),
there's no need in two separate methods
π₯ Breaking : renames .from_successful_context() to .from_context(),
there's no need in two separate methods
π₯ Breaking : since we now support .apply() method,
π there's no more need in *_squash converters, they are removed
π₯ Breaking : renamed Instanceable to Applicative
π₯ Breaking : changes .from_io and .from_failed_io of IOResult
to return Any instead of NoReturn unfilled type
π₯ Breaking : removes .lift and .lift_* methods from all containers,
use map_, bind_result, bind_io, and other pointfree helpers instead
π₯ Breaking : removes @pipeline function. It was a mistake:
it does not work with mixed container types,
it does not type failures properly,
it does not work with IO and Future,
it enforces to write imperative code in a functional codebase.
π Use flow instead
β Adds typed partial and curry mypy plugins!
β Adds typed flow plugin, now it can accept any number of arguments,
it now also has excelent type inference
β Adds typed pipe plugin, now it can accept any number of arguments,
it now also has good type inference
β Adds managed pipeline function that is useful
for working with stateful computations
β Adds typed map_, fix, and alt pointfree functions
Adds typed bind_result, bind_io, bind_ioresult,
bind_context, bind_context_result, bind_future,
bind_async, and bind_awaitable pointfree functions
Adds typed bind_async_future and bind_async_future_result
pointfree functions
β Adds typed unify pointfree function
β Adds typed apply pointfree function
β Adds typed value_or pointfree function
β Adds pytest plugin with the ability to tests error handling
β Adds Future container to easily work with async functions
β Adds FutureResult container to easily work
with async function that might fail
β Adds RequiresContextFutureResult container
β Adds ReaderFutureResult alias for RequiresContextFutureResult
β Adds RequiresContextFutureResultE and ReaderFutureResultE aliases
β Adds Future, FutureResult and RequiresContextFutureResult
π support for all existing pointfree functions
β Adds bind_io method to IOResult
β Adds bind_io method to RequiresContextIOResult
β Adds or_else method to Maybe
Adds .from_io and .from_failed_io to RequiresContextIOResult
Syncs naming in from_* methods, now all parameters are named inner_value
β Adds not_ composition helper
β Adds flatten support for Future,
FutureResult and RequiresContextFutureResult
Adds __copy__ and __deepcopy__ magic methods to Immutable class
Speeds up is_successful function
π Makes all Context context helpers abstract,
so you cannot create new instances of this class,
also adds __slots__ to these classes
π Improves RequiresContext* types with NoDeps where it is logically true
@safe decorator was generating incorrect signaturesAny.rescue() of RequiresContextResult was returning Any.rescue() of RequiresContextIOResult was returning AnyRequiresContextResult and RequiresContextIOResultfinalImmutableStateError was not a subclass of AttributeErrorIOResult was not showing str representationinner_valuepytest-asyncio with anyio plugin,asyncio, trio, curioAnnouncing article: https://sobolevn.me/2020/02/typed-functional-dependency-injection
π₯ Breaking : renames join to flatten, sorry!
π₯ Breaking : renames box to bind and moves it to returns.pointfree
π₯ Breaking : removes Maybe.rescue and Maybe.fix methods
π₯ Breaking : renames io_squash to squash_io
π and moves it to returns.converters
π₯ Breaking : moves all interfaces from returns.primitives.container to
returns.primitives.interfaces
β Adds rescue pointfree function
β Adds ResultE alias for Result[..., Exception]
β Adds RequiresContext container and Context helper class
β Adds RequiresContext support for bind pointfree function
β Adds RequiresContext support for flatten function
β Adds RequiresContextResult container
β Adds RequiresContextResultE alias
β Adds ReaderResult and ReaderResultE aliases
π» for RequiresContextResult[..., ..., Exception]
β Adds RequiresContextResult support for bind and rescue
β Adds RequiresContextResult support for flatten
β Adds IOResult helper to work better with IO[Result[a, b]]
β Adds IOResultE alias for IOResult[a, Exception]
β Adds IOResult support for bind
β Adds IOResult support for flatten
β Adds IOResult support for @pipeline
β Adds IOResult support for coalesce
β Adds IOResult support for is_successful
β Adds RequiresContextIOResult container
β Adds RequiresContextIOResultE alias
β Adds ReaderIOResult and ReaderIOResultE aliases
π» for RequiresContextIOResult[..., ..., Exception]
β Adds RequiresContextIOResult support for bind and rescue
β Adds RequiresContextIOResult support for flatten
β Adds Result.lift, Maybe.lift, RequiresContext.lift,
and RequiresContextResult.lift functions in addition to IO.lift
β Adds Immutable primitive type
Adds Unitable protocol and .from_success() and .from_failure()
methods for all Result realted classes
β Adds Instanceable protocol and .from_value() method
for IO and RequiresContext
β Adds flow function, which is similar to pipe
β Adds swap coverter for Result and IOResult
β Adds squash_context function to squash RequiresContext similar to IO
Success and Failure (both io and pure) return Any and not NoReturnflatten works, also adds more tests and docs about Failure caseUnwrappable type being parametrized with only one TypeVarSuccess and Failure to return Any instead of NoReturnpoetry version in travispipe docs with lambda and Generic problemmypy in CI@pipeline requires a container type when created:@pipeline(Result) or @pipeline(Maybe)Maybe and Result now has success_type and failure_type aliasesResult.unify utility method for better error type compositiondry-python/classes as a first-class citizenio_squash to squash several IO containers into one container9 containers max at a timeuntap function which does convert return type to NonemultiprocessingBaseContainer is the first childNothing had incorrect docstringsgenerated package is protectedpoetry to 1.0