[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 21/23] qapi/schema: add type hints
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v4 21/23] qapi/schema: add type hints |
Date: |
Fri, 15 Mar 2024 15:03:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
John Snow <jsnow@redhat.com> writes:
> This patch only adds type hints, which aren't utilized at runtime and
> don't change the behavior of this module in any way.
>
> In a scant few locations, type hints are removed where no longer
> necessary due to inference power from typing all of the rest of
> creation; and any type hints that no longer need string quotes are
> changed.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qapi/schema.py | 568 ++++++++++++++++++++++++++++-------------
> 1 file changed, 396 insertions(+), 172 deletions(-)
>
> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> index 3b8c2ebbb5f..d2faaea6eac 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
[...]
> @@ -1006,18 +1181,27 @@ def _def_definition(self, defn):
> defn.info, "%s is already defined" % other_defn.describe())
> self._entity_dict[defn.name] = defn
>
> - def lookup_entity(self, name, typ=None):
> + def lookup_entity(
> + self,
> + name: str,
> + typ: Optional[type] = None,
> + ) -> Optional[QAPISchemaEntity]:
Optional[QAPISchemaDefinition], actually.
> ent = self._entity_dict.get(name)
> if typ and not isinstance(ent, typ):
> return None
> return ent
[...]
- Re: [PATCH v4 16/23] qapi/schema: Don't initialize "members" with `None`, (continued)
[PATCH v4 22/23] qapi/schema: turn on mypy strictness, John Snow, 2024/03/13
[PATCH v4 19/23] qapi/parser: demote QAPIExpression to Dict[str, Any], John Snow, 2024/03/13
[PATCH v4 15/23] qapi/schema: add _check_complete flag, John Snow, 2024/03/13
[PATCH v4 11/23] qapi/schema: assert resolve_type has 'info' and 'what' args on error, John Snow, 2024/03/13
[PATCH v4 20/23] qapi/parser.py: assert member.info is present in connect_member, John Snow, 2024/03/13
[PATCH v4 21/23] qapi/schema: add type hints, John Snow, 2024/03/13
- Re: [PATCH v4 21/23] qapi/schema: add type hints,
Markus Armbruster <=
[PATCH v4 08/23] qapi/schema: make c_type() and json_type() abstract methods, John Snow, 2024/03/13
[PATCH v4 06/23] qapi/schema: declare type for QAPISchemaObjectTypeMember.type, John Snow, 2024/03/13
[PATCH v4 10/23] qapi/schema: add type narrowing to lookup_type(), John Snow, 2024/03/13
[PATCH v4 23/23] qapi/schema: remove unnecessary asserts, John Snow, 2024/03/13
Re: [PATCH v4 00/23] qapi: statically type schema.py, Markus Armbruster, 2024/03/14