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