MCPcopy
hub / github.com/nonebot/nonebot2 / solve

Method solve

nonebot/dependencies/__init__.py:205–226  ·  view source on GitHub ↗
(self, **params: Any)

Source from the content-addressed store, hash-verified

203 return v if param.validate else value
204
205 async def solve(self, **params: Any) -> dict[str, Any]:
206 # solve parameterless
207 for param in self.parameterless:
208 await param._solve(**params)
209
210 # solve param values
211 result: dict[str, Any] = {}
212 if not self.params:
213 return result
214
215 async def _solve_field(field: ModelField, params: dict[str, Any]) -> None:
216 value = await self._solve_field(field, params)
217 result[field.name] = value
218
219 async with anyio.create_task_group() as tg:
220 for field in self.params:
221 # shield the task to prevent cancellation
222 # when one of the tasks raises an exception
223 # this will improve the dependency cache reusability
224 tg.start_soon(run_coro_with_shield, _solve_field(field, params))
225
226 return result
227
228
229__autodoc__ = {"CustomConfig": False}

Callers 2

__call__Method · 0.95
_solveMethod · 0.80

Calls 1

_solveMethod · 0.45

Tested by

no test coverage detected