True when any Box / BoxList in the tree has a key, item or document comment.
(obj, _seen=None)
| 246 | |
| 247 | |
| 248 | def has_comments(obj, _seen=None) -> bool: |
| 249 | """True when any Box / BoxList in the tree has a key, item or document comment.""" |
| 250 | store = getattr(obj, "_comment_store", None) |
| 251 | if store is None: |
| 252 | return False |
| 253 | if obj._comment_store(create=False) or obj._comment_document(create=False): |
| 254 | return True |
| 255 | seen = _seen if _seen is not None else set() |
| 256 | if id(obj) in seen: |
| 257 | return False |
| 258 | seen.add(id(obj)) |
| 259 | values = obj.values() if isinstance(obj, dict) else obj # a list or a frozen list (tuple) |
| 260 | return any(has_comments(value, seen) for value in values) |
| 261 | |
| 262 | |
| 263 | def _add_eol_comment(out, key, text): |
no test coverage detected