From 2665f8ff988e974638e228b2867526830ed69e91 Mon Sep 17 00:00:00 2001 From: Emi Simpson Date: Sun, 12 Feb 2023 11:07:58 -0500 Subject: [PATCH] Change sequence() to return a list --- emis_funky_funktions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emis_funky_funktions.py b/emis_funky_funktions.py index 54a1706..1fec916 100644 --- a/emis_funky_funktions.py +++ b/emis_funky_funktions.py @@ -707,7 +707,7 @@ def unwrap_r(r: Result[A, Any]) -> A: return val case Err(e): raise AssertionError(f'Tried to unwrap an error: ', e) -def sequence(s: Sequence[Result[A, B]]) -> Result[Iterator[A], B]: +def sequence(s: Sequence[Result[A, B]]) -> Result[Sequence[A], B]: """ Convert a list of results into a result of a list. @@ -716,14 +716,14 @@ def sequence(s: Sequence[Result[A, B]]) -> Result[Iterator[A], B]: errors, proccessing of the sequence is immediately stopped, and the first error encountered is returned. - >>> map_res(list, sequence([Ok(1), Ok(2), Ok(3)])) + >>> sequence([Ok(1), Ok(2), Ok(3)]) Ok([1, 2, 3]) >>> sequence([Ok(1), Err('Oops!'), Err('Aw man!')]) Err('Oops!') """ if all(s): - return Ok(map(unwrap_r, s)) + return Ok(list(map(unwrap_r, s))) else: o = next(filter(not_, s)) assert isinstance(o, Err)