(self, key)
| 122 | super().__init__(list_items) |
| 123 | |
| 124 | def __getitem__(self, key): |
| 125 | # change index to positive value because MongoDB does not support negative one |
| 126 | if isinstance(key, int) and key < 0: |
| 127 | key = len(self) + key |
| 128 | value = super().__getitem__(key) |
| 129 | |
| 130 | if isinstance(key, slice): |
| 131 | # When receiving a slice operator, we don't convert the structure and bind |
| 132 | # to parent's instance. This is buggy for now but would require more work to be handled properly |
| 133 | return value |
| 134 | |
| 135 | EmbeddedDocument = _import_class("EmbeddedDocument") |
| 136 | if isinstance(value, EmbeddedDocument) and value._instance is None: |
| 137 | value._instance = self._instance |
| 138 | elif isinstance(value, dict) and not isinstance(value, BaseDict): |
| 139 | # Replace dict by BaseDict |
| 140 | value = BaseDict(value, None, f"{self._name}.{key}") |
| 141 | super().__setitem__(key, value) |
| 142 | value._instance = self._instance |
| 143 | elif isinstance(value, list) and not isinstance(value, BaseList): |
| 144 | # Replace list by BaseList |
| 145 | value = BaseList(value, None, f"{self._name}.{key}") |
| 146 | super().__setitem__(key, value) |
| 147 | value._instance = self._instance |
| 148 | return value |
| 149 | |
| 150 | def __iter__(self): |
| 151 | yield from super().__iter__() |
nothing calls this directly
no test coverage detected