(self, key)
| 125 | raise BoxError("Box is frozen") |
| 126 | |
| 127 | def _comment_owner(self, key): |
| 128 | if key is None: |
| 129 | return self, None |
| 130 | if isinstance(key, int) and not isinstance(key, bool): |
| 131 | index = key + len(self) if key < 0 else key |
| 132 | if 0 <= index < len(self): |
| 133 | return self, index |
| 134 | elif isinstance(key, str) and key.startswith("["): |
| 135 | list_pos = _tuple_comment_index_re.match(key) |
| 136 | if list_pos is not None: |
| 137 | index = int(list_pos.group(1)) |
| 138 | index = index + len(self) if index < 0 else index |
| 139 | rest = key[list_pos.end() :].lstrip(".") |
| 140 | if 0 <= index < len(self): |
| 141 | if not rest: |
| 142 | return self, index |
| 143 | child = tuple.__getitem__(self, index) |
| 144 | if hasattr(child, "_comment_owner"): |
| 145 | return child._comment_owner(rest) |
| 146 | raise BoxKeyError(f"{key!r} is not in the frozen list, comments can only be attached to existing items") |
| 147 | |
| 148 | def get_comment(self, key: Any = None) -> dict | None: |
| 149 | """The comments of an item (see ``BoxList.get_comment``), ``None`` for the document comments.""" |
nothing calls this directly
no test coverage detected