[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/17] qapi: Improve error position for bogus invalid "Returns" se
From: |
Markus Armbruster |
Subject: |
[PULL 07/17] qapi: Improve error position for bogus invalid "Returns" section |
Date: |
Mon, 26 Feb 2024 11:49:44 +0100 |
When something other than a command has a "Returns" section, the error
message points to the beginning of the definition comment. Point to
the "Returns" section instead.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240216145841.2099240-7-armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
scripts/qapi/parser.py | 10 +++++++---
tests/qapi-schema/doc-invalid-return.err | 2 +-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 82db595dcf..a771013959 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -759,9 +759,13 @@ def connect_feature(self, feature: 'QAPISchemaFeature') ->
None:
self.features[feature.name].connect(feature)
def check_expr(self, expr: QAPIExpression) -> None:
- if self.has_section('Returns') and 'command' not in expr:
- raise QAPISemError(self.info,
- "'Returns:' is only valid for commands")
+ if 'command' not in expr:
+ sec = next((sec for sec in self.sections
+ if sec.name == 'Returns'),
+ None)
+ if sec:
+ raise QAPISemError(sec.info,
+ "'Returns:' is only valid for commands")
def check(self) -> None:
diff --git a/tests/qapi-schema/doc-invalid-return.err
b/tests/qapi-schema/doc-invalid-return.err
index 2ad89c5941..bc5826de20 100644
--- a/tests/qapi-schema/doc-invalid-return.err
+++ b/tests/qapi-schema/doc-invalid-return.err
@@ -1 +1 @@
-doc-invalid-return.json:3: 'Returns:' is only valid for commands
+doc-invalid-return.json:5: 'Returns:' is only valid for commands
--
2.43.0
- [PULL 02/17] tests/qapi-schema: Fix test 'QAPI rST doc', (continued)
- [PULL 02/17] tests/qapi-schema: Fix test 'QAPI rST doc', Markus Armbruster, 2024/02/26
- [PULL 09/17] qapi: Rename QAPIDoc.Section.name to .tag, Markus Armbruster, 2024/02/26
- [PULL 04/17] tests/qapi-schema: Cover 'Features:' not followed by descriptions, Markus Armbruster, 2024/02/26
- [PULL 05/17] sphinx/qapidoc: Drop code to generate doc for simple union branch, Markus Armbruster, 2024/02/26
- [PULL 16/17] qapi: Reject multiple and empty feature descriptions, Markus Armbruster, 2024/02/26
- [PULL 13/17] qapi: Call QAPIDoc.check() always, Markus Armbruster, 2024/02/26
- [PULL 06/17] qapi: Improve error position for bogus argument descriptions, Markus Armbruster, 2024/02/26
- [PULL 11/17] qapi: Require descriptions and tagged sections to be indented, Markus Armbruster, 2024/02/26
- [PULL 08/17] qapi: Improve error message for empty doc sections, Markus Armbruster, 2024/02/26
- [PULL 03/17] tests/qapi-schema: Cover duplicate 'Features:' line, Markus Armbruster, 2024/02/26
- [PULL 07/17] qapi: Improve error position for bogus invalid "Returns" section,
Markus Armbruster <=
- [PULL 10/17] qapi: Reject section heading in the middle of a doc comment, Markus Armbruster, 2024/02/26
- Re: [PULL 00/17] QAPI patches patches for 2024-02-26, Peter Maydell, 2024/02/26