[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 36/36] qapi/visit.py: add type hint annotations
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v5 36/36] qapi/visit.py: add type hint annotations |
Date: |
Wed, 07 Oct 2020 15:00:11 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
John Snow <jsnow@redhat.com> writes:
> Annotations do not change runtime behavior.
> This commit *only* adds annotations.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> Reviewed-by: Cleber Rosa <crosa@redhat.com>
> Tested-by: Cleber Rosa <crosa@redhat.com>
> ---
> scripts/qapi/mypy.ini | 5 ---
> scripts/qapi/visit.py | 73 +++++++++++++++++++++++++++++++++----------
> 2 files changed, 56 insertions(+), 22 deletions(-)
>
> diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini
> index 83f19813553..74fc6c82153 100644
> --- a/scripts/qapi/mypy.ini
> +++ b/scripts/qapi/mypy.ini
> @@ -28,8 +28,3 @@ check_untyped_defs = False
> disallow_untyped_defs = False
> disallow_incomplete_defs = False
> check_untyped_defs = False
> -
> -[mypy-qapi.visit]
> -disallow_untyped_defs = False
> -disallow_incomplete_defs = False
> -check_untyped_defs = False
> diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
> index e54694e23db..14d4f0b261f 100644
> --- a/scripts/qapi/visit.py
> +++ b/scripts/qapi/visit.py
> @@ -13,6 +13,8 @@
> See the COPYING file in the top-level directory.
> """
>
> +from typing import List, Optional
> +
> from .common import (
> c_enum_const,
> c_name,
> @@ -22,10 +24,20 @@
> mcgen,
> )
> from .gen import QAPISchemaModularCVisitor, ifcontext
> -from .schema import QAPISchemaEnumType, QAPISchemaObjectType
> +from .schema import (
> + QAPISchema,
> + QAPISchemaEnumMember,
> + QAPISchemaEnumType,
> + QAPISchemaFeature,
> + QAPISchemaObjectType,
> + QAPISchemaObjectTypeMember,
> + QAPISchemaType,
> + QAPISchemaVariants,
> +)
> +from .source import QAPISourceInfo
>
>
> -def gen_visit_decl(name, scalar=False):
> +def gen_visit_decl(name: str, scalar: bool = False) -> str:
More abuse of review to learn: even through we initialize with False, we
still need the type hint?
> c_type = c_name(name) + ' *'
> if not scalar:
> c_type += '*'
[...]
- Re: [PATCH v5 34/36] qapi/visit.py: assert tag_member contains a QAPISchemaEnumType, (continued)
[PATCH v5 33/36] qapi/types.py: remove one-letter variables, John Snow, 2020/10/05
[PATCH v5 35/36] qapi/visit.py: remove unused parameters from gen_visit_object, John Snow, 2020/10/05
[PATCH v5 36/36] qapi/visit.py: add type hint annotations, John Snow, 2020/10/05
- Re: [PATCH v5 36/36] qapi/visit.py: add type hint annotations,
Markus Armbruster <=
Re: [PATCH v5 00/36] qapi: static typing conversion, pt1, Cleber Rosa, 2020/10/05
Re: [PATCH v5 00/36] qapi: static typing conversion, pt1, Markus Armbruster, 2020/10/07