Merges the provided change with the last if possible.
(past_changes: list[Bunch] | None, change: Bunch)
| 1468 | cache: dict[str, list[Bunch]] = {} |
| 1469 | |
| 1470 | def compress(past_changes: list[Bunch] | None, change: Bunch) -> list[Bunch]: |
| 1471 | """Merges the provided change with the last if possible.""" |
| 1472 | if past_changes is None: |
| 1473 | return [change] |
| 1474 | else: |
| 1475 | if past_changes[-1]["type"] == "change" and change.type == "change": |
| 1476 | past_changes[-1]["new"] = change.new |
| 1477 | else: |
| 1478 | # In case of changes other than 'change', append the notification. |
| 1479 | past_changes.append(change) |
| 1480 | return past_changes |
| 1481 | |
| 1482 | def hold(change: Bunch) -> None: |
| 1483 | name = change.name |