| 983 | |
| 984 | @classmethod |
| 985 | def safe_merge(cls, other: class="st">"Options") -> Any: |
| 986 | d = other._state_dict() |
| 987 | |
| 988 | class="cm"># only support a merge with another object of our class |
| 989 | class="cm"># and which does not have attrs that we don't. otherwise |
| 990 | class="cm"># we risk having state that might not be part of our cache |
| 991 | class="cm"># key strategy |
| 992 | |
| 993 | if ( |
| 994 | cls is not other.__class__ |
| 995 | and other._cache_attrs |
| 996 | and set(other._cache_attrs).difference(cls._cache_attrs) |
| 997 | ): |
| 998 | raise TypeError( |
| 999 | class="st">"other element %r is not empty, is not of type %s, " |
| 1000 | class="st">"and contains attributes not covered here %r" |
| 1001 | % ( |
| 1002 | other, |
| 1003 | cls, |
| 1004 | set(other._cache_attrs).difference(cls._cache_attrs), |
| 1005 | ) |
| 1006 | ) |
| 1007 | return cls + d |
| 1008 | |
| 1009 | @classmethod |
| 1010 | def from_execution_options( |