MCPcopy
hub / github.com/pallets/jinja / as_const

Method as_const

src/jinja2/nodes.py:499–512  ·  view source on GitHub ↗
(self, eval_ctx: t.Optional[EvalContext] = None)

Source from the content-addressed store, hash-verified

497 abstract = True
498
499 def as_const(self, eval_ctx: t.Optional[EvalContext] = None) -> t.Any:
500 eval_ctx = get_eval_context(self, eval_ctx)
501
502 # intercepted operators cannot be folded at compile time
503 if (
504 eval_ctx.environment.sandboxed
505 and self.operator in eval_ctx.environment.intercepted_binops # type: ignore
506 ):
507 raise Impossible()
508 f = _binop_to_func[self.operator]
509 try:
510 return f(self.left.as_const(eval_ctx), self.right.as_const(eval_ctx))
511 except Exception as e:
512 raise Impossible() from e
513
514
515class UnaryExpr(Expr):

Callers

nothing calls this directly

Calls 3

get_eval_contextFunction · 0.85
ImpossibleClass · 0.85
as_constMethod · 0.45

Tested by

no test coverage detected