qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 21/23] qapi/schema: add type hints


From: John Snow
Subject: Re: [PATCH v4 21/23] qapi/schema: add type hints
Date: Fri, 15 Mar 2024 13:37:05 -0400



On Fri, Mar 15, 2024, 10:03 AM Markus Armbruster <armbru@redhat.com> wrote:
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.

Ah! Very good catch.


>          ent = self._entity_dict.get(name)
>          if typ and not isinstance(ent, typ):
>              return None
>          return ent

[...]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]