MCPcopy
hub / github.com/dry-python/returns / apply

Method apply

returns/context/requires_context.py:153–174  ·  view source on GitHub ↗

Calls a wrapped function in a container on this container. .. code:: python >>> from returns.context import RequiresContext >>> assert RequiresContext.from_value('a').apply( ... RequiresContext.from_value(lambda inner: inner + 'b') ... )(

(
        self,
        container: Kind2[
            RequiresContext,
            Callable[[_ReturnType_co], _NewReturnType],
            _EnvType_contra,
        ],
    )

Source from the content-addressed store, hash-verified

151 return RequiresContext(lambda deps: function(self(deps)))
152
153 def apply(
154 self,
155 container: Kind2[
156 RequiresContext,
157 Callable[[_ReturnType_co], _NewReturnType],
158 _EnvType_contra,
159 ],
160 ) -> RequiresContext[_NewReturnType, _EnvType_contra]:
161 """
162 Calls a wrapped function in a container on this container.
163
164 .. code:: python
165
166 >>> from returns.context import RequiresContext
167 >>> assert RequiresContext.from_value('a').apply(
168 ... RequiresContext.from_value(lambda inner: inner + 'b')
169 ... )(...) == 'ab'
170
171 """
172 return RequiresContext(
173 lambda deps: self.map(dekind(container)(deps))(deps),
174 )
175
176 def bind(
177 self,

Callers

nothing calls this directly

Calls 3

mapMethod · 0.95
dekindFunction · 0.90
RequiresContextClass · 0.85

Tested by

no test coverage detected