Check for collisions between two config objects. Returns a dict of the form {"Class": {"trait": "collision message"}}`, indicating which values have been ignored. An empty dict indicates no collisions.
(self, other: Config)
| 273 | self.update(to_update) |
| 274 | |
| 275 | def collisions(self, other: Config) -> dict[str, t.Any]: |
| 276 | """Check for collisions between two config objects. |
| 277 | |
| 278 | Returns a dict of the form {"Class": {"trait": "collision message"}}`, |
| 279 | indicating which values have been ignored. |
| 280 | |
| 281 | An empty dict indicates no collisions. |
| 282 | """ |
| 283 | collisions: dict[str, t.Any] = {} |
| 284 | for section in self: |
| 285 | if section not in other: |
| 286 | continue |
| 287 | mine = self[section] |
| 288 | theirs = other[section] |
| 289 | for key in mine: |
| 290 | if key in theirs and mine[key] != theirs[key]: |
| 291 | collisions.setdefault(section, {}) |
| 292 | collisions[section][key] = f"{mine[key]!r} ignored, using {theirs[key]!r}" |
| 293 | return collisions |
| 294 | |
| 295 | def __contains__(self, key: t.Any) -> bool: |
| 296 | # allow nested contains of the form `"Section.key" in config` |
no outgoing calls