[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/7] qapi/expr: add typing workaround for AbstractSet
From: |
John Snow |
Subject: |
[PATCH v2 4/7] qapi/expr: add typing workaround for AbstractSet |
Date: |
Tue, 7 Feb 2023 21:13:03 -0500 |
As part of attempting to unify the JSON types, I discovered that mypy
believes that `Mapping[str, ...].keys() & Set[str]` produces an
`AbstractSet[str]` and not a `Set[str]`.
As a result, mypy is unsure if the .pop() is safe.
Eh, fine, just wrap the expression in a set() constructor to force it to
be a mutable type.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/expr.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py
index 338c9ea4131..95a25758fed 100644
--- a/scripts/qapi/expr.py
+++ b/scripts/qapi/expr.py
@@ -610,8 +610,8 @@ def check_expr(pexpr: ParsedExpression) -> None:
if 'include' in expr:
return
- metas = expr.keys() & {'enum', 'struct', 'union', 'alternate',
- 'command', 'event'}
+ metas = set(expr.keys() & {
+ 'enum', 'struct', 'union', 'alternate', 'command', 'event'})
if len(metas) != 1:
raise QAPISemError(
info,
--
2.39.0