MCPcopy Create free account
hub / github.com/ipython/traitlets / collisions

Method collisions

traitlets/config/loader.py:275–293  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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`

Callers 2

test_collisionMethod · 0.95
_load_config_filesMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_collisionMethod · 0.76