Releases: dry-python/returns
Version 0.17.0
Features
- Python3.10 support
- Enables Pattern Matching support for
Resultcontainers - Enables Pattern Matching support for
Maybecontainer - Enables Pattern Matching support for
IOResultcontainer - Improves
hypothesisplugin, now we detect
when type cannot be constructed and give a clear error message
Version 0.16.0
Features
- Makes
_Nothinga singleton - Refactor
flowfunction to be faster
Bugfixes
- Fixes that
assert_tracewas not catching containers
from@safe-wrapped functions
Misc
- Fixes typos in documentation
Version 0.15.0 aka The initial HKT release
Features
-
Adds Higher Kinded Types partial support
-
Breaking: drops
python3.6support -
Breaking: makes our
mypyplugin not optional, but required! -
Breaking: changes all
RequiresContext-based type arguments order,
previously we used to specify_EnvTypeas the first type argument,
now it is the last one. This is done to respect new HKT rules -
Breaking: renames
.rescueto.lash -
Breaking: removes all old interfaces from
primitives/interfaces.py,
use new typeclasses instead -
Breaking:
Maybeis fully reworked to be lawful -
Breaking: removes
value_orpointfree method,
because it is impossible to express with HKT -
Breaking: removes
.value_or,.unwrap, and.failuremethods
fromFutureResultandRequiresContext-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_successfulis typed:
now we allow anyUnwrappableinterface instances there,
including custom ones -
Breaking: changes
UnwrapFailedErrorconstructor,
now it does accept anUnwrappableinstance instead of aBaseContainer -
Breaking: removes
.fixmethod from all containers,
also removesfixpointfree function -
Breaking: Removes
coalescefunction,
because it is impossible to properly type it -
Breaking: Removes all
Context*based types with.ask()method,
use new.ask()methods on theReader-based containers -
Breaking: Now
FutureandFutureResultcan be awaited multiple times -
Breaking: Removes
.unify()method from several containers,
useunify()pointfree function instead -
Breaking: Removes
.from_iterablemethod from all containers,
instead adds betteriterablessupport,
we now havereturns.iterablesmodule withFoldhelper -
Breaking: Renames property
emptytono_argsof
allRequiresContext-based classes -
Adds new public interfaces: see
returns.interfaces -
Adds
methodspackage with several helpful things inside -
Adds
FutureSuccessandFutureFailureunit functions
to be similar toResultandIOResult -
Adds
.swapmethod toResult,IOResult,FutureResult,
and other result based containers -
Adds
.modify_envmethod to allRequiresContext*types -
Adds
.rescuetoMaybe -
Adds
.equalsmethods to types that can be compared directly:
Result,Maybe,IO,IOResult -
Adds missing
from_requires_context_future_resulttoRequiresContext -
Adds
.from_optionaland.bind_optionaltoMaybecontainer -
Adds
__slots__toUnwrapFailedErrorwithhalted_container -
Changes
flattento work withKindNand any possible container -
Adds a helper to test traces to our
pytestplugin -
Adds
condfunction topointfreeandmethodspackages -
Adds
compose_resultHKT method and pointfree function -
Adds
unifyHKT pointfree function -
Adds
bimappointfree function -
Adds
unwrap_or_failurefunction tomethodspackage -
Adds
collect_tracehelper function for better development experience -
Adds
hypothesisintergration and pre-defined "monad laws as values" -
Adds
assert_equalmethod to ourpytestplugin
Bugfixes
- Breaking: fixes serious typing issue and changes how
flowworks - Breaking: fixes serious typing issue and changes how
pipeworks,
now it has a hard limit of 20 parameters - Fixes that
RequiresContextFutureResultwas not supported bypytestplugin - Fixes incorrect
partialbehaviour in an edge case, #618 - Fixes that
.applymethod ofIOResultwas working incorrectly,
it was returningIOFailure(2)
as a result ofIOFailure(1).apply(IOFailure(2)) - Fixes bug that
safe(tap(...))was revealing invalid types sometimes
Misc
- Adds a lot of new typetests
- Checks that now all math laws are checked for all types
- Changes docs structure, adds new
Interfaces,HKT, andMethodspages - Changed
__str__method inBaseContainerclass to__repr__method - Adds
Quickstartguide
Version 0.14.0
Special thanks to:
- @orsinium
- @thedrow
- @thepabloaguilar
- and other (code and ideas) contributors
for making this release possible. You are awesome!
Announcement: https://sobolevn.me/2020/06/how-async-should-have-been
Features
-
Breaking: renames mypy plugin from
decorator_plugintoreturns_plugin
because of a complete rewrite and lots of new features -
Breaking: changes
@safe,@impure,impure_safe,@maybesemantics:
they do not work withasyncfunctions anymore;
now you are forced to useFutureand its helpers
to work withasyncfunctions -
Breaking: renames
Maybe.newtoMaybe.from_value.
Because all our other containers support this protocol.
OnlyMaybewas 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*_squashconverters, they are removed -
Breaking: renamed
InstanceabletoApplicative -
Breaking: changes
.from_ioand.from_failed_ioofIOResult
to returnAnyinstead ofNoReturnunfilled type -
Breaking: removes
.liftand.lift_*methods from all containers,
usemap_,bind_result,bind_io, and other pointfree helpers instead -
Breaking: removes
@pipelinefunction. It was a mistake:
it does not work with mixed container types,
it does not type failures properly,
it does not work withIOandFuture,
it enforces to write imperative code in a functional codebase.
Useflowinstead -
Adds typed
partialandcurrymypy plugins! -
Adds typed
flowplugin, now it can accept any number of arguments,
it now also has excelent type inference -
Adds typed
pipeplugin, now it can accept any number of arguments,
it now also has good type inference -
Adds
managedpipeline function that is useful
for working with stateful computations -
Adds typed
map_,fix, andaltpointfree functions -
Adds typed
bind_result,bind_io,bind_ioresult,
bind_context,bind_context_result,bind_future,
bind_async, andbind_awaitablepointfree functions -
Adds typed
bind_async_futureandbind_async_future_result
pointfree functions -
Adds typed
unifypointfree function -
Adds typed
applypointfree function -
Adds typed
value_orpointfree function -
Adds
pytestplugin with the ability to tests error handling -
Adds
Futurecontainer to easily work withasyncfunctions -
Adds
FutureResultcontainer to easily work
withasyncfunction that might fail -
Adds
RequiresContextFutureResultcontainer -
Adds
ReaderFutureResultalias forRequiresContextFutureResult -
Adds
RequiresContextFutureResultEandReaderFutureResultEaliases -
Adds
Future,FutureResultandRequiresContextFutureResult
support for all existing pointfree functions -
Adds
bind_iomethod toIOResult -
Adds
bind_iomethod toRequiresContextIOResult -
Adds
or_elsemethod toMaybe -
Adds
.from_ioand.from_failed_iotoRequiresContextIOResult -
Syncs naming in
from_*methods, now all parameters are namedinner_value -
Adds
not_composition helper -
Adds
flattensupport forFuture,
FutureResultandRequiresContextFutureResult -
Adds
__copy__and__deepcopy__magic methods toImmutableclass -
Speeds up
is_successfulfunction -
Makes all
Contextcontext helpers abstract,
so you cannot create new instances of this class,
also adds__slots__to these classes -
Improves
RequiresContext*types withNoDepswhere it is logically true
Bugfixes
- Fixes that
@safedecorator was generating incorrect signatures
for functions withAny - Fixes that
.rescue()ofRequiresContextResultwas returningAny - Fixes that
.rescue()ofRequiresContextIOResultwas returningAny - Fixes that
RequiresContextResultandRequiresContextIOResult
were notfinal - Fixes that
ImmutableStateErrorwas not a subclass ofAttributeError - Fixes that
IOResultwas not showingstrrepresentation
of wrappedinner_value
Misc
- Replaces
pytest-asynciowithanyioplugin,
now we test compatibility with any IO stack:asyncio,trio,curio - Updates lots of dependencies
- Adds lots of new tests
- Updates lots of docs
- Removes "IO marker" name from docs in favor for "IO container",
it is not special at all. Why would we call it differently?
Version 0.13.0
Announcing article: https://sobolevn.me/2020/02/typed-functional-dependency-injection
Features
-
Breaking: renames
jointoflatten, sorry! -
Breaking: renames
boxtobindand moves it toreturns.pointfree -
Breaking: removes
Maybe.rescueandMaybe.fixmethods -
Breaking: renames
io_squashtosquash_io
and moves it toreturns.converters -
Breaking: moves all interfaces from
returns.primitives.containerto
returns.primitives.interfaces -
Adds
rescuepointfree function -
Adds
ResultEalias forResult[..., Exception] -
Adds
RequiresContextcontainer andContexthelper class -
Adds
RequiresContextsupport forbindpointfree function -
Adds
RequiresContextsupport forflattenfunction -
Adds
RequiresContextResultcontainer -
Adds
RequiresContextResultEalias -
Adds
ReaderResultandReaderResultEaliases
forRequiresContextResult[..., ..., Exception] -
Adds
RequiresContextResultsupport forbindandrescue -
Adds
RequiresContextResultsupport forflatten -
Adds
IOResulthelper to work better withIO[Result[a, b]] -
Adds
IOResultEalias forIOResult[a, Exception] -
Adds
IOResultsupport forbind -
Adds
IOResultsupport forflatten -
Adds
IOResultsupport for@pipeline -
Adds
IOResultsupport forcoalesce -
Adds
IOResultsupport foris_successful -
Adds
RequiresContextIOResultcontainer -
Adds
RequiresContextIOResultEalias -
Adds
ReaderIOResultandReaderIOResultEaliases
forRequiresContextIOResult[..., ..., Exception] -
Adds
RequiresContextIOResultsupport forbindandrescue -
Adds
RequiresContextIOResultsupport forflatten -
Adds
Result.lift,Maybe.lift,RequiresContext.lift,
andRequiresContextResult.liftfunctions in addition toIO.lift -
Adds
Immutableprimitive type -
Adds
Unitableprotocol and.from_success()and.from_failure()
methods for allResultrealted classes -
Adds
Instanceableprotocol and.from_value()method
forIOandRequiresContext -
Adds
flowfunction, which is similar topipe -
Adds
swapcoverter forResultandIOResult -
Adds
squash_contextfunction to squashRequiresContextsimilar toIO
Bugfixes
- Now
SuccessandFailure(bothioand pure) returnAnyand notNoReturn - Fixes how
flattenworks, also adds more tests and docs aboutFailurecase - Fixes
Unwrappabletype being parametrized with only oneTypeVar - Changes
SuccessandFailureto returnAnyinstead ofNoReturn
Misc
- Updates
poetryversion intravis - Imporves
pipedocs withlambdaandGenericproblem - Improves docs in several places
- Now examples in docs tries to be docstests where possible
- Changes how tests are checked with
mypyin CI
Version 0.12.0
Features
- Breaking: now
@pipelinerequires a container type when created:
@pipeline(Result)or@pipeline(Maybe) MaybeandResultnow hassuccess_typeandfailure_typealiases- Adds
Result.unifyutility method for better error type composition - We now support
dry-python/classesas a first-class citizen - Adds
io_squashto squash severalIOcontainers into one container
with a tuple inside, currently works with9containers max at a time - Adds
untapfunction which does convert return type toNone
Bugfixes
- Fixes that containers were not usable with
multiprocessing - Changes the inheritance order, now
BaseContaineris the first child - Fixes that
Nothinghad incorrect docstrings
Misc
- Now
generatedpackage is protected - Updates
poetryto1.0
Version 0.11.0
Features
- Breaking: now
pipe()does not require argument to be the first value,
instead it is required to use:pipe(f1, f2, f3, f4)(value) - Breaking: dropped everything from
returns/__init__.py,
because we now have quite a lot of stuff - Breaking: dropped support of zero argument functions for
Nothing.fix - Breaking: dropped support of zero argument functions for
Nothing.rescue Maybenow has.failure()to match the same API asResult- Adds
identityfunction - Adds
tapfunction - Now
pipeallows to pipe 8 steps - Adds
coalesce_resultandcoalesce_maybecoverters
Bugfixes
- Fixes that code inside
.fixand.rescueofMaybemight be called twice
Misc
- Now all methods have doctests
- Updates docs about
Successand_Success,Failureand_Failure - Updates docs about
@pipeline - Typechecks async functions and decorators inside
typesafety/tests
Version 0.10.0
Features
- Breaking:
python>=3.7,<=3.7.2are not supported anymore,
because of a bug insidetypingmodule - Breaking: Now
binddoes not change the type of an error - Breaking: Now
rescuedoes not change the type of a value - Breaking: Renames
map_failuretoalt - Adds
box()function with the ability
to box function for direct container composition like:
a -> Container[b]toContainer[a] -> Container[b] - Adds
IO.lift()function to lifta -> atoIO[a] -> IO[a] - Adds
pipe()function topipeline.py - Adds
__hash__()magic methods to all containers
Bugfixes
- Changes
AnytoNoReturninSuccessandFailure - Now all type parameters in
Result,Maybe, andIOare covariant
Misc
- Massive docs rewrite
- Updates
mypyversion - Updates
wemake-python-styleguideand introducesnitpick - Updates
pytest-plugin-mypy, all tests now useyml
Version 0.9.0
Features
- Provides a bunch of primitive interfaces to write your own containers
- Adds
.map_failure()method - Adds
join()function to join nested containers
Bugfixes
- Fixes type of
Maybe.fixandMaybe.rescueto work with bothlambda: 1andlambda _: 1
Misc
- Improves
README
Version 0.8.0
Features
- Reintroduces the
Maybemonad, typed! - Introduces converters from one type to another
- Adds
mypyplugin to type decorators - Complete rewrite of
Resulttypes - Partial API change, now
SuccessandFailureare not types, but functions - New internal types introduced:
FixableContainerandValueUnwrapContainer
Bugfixes
- Fixes issue when you could return
IOcontainer fromResult.bind - Fixes
@pipelinereturn type
Misc
- Reapplied all types to
.pyfiles - Improved docs about
IOandContainerconcept - Adds docs about container composition
- Moves from
AlphatoBeta