Restore a Statement from a dictionary. :param source_dict: source data dictionary (generated using to_dict()) :return: Statement object
(cls, source_dict: dict[str, Any])
| 228 | |
| 229 | @classmethod |
| 230 | def from_dict(cls, source_dict: dict[str, Any]) -> Self: |
| 231 | """Restore a Statement from a dictionary. |
| 232 | |
| 233 | :param source_dict: source data dictionary (generated using to_dict()) |
| 234 | :return: Statement object |
| 235 | """ |
| 236 | # value needs to be passed as a positional argument. It corresponds to the args field. |
| 237 | try: |
| 238 | value = source_dict["args"] |
| 239 | except KeyError: |
| 240 | raise KeyError("Statement dictionary is missing 'args' field") from None |
| 241 | |
| 242 | # Filter out 'args' so it isn't passed twice |
| 243 | kwargs = {k: v for k, v in source_dict.items() if k != "args"} |
| 244 | return cls(value, **kwargs) |
| 245 | |
| 246 | |
| 247 | @dataclass(frozen=True, slots=True) |
no outgoing calls