MCPcopy Index your code
hub / github.com/ipython/ipython / can_operate

Method can_operate

IPython/core/guarded_eval.py:328–347  ·  view source on GitHub ↗
(self, dunders: tuple[str, ...], a, b=None)

Source from the content-addressed store, hash-verified

326 )
327
328 def can_operate(self, dunders: tuple[str, ...], a, b=None):
329 allowed_operations_external = _coerce_path_to_tuples(
330 self.allowed_operations_external
331 )
332 objects = [a]
333 if b is not None:
334 objects.append(b)
335 return all(
336 [
337 _has_original_dunder(
338 obj,
339 allowed_types=self.allowed_operations,
340 allowed_methods=self._operator_dunder_methods(dunder),
341 allowed_external=allowed_operations_external,
342 method_name=dunder,
343 )
344 for dunder in dunders
345 for obj in objects
346 ]
347 )
348
349 def _operator_dunder_methods(self, dunder: str) -> set[Callable]:
350 if dunder not in self._operation_methods_cache:

Callers 1

eval_nodeFunction · 0.45

Calls 3

_coerce_path_to_tuplesFunction · 0.85
_has_original_dunderFunction · 0.85

Tested by

no test coverage detected