Return the union of two dictionaries as a new dictionary. An exception is raised if any keys are found in both dictionaries and the values are not compatible. Parameters ---------- first_dict, second_dict : dict-like Mappings to merge. compat : function, optional
(
first_dict: Mapping[K, V],
second_dict: Mapping[K, V],
compat: Callable[[V, V], bool] = equivalent,
)
| 463 | |
| 464 | |
| 465 | def compat_dict_union( |
| 466 | first_dict: Mapping[K, V], |
| 467 | second_dict: Mapping[K, V], |
| 468 | compat: Callable[[V, V], bool] = equivalent, |
| 469 | ) -> MutableMapping[K, V]: |
| 470 | """Return the union of two dictionaries as a new dictionary. |
| 471 | |
| 472 | An exception is raised if any keys are found in both dictionaries and the |
| 473 | values are not compatible. |
| 474 | |
| 475 | Parameters |
| 476 | ---------- |
| 477 | first_dict, second_dict : dict-like |
| 478 | Mappings to merge. |
| 479 | compat : function, optional |
| 480 | Binary operator to determine if two values are compatible. By default, |
| 481 | checks for equivalence. |
| 482 | |
| 483 | Returns |
| 484 | ------- |
| 485 | union : dict |
| 486 | union of the contents. |
| 487 | """ |
| 488 | new_dict = dict(first_dict) |
| 489 | update_safety_check(first_dict, second_dict, compat) |
| 490 | new_dict.update(second_dict) |
| 491 | return new_dict |
| 492 | |
| 493 | |
| 494 | class Frozen(Mapping[K, V]): |
no test coverage detected
searching dependent graphs…