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

Class EvaluationContext

IPython/core/guarded_eval.py:385–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383
384@dataclass
385class EvaluationContext:
386 #: Local namespace
387 locals: dict
388 #: Global namespace
389 globals: dict
390 #: Evaluation policy identifier
391 evaluation: EvaluationPolicyName = "forbidden"
392 #: Whether the evaluation of code takes place inside of a subscript.
393 #: Useful for evaluating ``:-1, 'col'`` in ``df[:-1, 'col']``.
394 in_subscript: bool = False
395 #: Auto import method
396 auto_import: Callable[[Sequence[str]], ModuleType] | None = None
397 #: Overrides for evaluation policy
398 policy_overrides: dict = field(default_factory=dict)
399 #: Transient local namespace used to store mocks
400 transient_locals: dict = field(default_factory=dict)
401 #: Transients of class level
402 class_transients: dict | None = None
403 #: Instance variable name used in the method definition
404 instance_arg_name: str | None = None
405 #: Currently associated value
406 #: Useful for adding items to _Duck on annotated assignment
407 current_value: ast.AST | None = None
408
409 def replace(self, /, **changes):
410 """Return a new copy of the context, with specified changes"""
411 return dataclasses.replace(self, **changes)
412
413
414class _IdentitySubscript:

Callers 9

global_matchesMethod · 0.90
_evaluate_exprMethod · 0.90
dict_key_matchesMethod · 0.90
create_contextFunction · 0.90
test_subscriptFunction · 0.90
test_autoimport_moduleFunction · 0.90

Calls

no outgoing calls

Tested by 6

create_contextFunction · 0.72
test_subscriptFunction · 0.72
test_autoimport_moduleFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…