def map( self, transformation: typing.Union[typing.Callable[[ValueT], AnotherValueT], str], ) -> LazyIterator[AnotherValueT]: """Map the values to a different value. Parameters ---------- transformation : typing.Union[typing.Callable[[ValueT], builtins.bool], builtins.str] The function to use to map the attribute. This may alternatively be a string attribute name to replace the input value with. You can provide nested attributes using the `.` operator. Returns ------- LazyIterator[AnotherValueT] `LazyIterator` that maps each value to another value. """ if isinstance(transformation, str): transformation = typing.cast( "spel.AttrGetter[ValueT, AnotherValueT]", spel.AttrGetter(transformation)) return _MappingLazyIterator(self, transformation)
def __init__( self, attr_name: str, expected_value: typing.Any, cast: typing.Optional[typing.Callable[[ValueT], typing.Any]] = None, ) -> None: self.expected_value = expected_value self.attr_getter: spel.AttrGetter[ ValueT, typing.Any] = spel.AttrGetter(attr_name) self.cast = cast