Message ID | 20201026194251.11075-5-jsnow@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | qapi: static typing conversion, pt2 | expand |
On Mon, Oct 26, 2020 at 03:42:44PM -0400, John Snow wrote: > This is necessary to keep mypy passing in the next patch when we add > preliminary type hints. It will be removed shortly. > > Signed-off-by: John Snow <jsnow@redhat.com> > --- Reviewed-by: Cleber Rosa <crosa@redhat.com>
diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index fafec94e022..63f721ebfb6 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,6 +10,8 @@ See the COPYING file in the top-level directory. """ +from typing import Optional, Sequence, cast + from .common import ( c_name, gen_endif, @@ -30,6 +32,7 @@ def _make_tree(obj, ifcond, features, extra=None): if ifcond: extra['if'] = ifcond if features: + assert isinstance(obj, dict) obj['features'] = [(f.name, {'if': f.ifcond}) for f in features] if extra: return (obj, extra) @@ -43,7 +46,7 @@ def indent(level): if isinstance(obj, tuple): ifobj, extra = obj - ifcond = extra.get('if') + ifcond = cast(Optional[Sequence[str]], extra.get('if')) comment = extra.get('comment') ret = '' if comment:
This is necessary to keep mypy passing in the next patch when we add preliminary type hints. It will be removed shortly. Signed-off-by: John Snow <jsnow@redhat.com> --- scripts/qapi/introspect.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)