(self, other: Mapping[Any, Any])
| 360 | return self |
| 361 | |
| 362 | def __sub__(self, other: Mapping[Any, Any]): |
| 363 | frozen = self._box_config["frozen_box"] |
| 364 | config = self.__box_config() |
| 365 | config["frozen_box"] = False |
| 366 | config.pop("box_namespace") # Detach namespace; it will be reassigned if we nest again |
| 367 | output = self._box_config["box_class"](**config) |
| 368 | if not isinstance(other, dict): |
| 369 | raise BoxError("Box can only compare two boxes or a box and a dictionary.") |
| 370 | if not isinstance(other, Box): |
| 371 | other = self._box_config["box_class"](other, **config) |
| 372 | for item in self: |
| 373 | if item not in other: |
| 374 | output[item] = self[item] |
| 375 | elif isinstance(self.get(item), Box) and isinstance(other.get(item), Box): |
| 376 | output[item] = self[item] - other[item] |
| 377 | if not output[item]: |
| 378 | del output[item] |
| 379 | output._box_config["frozen_box"] = frozen |
| 380 | return output |
| 381 | |
| 382 | def __hash__(self): |
| 383 | if self._box_config["frozen_box"]: |
nothing calls this directly
no test coverage detected