Releases: dry-python/returns
Version 0.15.0 aka The initial HKT release
Features
-
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
fromFutureResult
andRequiresContext
-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 anyUnwrappable
interface instances there,
including custom ones -
Breaking: changes
UnwrapFailedError
constructor,
now it does accept anUnwrappable
instance instead of aBaseContainer
-
Breaking: removes
.fix
method from all containers,
also removesfix
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 theReader
-based containers -
Breaking: Now
Future
andFutureResult
can be awaited multiple times -
Breaking: Removes
.unify()
method from several containers,
useunify()
pointfree function instead -
Breaking: Removes
.from_iterable
method from all containers,
instead adds betteriterables
support,
we now havereturns.iterables
module withFold
helper -
Breaking: Renames property
empty
tono_args
of
allRequiresContext
-based classes -
Adds new public interfaces: see
returns.interfaces
-
Adds
methods
package with several helpful things inside -
Adds
FutureSuccess
andFutureFailure
unit functions
to be similar toResult
andIOResult
-
Adds
.swap
method toResult
,IOResult
,FutureResult
,
and other result based containers -
Adds
.modify_env
method to allRequiresContext*
types -
Adds
.rescue
toMaybe
-
Adds
.equals
methods to types that can be compared directly:
Result
,Maybe
,IO
,IOResult
-
Adds missing
from_requires_context_future_result
toRequiresContext
-
Adds
.from_optional
and.bind_optional
toMaybe
container -
Adds
__slots__
toUnwrapFailedError
withhalted_container
-
Changes
flatten
to work withKindN
and any possible container -
Adds a helper to test traces to our
pytest
plugin -
Adds
cond
function topointfree
andmethods
packages -
Adds
compose_result
HKT method and pointfree function -
Adds
unify
HKT pointfree function -
Adds
bimap
pointfree function -
Adds
unwrap_or_failure
function tomethods
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 ourpytest
plugin
Bugfixes
- Breaking: fixes serious typing issue and changes how
flow
works - Breaking: fixes serious typing issue and changes how
pipe
works,
now it has a hard limit of 20 parameters - Fixes that
RequiresContextFutureResult
was not supported bypytest
plugin - Fixes incorrect
partial
behaviour in an edge case, #618 - Fixes that
.apply
method ofIOResult
was 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
, andMethods
pages - Changed
__str__
method inBaseContainer
class to__repr__
method - Adds
Quickstart
guide
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_plugin
toreturns_plugin
because of a complete rewrite and lots of new features -
Breaking: changes
@safe
,@impure
,impure_safe
,@maybe
semantics:
they do not work withasync
functions anymore;
now you are forced to useFuture
and its helpers
to work withasync
functions -
Breaking: renames
Maybe.new
toMaybe.from_value
.
Because all our other containers support this protocol.
OnlyMaybe
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
toApplicative
-
Breaking: changes
.from_io
and.from_failed_io
ofIOResult
to returnAny
instead ofNoReturn
unfilled type -
Breaking: removes
.lift
and.lift_*
methods from all containers,
usemap_
,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 withIO
andFuture
,
it enforces to write imperative code in a functional codebase.
Useflow
instead -
Adds typed
partial
andcurry
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
, andalt
pointfree functions -
Adds typed
bind_result
,bind_io
,bind_ioresult
,
bind_context
,bind_context_result
,bind_future
,
bind_async
, andbind_awaitable
pointfree functions -
Adds typed
bind_async_future
andbind_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 withasync
functions -
Adds
FutureResult
container to easily work
withasync
function that might fail -
Adds
RequiresContextFutureResult
container -
Adds
ReaderFutureResult
alias forRequiresContextFutureResult
-
Adds
RequiresContextFutureResultE
andReaderFutureResultE
aliases -
Adds
Future
,FutureResult
andRequiresContextFutureResult
support for all existing pointfree functions -
Adds
bind_io
method toIOResult
-
Adds
bind_io
method toRequiresContextIOResult
-
Adds
or_else
method toMaybe
-
Adds
.from_io
and.from_failed_io
toRequiresContextIOResult
-
Syncs naming in
from_*
methods, now all parameters are namedinner_value
-
Adds
not_
composition helper -
Adds
flatten
support forFuture
,
FutureResult
andRequiresContextFutureResult
-
Adds
__copy__
and__deepcopy__
magic methods toImmutable
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 withNoDeps
where it is logically true
Bugfixes
- Fixes that
@safe
decorator was generating incorrect signatures
for functions withAny
- Fixes that
.rescue()
ofRequiresContextResult
was returningAny
- Fixes that
.rescue()
ofRequiresContextIOResult
was returningAny
- Fixes that
RequiresContextResult
andRequiresContextIOResult
were notfinal
- Fixes that
ImmutableStateError
was not a subclass ofAttributeError
- Fixes that
IOResult
was not showingstr
representation
of wrappedinner_value
Misc
- Replaces
pytest-asyncio
withanyio
plugin,
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
join
toflatten
, sorry! -
Breaking: renames
box
tobind
and moves it toreturns.pointfree
-
Breaking: removes
Maybe.rescue
andMaybe.fix
methods -
Breaking: renames
io_squash
tosquash_io
and moves it toreturns.converters
-
Breaking: moves all interfaces from
returns.primitives.container
to
returns.primitives.interfaces
-
Adds
rescue
pointfree function -
Adds
ResultE
alias forResult[..., Exception]
-
Adds
RequiresContext
container andContext
helper class -
Adds
RequiresContext
support forbind
pointfree function -
Adds
RequiresContext
support forflatten
function -
Adds
RequiresContextResult
container -
Adds
RequiresContextResultE
alias -
Adds
ReaderResult
andReaderResultE
aliases
forRequiresContextResult[..., ..., Exception]
-
Adds
RequiresContextResult
support forbind
andrescue
-
Adds
RequiresContextResult
support forflatten
-
Adds
IOResult
helper to work better withIO[Result[a, b]]
-
Adds
IOResultE
alias forIOResult[a, Exception]
-
Adds
IOResult
support forbind
-
Adds
IOResult
support forflatten
-
Adds
IOResult
support for@pipeline
-
Adds
IOResult
support forcoalesce
-
Adds
IOResult
support foris_successful
-
Adds
RequiresContextIOResult
container -
Adds
RequiresContextIOResultE
alias -
Adds
ReaderIOResult
andReaderIOResultE
aliases
forRequiresContextIOResult[..., ..., Exception]
-
Adds
RequiresContextIOResult
support forbind
andrescue
-
Adds
RequiresContextIOResult
support forflatten
-
Adds
Result.lift
,Maybe.lift
,RequiresContext.lift
,
andRequiresContextResult.lift
functions in addition toIO.lift
-
Adds
Immutable
primitive type -
Adds
Unitable
protocol and.from_success()
and.from_failure()
methods for allResult
realted classes -
Adds
Instanceable
protocol and.from_value()
method
forIO
andRequiresContext
-
Adds
flow
function, which is similar topipe
-
Adds
swap
coverter forResult
andIOResult
-
Adds
squash_context
function to squashRequiresContext
similar toIO
Bugfixes
- Now
Success
andFailure
(bothio
and pure) returnAny
and notNoReturn
- Fixes how
flatten
works, also adds more tests and docs aboutFailure
case - Fixes
Unwrappable
type being parametrized with only oneTypeVar
- Changes
Success
andFailure
to returnAny
instead ofNoReturn
Misc
- Updates
poetry
version intravis
- Imporves
pipe
docs withlambda
andGeneric
problem - Improves docs in several places
- Now examples in docs tries to be docstests where possible
- Changes how tests are checked with
mypy
in CI
Version 0.12.0
Features
- Breaking: now
@pipeline
requires a container type when created:
@pipeline(Result)
or@pipeline(Maybe)
Maybe
andResult
now hassuccess_type
andfailure_type
aliases- Adds
Result.unify
utility method for better error type composition - We now support
dry-python/classes
as a first-class citizen - Adds
io_squash
to squash severalIO
containers into one container
with a tuple inside, currently works with9
containers max at a time - Adds
untap
function which does convert return type toNone
Bugfixes
- Fixes that containers were not usable with
multiprocessing
- Changes the inheritance order, now
BaseContainer
is the first child - Fixes that
Nothing
had incorrect docstrings
Misc
- Now
generated
package is protected - Updates
poetry
to1.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
Maybe
now has.failure()
to match the same API asResult
- Adds
identity
function - Adds
tap
function - Now
pipe
allows to pipe 8 steps - Adds
coalesce_result
andcoalesce_maybe
coverters
Bugfixes
- Fixes that code inside
.fix
and.rescue
ofMaybe
might be called twice
Misc
- Now all methods have doctests
- Updates docs about
Success
and_Success
,Failure
and_Failure
- Updates docs about
@pipeline
- Typechecks async functions and decorators inside
typesafety/
tests
Version 0.10.0
Features
- Breaking:
python>=3.7,<=3.7.2
are not supported anymore,
because of a bug insidetyping
module - Breaking: Now
bind
does not change the type of an error - Breaking: Now
rescue
does not change the type of a value - Breaking: Renames
map_failure
toalt
- 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 -> a
toIO[a] -> IO[a]
- Adds
pipe()
function topipeline.py
- Adds
__hash__()
magic methods to all containers
Bugfixes
- Changes
Any
toNoReturn
inSuccess
andFailure
- Now all type parameters in
Result
,Maybe
, andIO
are covariant
Misc
- Massive docs rewrite
- Updates
mypy
version - Updates
wemake-python-styleguide
and 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.fix
andMaybe.rescue
to work with bothlambda: 1
andlambda _: 1
Misc
- Improves
README
Version 0.8.0
Features
- Reintroduces the
Maybe
monad, typed! - Introduces converters from one type to another
- Adds
mypy
plugin to type decorators - Complete rewrite of
Result
types - Partial API change, now
Success
andFailure
are not types, but functions - New internal types introduced:
FixableContainer
andValueUnwrapContainer
Bugfixes
- Fixes issue when you could return
IO
container fromResult.bind
- Fixes
@pipeline
return type
Misc
- Reapplied all types to
.py
files - Improved docs about
IO
andContainer
concept - Adds docs about container composition
- Moves from
Alpha
toBeta
Version 0.7.0
Features
- Adds
IO
marker - Adds
unsafe
module with unsafe functions - Changes how functions are located inside the project
Bugfixes
- Fixes container type in
@pipeline
- Now
is_successful
is public - Now
raise_exception
is public
Misc
- Changes how
str()
function works for container types - Total rename to "container" in the source code
Version 0.6.0
Features
safe
andpipeline
now supportsasyncio
is_successful
now returnsLiteral
types if possible