All notable changes to this project will be documented in this file.
kwarged
function in themappings
module to call functions with keyword arguments (similar tostarred
initerables
)unwrap
singleton that unwraps pipes (equivalent to.get()
)enumerated
, curried version ofenumerate
builtiniter_reverse
, reverses Iterators rather than just reversible functions.
count
in the iterables module now takes a predicate instead of a value- Using iterables,
Then
, andCatch
on the RHS of the pipe (|
) operator is now deprecated and will be removed in later versions.
- Curry wrapper. Functions can now be decorated with an
@curry
decorator. e.g.:from pipe_utils import curry @curry def foo(x, y, z=3): return [x, y, z] result = foo(z=1)(3)(2) # or: `foo(z=1) >> 3 >> 2`, or `foo(3, 2, 1)` print(result) # [3, 2, 1]
P
added as a short alias forPipe
- Pipes can now be created with the
>>
operator:P >> data | ...
obj
object to allow for method calls in pipe operations without using lambdasreturns
, andinstance_of
functions in thevalues
modulecase_match
andcase_when
functions in themappings
modulesplit_by_any
andsplit_when
functions to split by containers and predicates respectivelymelt
andunmelt
in themappings
module to transform dicts to iterables and backas_tuple
,as_tuples
,as_tuple_of_tuples
,as_list
,as_lists
,as_list_of_lists
functions to easily convert data types
- breaking change
pipe-utils
now requires Python 3.12 - All functions are now curried and can be called with brackets or the right
shift operator (e.g.
foo(1)(2)
orfoo >> 1 >> 2
). Functions will still work as before. get_or_default
is now deprecated, useget(n, default=...)
instead- breaking change
first
andlast
now return single unwraped elements — to retrieve an iterable, usetake
andtake_last
- breaking change
chunked
,drop
,drop_last
,windowed
, no longer eagerly check for value errors - breaking change
join_to_str
separator args are now keyword only - breaking change
pad_with
length
argument now no longer has a default None value - breaking change
split_by
now takes a singlesep
parameter – usesplit_by_any
as a replacement for multiple split values - breaking change
try_map
,catch
parameter is now keyword only
raises
function invalues
. Similar toraise_
but returns a callable.- Several functions in the
iterables
module:strip
,lstrip
,rstrip
andstrip_while
replace
functionextend
andextend_left
as replacements toconcat
andconcat_after
map_indexed
andfilter_indexed
functionswrap
function
- Deprecated modules and functions have been removed:
utils
module and several functions invalues
concat
andconcat_after
are now deprecated useextend
andextend_left
insteadtry_map
now ignores errors by default and will only include default values if the (now named) default parameter is given.err
parameter is also changed tocatch
raise_
andRaise
functions now takenothing
singleton for thefrom_
parameter allowing for exception chain disabling with theraise E from None
idiom.Pipe.get_or_raise
now takes a namedchained
parameter that determines whether errors should be chained with the caught Pipe exceptions.chunked
now takespartial
andstrict
arguments.- Typehints have been updated for
Or
/or_
andAnd
/and_
to indicate non-boolean return types.
pad_with
function has been added toiterables
module.- A
Catch
class has been added as an equivalent toPipe.catch
intended to be used with chained__or__
calls raise_
function invalues
module that raises an exception. Aliased asRaise
inoverride
module.
it_is
andit_is_not
have been deprecated, useis_
andis_not
instead for consistency with other naming conventions.windowed
now hasstrict
andpartial
parametersPipe
get_or_default
andget_or_raise
methods now take a namedcatch
parameter that limits the scope of errors that are caught.override
module now aliasesvalues
functionsand_
,or_
,not_
andis_
toAnd
,Or
,Not
, andIs
to avoid underscore naming convention. Includingis_not
toIsNot
for consistency with other binary operations.
sum_by
function was added toiterables
module
- multiple
it
objects can now be used in a single expression. e.g.it ** it
- An
override
module has been added that exposesPipe
,Then
,it
and all utility functions but aliasesfiler_
,map_
,all_
,any_
, andslice_
to not include the trailing underscore – overriding the builtin names - An
it
object has been added to thepipe
module. This allows for simple comparisons to be constructed:from pipe_utils.override import * class Foo: def __init__(self, bar): self.bar = bar res = ( Pipe(Foo(x) for x in range(10)) | map(it.bar) | filter(it % 2 == 0) | list ).get() print(res)
- Added
not_contains
utility toiterables
module
utils
module is now deprecated- All utilities are now imported into the root
pipe_utils
module by default - Several functions in the
values
module are deprecated as these are now replaced by theit
object behaviour (e.g.gt
,add_by
, etc.).
sorted_dict_by
no longer has a default key ofNone
to_each
in theiterables
moduleclamp
,lclamp
, andrclamp
in thevalues
modulemap_keys
,map_values
,filter_keys
,filter_values
,get_value
,get_value_or_default
functions in themappings
moduleutils
module that importsPipe
,Then
and all utility functions