(self, other: Mapping[Any, Any])
| 472 | return self |
| 473 | |
| 474 | def __sub__(self, other: Mapping[Any, Any]): |
| 475 | frozen = self._box_config["frozen_box"] |
| 476 | config = self.__box_config() |
| 477 | config["frozen_box"] = False |
| 478 | config.pop("box_namespace") # Detach namespace; it will be reassigned if we nest again |
| 479 | output = self._box_config["box_class"](**config) |
| 480 | if not isinstance(other, dict): |
| 481 | raise BoxError("Box can only compare two boxes or a box and a dictionary.") |
| 482 | if not isinstance(other, Box): |
| 483 | other = self._box_config["box_class"](other, **config) |
| 484 | for item in self: |
| 485 | if item not in other: |
| 486 | output[item] = self[item] |
| 487 | elif isinstance(self.get(item), Box) and isinstance(other.get(item), Box): |
| 488 | output[item] = self[item] - other[item] |
| 489 | if not output[item]: |
| 490 | del output[item] |
| 491 | output._box_config["frozen_box"] = frozen |
| 492 | return output |
| 493 | |
| 494 | def __hash__(self): |
| 495 | if self._box_config["frozen_box"]: |
nothing calls this directly
no test coverage detected