[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 07/22] qapi/parser: assert object keys are strings
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 07/22] qapi/parser: assert object keys are strings |
Date: |
Sun, 25 Apr 2021 09:27:50 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
John Snow <jsnow@redhat.com> writes:
> The single quote token implies the value is a string. Assert this to be
> the case.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qapi/parser.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
> index 6b443b1247e..8d1fe0ddda5 100644
> --- a/scripts/qapi/parser.py
> +++ b/scripts/qapi/parser.py
> @@ -246,6 +246,8 @@ def get_members(self):
> raise QAPIParseError(self, "expected string or '}'")
> while True:
> key = self.val
> + assert isinstance(key, str) # Guaranteed by tok == "'"
> +
> self.accept()
> if self.tok != ':':
> raise QAPIParseError(self, "expected ':'")
The assertion is correct, but I wonder why mypy needs it. Can you help?
- Re: [PATCH 06/22] qapi/parser: assert get_expr returns object in outer loop, (continued)
[PATCH 07/22] qapi/parser: assert object keys are strings, John Snow, 2021/04/21
- Re: [PATCH 07/22] qapi/parser: assert object keys are strings,
Markus Armbruster <=
[PATCH 12/22] qapi/parser: add type hint annotations, John Snow, 2021/04/21
[PATCH 02/22] qapi/source: [RFC] add "with_column" contextmanager, John Snow, 2021/04/21