def METHOD_NAME(self, state: WorkerState) -> None:
    if self._state != state:
        raise InvalidStateException(
            f"Invalid operation: state is {self._state} (must be {state})"
        )