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

Function is_undefined

src/jinja2/utils.py:104–118  ·  view source on GitHub ↗

Check if the object passed is undefined. This does nothing more than performing an instance check against :class:`Undefined` but looks nicer. This can be used for custom filters or tests that want to react to undefined variables. For example a custom default filter can look like th

(obj: t.Any)

Source from the content-addressed store, hash-verified

102
103
104def is_undefined(obj: t.Any) -> bool:
105 """Check if the object passed is undefined. This does nothing more than
106 performing an instance check against :class:`Undefined` but looks nicer.
107 This can be used for custom filters or tests that want to react to
108 undefined variables. For example a custom default filter can look like
109 this::
110
111 def default(var, default=''):
112 if is_undefined(var):
113 return default
114 return var
115 """
116 from .runtime import Undefined
117
118 return isinstance(obj, Undefined)
119
120
121def consume(iterable: t.Iterable[t.Any]) -> None:

Callers 1

test_expressionsMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_expressionsMethod · 0.72