From 76f598c55a221a2fdd1fd7dcfe5f054e5c76e38b Mon Sep 17 00:00:00 2001 From: "zhen.chen" Date: Mon, 11 Apr 2022 18:24:04 +0800 Subject: [PATCH] style(utility): update error message for calling "get_callback_body" PR Closed: https://github.com/Graviti-AI/tensorbay-python-sdk/pull/1246 --- tensorbay/client/segment.py | 2 +- tensorbay/utility/file.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tensorbay/client/segment.py b/tensorbay/client/segment.py index 79594e63e..43ad11e19 100644 --- a/tensorbay/client/segment.py +++ b/tensorbay/client/segment.py @@ -933,7 +933,7 @@ def upload_frame(self, frame: Frame, timestamp: Optional[float] = None) -> None: callback_bodies = [] for sensor_name, data in frame.items(): try: - callback_body = data.get_callback_body() # type:ignore[union-attr] + callback_body = data.get_callback_body() except AttributeError: continue diff --git a/tensorbay/utility/file.py b/tensorbay/utility/file.py index 4834b28b4..105b2ad24 100644 --- a/tensorbay/utility/file.py +++ b/tensorbay/utility/file.py @@ -220,3 +220,12 @@ def open(self) -> Union[UserResponse, BufferedReader]: self._write_cache(cache_path) return open(cache_path, "rb") + + def get_callback_body(self) -> Dict[str, Any]: + """Not support ``get_callback_body`` function. + + Raises: + AttributeError: when calling the ``get_callback_body()``. + + """ + raise AttributeError(f"Could not dump a '{self.__class__.__name__}' instance")