[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 26/36] qapi/gen.py: Fix edge-case of _is_user_module
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v5 26/36] qapi/gen.py: Fix edge-case of _is_user_module |
Date: |
Wed, 07 Oct 2020 14:02:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
John Snow <jsnow@redhat.com> writes:
> The edge case is that if the name is '', this expression returns a
> string instead of a bool, which violates our declared type.
The edge case is impossible, as discussed in review of v2. I figure the
type checker can't see that, so we need to help it some. Can we mention
this in the commit message?
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> Reviewed-by: Cleber Rosa <crosa@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> scripts/qapi/gen.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
> index f2e2746fea5..1bad37fc06b 100644
> --- a/scripts/qapi/gen.py
> +++ b/scripts/qapi/gen.py
> @@ -243,7 +243,7 @@ def __init__(self, prefix, what, user_blurb,
> builtin_blurb, pydoc):
>
> @staticmethod
> def _is_user_module(name):
> - return name and not name.startswith('./')
> + return bool(name and not name.startswith('./'))
return not (name is None or name.startswith('./')
Looks slightly clearer to me.
>
> @staticmethod
> def _is_builtin_module(name):
[PATCH v5 27/36] qapi/gen.py: add type hint annotations, John Snow, 2020/10/05