diff --git a/pb_plugins/protoc_gen_mavsdk/methods.py b/pb_plugins/protoc_gen_mavsdk/methods.py index 46c73ddf2..16c9111dc 100644 --- a/pb_plugins/protoc_gen_mavsdk/methods.py +++ b/pb_plugins/protoc_gen_mavsdk/methods.py @@ -66,7 +66,7 @@ def extract_return_type_and_name(self, pb_method, responses): if len(return_params) > 1: raise Exception( "Responses cannot have more than 1 return parameter" + - f"(and an optional '*Result')!\nError in {method_output}") + f" (and an optional '*Result')!\nError in {method_output}") if len(return_params) == 1: self._return_type = type_info_factory.create( @@ -74,6 +74,10 @@ def extract_return_type_and_name(self, pb_method, responses): self._return_name = name_parser_factory.create( return_params[0]['field'].json_name) self._return_description = return_params[0]['docs'] + elif len(return_params) == 0 and self.return_type_required: + raise Exception( + "This response must have 1 return parameter" + + f" (and an optional '*Result')!\nError in {method_output}") def extract_async_type(self, pb_method): self._is_sync = True @@ -119,6 +123,10 @@ def package(self): def name(self): return self._name + @property + def return_type_required(self): + return False + @staticmethod def collect_methods( plugin_name, @@ -270,6 +278,10 @@ def __init__( remove_subscribe(pb_method.name)) self._template = template_env.get_template("stream.j2") + @property + def return_type_required(self): + return True + def __repr__(self): return self._template.render( name=self._name,