Does the node have a safe representation?
(value: t.Any)
| 123 | |
| 124 | |
| 125 | def 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 | |
| 142 | def find_undeclared( |
no test coverage detected