@@ -145,7 +145,7 @@ def pipe1(value0, *bodys):
145145
146146class Getvalue (Singleton ): # singleton sentinel with a nice repr
147147 """Sentinel; pipe into this to exit a shell-like pipe and return the current value."""
148- def __repr__ (self ):
148+ def __repr__ (self ): # pragma: no cover
149149 return "<sentinel for pipe exit>"
150150getvalue = Getvalue ()
151151runpipe = getvalue # same thing as getvalue, but semantically better name for lazy pipes
@@ -185,7 +185,7 @@ def __or__(self, f):
185185 return self ._x
186186 cls = self .__class__
187187 return cls (f (self ._x )) # functional update
188- def __repr__ (self ):
188+ def __repr__ (self ): # pragma: no cover
189189 return "<piped1 at 0x{:x}; value {}>" .format (id (self ), self ._x )
190190
191191class lazy_piped1 :
@@ -247,7 +247,7 @@ def nextfibo(state):
247247 # just pass on the reference to the original x.
248248 cls = self .__class__
249249 return cls (x = self ._x , _funcs = self ._funcs + (f ,))
250- def __repr__ (self ):
250+ def __repr__ (self ): # pragma: no cover
251251 return "<lazy_piped1 at 0x{:x}; initial value now {}, functions {}>" .format (id (self ), self ._x , self ._funcs )
252252
253253def pipe (values0 , * bodys ):
@@ -330,14 +330,12 @@ def __or__(self, f):
330330 if f is exitpipe :
331331 return xs if len (xs ) > 1 else xs [0 ]
332332 cls = self .__class__
333- if isinstance (xs , tuple ):
334- newxs = f (* xs )
335- else :
336- newxs = f (xs )
333+ assert isinstance (xs , tuple ) # __init__ ensures this
334+ newxs = f (* xs )
337335 if isinstance (newxs , tuple ):
338336 return cls (* newxs )
339337 return cls (newxs )
340- def __repr__ (self ):
338+ def __repr__ (self ): # pragma: no cover
341339 return "<piped at 0x{:x}; values {}>" .format (id (self ), self ._xs )
342340
343341class lazy_piped :
@@ -379,11 +377,14 @@ def __or__(self, f):
379377 vs = g (* vs )
380378 else :
381379 vs = g (vs )
382- return vs if len (vs ) > 1 else vs [0 ]
380+ if isinstance (vs , tuple ):
381+ return vs if len (vs ) > 1 else vs [0 ]
382+ else :
383+ return vs
383384 # just pass on the references to the original xs.
384385 cls = self .__class__
385386 return cls (* self ._xs , _funcs = self ._funcs + (f ,))
386- def __repr__ (self ):
387+ def __repr__ (self ): # pragma: no cover
387388 return "<lazy_piped at 0x{:x}; initial values now {}, functions {}>" .format (id (self ), self ._xs , self ._funcs )
388389
389390# do(): improved begin() that can name intermediate results and refer to them
@@ -485,7 +486,7 @@ def maybe_call(v):
485486 try :
486487 if not arity_includes (v , 1 ):
487488 raise ValueError ("Arity mismatch; callable value must allow arity 1, to take in the environment." )
488- except UnknownArity : # well, we tried!
489+ except UnknownArity : # well, we tried! # pragma: no cover
489490 pass
490491 return v (e )
491492 return v
0 commit comments