| 383 | |
| 384 | @dataclass |
| 385 | class 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 | |
| 414 | class _IdentitySubscript: |
no outgoing calls
searching dependent graphs…