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

Function _has_original_dunder

IPython/core/guarded_eval.py:200–223  ·  view source on GitHub ↗
(
    value, allowed_types, allowed_methods, allowed_external, method_name
)

Source from the content-addressed store, hash-verified

198
199
200def _has_original_dunder(
201 value, allowed_types, allowed_methods, allowed_external, method_name
202):
203 # note: Python ignores `__getattr__`/`__getitem__` on instances,
204 # we only need to check at class level
205 value_type = type(value)
206
207 # strict type check passes → no need to check method
208 if value_type in allowed_types:
209 return True
210
211 method = getattr(value_type, method_name, None)
212
213 if method is None:
214 return None
215
216 if method in allowed_methods:
217 return True
218
219 for module_name, *access_path in allowed_external:
220 if _has_original_dunder_external(value, module_name, access_path, method_name):
221 return True
222
223 return False
224
225
226def _coerce_path_to_tuples(

Callers 3

can_get_attrMethod · 0.85
can_get_itemMethod · 0.85
can_operateMethod · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…