[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 21/36] qapi/commands.py: Don't re-bind to variable of diff
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v5 21/36] qapi/commands.py: Don't re-bind to variable of different type |
Date: |
Wed, 07 Oct 2020 13:34:56 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
John Snow <jsnow@redhat.com> writes:
> Mypy isn't a fan of rebinding a variable with a new data type.
> It's easy enough to avoid.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> Reviewed-by: Cleber Rosa <crosa@redhat.com>
> ---
> scripts/qapi/commands.py | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py
> index f67393f8713..586774a23c7 100644
> --- a/scripts/qapi/commands.py
> +++ b/scripts/qapi/commands.py
> @@ -195,14 +195,12 @@ def gen_register_command(name, success_response,
> allow_oob, allow_preconfig):
> if not options:
> options = ['QCO_NO_OPTIONS']
>
> - options = " | ".join(options)
> -
> ret = mcgen('''
> qmp_register_command(cmds, "%(name)s",
> qmp_marshal_%(c_name)s, %(opts)s);
> ''',
> name=name, c_name=c_name(name),
> - opts=options)
> + opts=" | ".join(options))
> return ret
Definitely neater.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[PATCH v5 20/36] qapi/events.py: Move comments into docstrings, John Snow, 2020/10/05
[PATCH v5 22/36] qapi/commands.py: add type hint annotations, John Snow, 2020/10/05
[PATCH v5 21/36] qapi/commands.py: Don't re-bind to variable of different type, John Snow, 2020/10/05
- Re: [PATCH v5 21/36] qapi/commands.py: Don't re-bind to variable of different type,
Markus Armbruster <=
[PATCH v5 23/36] qapi/commands.py: enable checking with mypy, John Snow, 2020/10/05
[PATCH v5 25/36] qapi/source.py: delint with pylint, John Snow, 2020/10/05
[PATCH v5 26/36] qapi/gen.py: Fix edge-case of _is_user_module, John Snow, 2020/10/05
[PATCH v5 28/36] qapi/gen.py: Enable checking with mypy, John Snow, 2020/10/05