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

Function has_safe_repr

src/jinja2/compiler.py:125–139  ·  view source on GitHub ↗

Does the node have a safe representation?

(value: t.Any)

Source from the content-addressed store, hash-verified

123
124
125def has_safe_repr(value: t.Any) -> bool:
126 """Does the node have a safe representation?"""
127 if value is None or value is NotImplemented or value is Ellipsis:
128 return True
129
130 if type(value) in {bool, int, float, complex, range, str, Markup}:
131 return True
132
133 if type(value) in {tuple, list, set, frozenset}:
134 return all(has_safe_repr(v) for v in value)
135
136 if type(value) is dict: # noqa E721
137 return all(has_safe_repr(k) and has_safe_repr(v) for k, v in value.items())
138
139 return False
140
141
142def find_undeclared(

Callers 2

from_untrustedMethod · 0.85

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected