| 971 | |
| 972 | @classmethod |
| 973 | def safe_merge(cls, other: "Options") -> Any: |
| 974 | d = other._state_dict() |
| 975 | |
| 976 | # only support a merge with another object of our class |
| 977 | # and which does not have attrs that we don't. otherwise |
| 978 | # we risk having state that might not be part of our cache |
| 979 | # key strategy |
| 980 | |
| 981 | if ( |
| 982 | cls is not other.__class__ |
| 983 | and other._cache_attrs |
| 984 | and set(other._cache_attrs).difference(cls._cache_attrs) |
| 985 | ): |
| 986 | raise TypeError( |
| 987 | "other element %r is not empty, is not of type %s, " |
| 988 | "and contains attributes not covered here %r" |
| 989 | % ( |
| 990 | other, |
| 991 | cls, |
| 992 | set(other._cache_attrs).difference(cls._cache_attrs), |
| 993 | ) |
| 994 | ) |
| 995 | return cls + d |
| 996 | |
| 997 | @classmethod |
| 998 | def from_execution_options( |