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

Method as_const

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

Source from the content-addressed store, hash-verified

521 abstract = True
522
523 def as_const(self, eval_ctx: t.Optional[EvalContext] = None) -> t.Any:
524 eval_ctx = get_eval_context(self, eval_ctx)
525
526 # intercepted operators cannot be folded at compile time
527 if (
528 eval_ctx.environment.sandboxed
529 and self.operator in eval_ctx.environment.intercepted_unops # type: ignore
530 ):
531 raise Impossible()
532 f = _uaop_to_func[self.operator]
533 try:
534 return f(self.node.as_const(eval_ctx))
535 except Exception as e:
536 raise Impossible() from e
537
538
539class Name(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