qapi/expr.py: Consolidate check_if_str calls in check_if
commit210fd63104525b6e3154de529565258f19146f1a
authorJohn Snow <jsnow@redhat.com>
Wed, 21 Apr 2021 18:20:26 +0000 (21 14:20 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 30 Apr 2021 10:59:54 +0000 (30 12:59 +0200)
treebd8bac6a9cae991ea561ae21dac00886b20e0f88
parentb9ad358aa057e83f8039a1e222d6941d2bf1f70a
qapi/expr.py: Consolidate check_if_str calls in check_if

This is a small rewrite to address some minor style nits.

Don't compare against the empty list to check for the empty condition, and
move the normalization forward to unify the check on the now-normalized
structure.

With the check unified, the local nested function isn't needed anymore
and can be brought down into the normal flow of the function. With the
nesting level changed, shuffle the error strings around a bit to get
them to fit in 79 columns.

Note: although ifcond is typed as Sequence[str] elsewhere, we *know* that
the parser will produce real, bona-fide lists. It's okay to check
isinstance(ifcond, list) here.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210421182032.3521476-12-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/expr.py