summary refs log tree commit diff stats
path: root/scripts/qapi/main.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-05-20 20:17:55 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-05-20 20:17:55 +0100
commit0b5acf89c1b197fc8f36db0896f652a4c577352f (patch)
tree6d2404d7a8f30c97f44d44c031c4793f06535758 /scripts/qapi/main.py
parent972e848b53970d12cb2ca64687ef8ff797fb6236 (diff)
parentd4092ffa2604e07b2e1bb5b1f7b2651bc1edda80 (diff)
downloadfocaccia-qemu-0b5acf89c1b197fc8f36db0896f652a4c577352f.tar.gz
focaccia-qemu-0b5acf89c1b197fc8f36db0896f652a4c577352f.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-05-20' into staging
QAPI patches patches for 2021-05-20

# gpg: Signature made Thu 20 May 2021 16:10:21 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2021-05-20:
  qapi/parser: add docstrings
  qapi/parser: allow 'ch' variable name
  qapi/parser: Remove superfluous list comprehension
  qapi/parser: add type hint annotations
  qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard
  qapi/parser: Fix token membership tests when token can be None
  qapi: add must_match helper
  qapi/parser: Use @staticmethod where appropriate
  qapi/parser: assert object keys are strings
  qapi/parser: enforce all top-level expressions must be dict in _parse()
  qapi/parser: Assert lexer value is a string
  qapi/parser: factor parsing routine into method
  qapi/source: Remove line number from QAPISourceInfo initializer
  qapi: Add test for nonexistent schema file
  qapi/parser: Don't try to handle file errors

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/main.py')
-rw-r--r--scripts/qapi/main.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py
index 703e7ed1ed..f2ea6e0ce4 100644
--- a/scripts/qapi/main.py
+++ b/scripts/qapi/main.py
@@ -8,11 +8,11 @@ This is the main entry point for generating C code from the QAPI schema.
 """
 
 import argparse
-import re
 import sys
 from typing import Optional
 
 from .commands import gen_commands
+from .common import must_match
 from .error import QAPIError
 from .events import gen_events
 from .introspect import gen_introspect
@@ -22,9 +22,7 @@ from .visit import gen_visit
 
 
 def invalid_prefix_char(prefix: str) -> Optional[str]:
-    match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix)
-    # match cannot be None, but mypy cannot infer that.
-    assert match is not None
+    match = must_match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix)
     if match.end() != len(prefix):
         return prefix[match.end()]
     return None