[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/25] qapi/schema.py: Constrain type of QAPISchemaObjectType mem
From: |
John Snow |
Subject: |
[PATCH 11/25] qapi/schema.py: Constrain type of QAPISchemaObjectType members field |
Date: |
Tue, 22 Sep 2020 18:44:47 -0400 |
This must always be QAPISchemaObjectTypeMember, and we do check and
enforce this -- but because the seen dict is invariant and check methods
need to operate in terms of a more abstract type, we need to tell the
type system to believe us.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/schema.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 62b1a7e890..57343a1002 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -17,6 +17,7 @@
import os
import re
from collections import OrderedDict
+from typing import cast, List
from .common import c_name, POINTER_SUFFIX
from .error import QAPISourceError, QAPISemError
@@ -391,7 +392,10 @@ def check(self, schema):
for m in self.local_members:
m.check(schema)
m.check_clash(self.info, seen)
- members = seen.values()
+
+ # check_clash is abstract, but local_members is asserted to be
+ # Sequence[QAPISchemaObjectTypeMember]. Cast to the narrower type.
+ members = cast(List[QAPISchemaObjectTypeMember], list(seen.values()))
if self.variants:
self.variants.check(schema, seen)
--
2.26.2
- [PATCH 02/25] qapi/schema.py: Move meta-type into class instances, (continued)
- [PATCH 02/25] qapi/schema.py: Move meta-type into class instances, John Snow, 2020/09/22
- [PATCH 04/25] qapi/schema.py: constrain QAPISchemaObjectType base type, John Snow, 2020/09/22
- [PATCH 06/25] qapi/schema.py: constrain QAPISchemaEvent arg_type type, John Snow, 2020/09/22
- [PATCH 05/25] qapi/schema.py: constrain QAPISchemaObjectTypeMember arg_type type, John Snow, 2020/09/22
- [PATCH 09/25] qapi/schema.py: remove superfluous assert, John Snow, 2020/09/22
- [PATCH 07/25] qapi/schema.py: constrain tag_member type, John Snow, 2020/09/22
- [PATCH 14/25] qapi/schema.py: Assert variants of an object are also objects, John Snow, 2020/09/22
- [PATCH 10/25] qapi/schema.py: Add assertion to ifcond property, John Snow, 2020/09/22
- [PATCH 21/25] qapi/schema.py: disable pylint line limit, John Snow, 2020/09/22
- [PATCH 12/25] qapi/schema.py: remove 'and' from non-bool rvalue expressions, John Snow, 2020/09/22
- [PATCH 11/25] qapi/schema.py: Constrain type of QAPISchemaObjectType members field,
John Snow <=
- [PATCH 08/25] qapi/schema.py: Allow alternate_type to assert, John Snow, 2020/09/22
- [PATCH 13/25] qapi/schema.py: Test type of self.ret_type instead of local temp, John Snow, 2020/09/22
- [PATCH 16/25] qapi/schema.py: enable checking, John Snow, 2020/09/22
- [PATCH 24/25] qapi/schema.py: Add module docstring, John Snow, 2020/09/22
- [PATCH 20/25] qapi/schema.py: Replace one-letter variable names, John Snow, 2020/09/22
- [PATCH 18/25] qapi/schema.py: Add pylint warning suppressions, John Snow, 2020/09/22
- [PATCH 25/25] qapi/schema.py: Use python3 style super(), John Snow, 2020/09/22
- [PATCH 23/25] qapi/schema.py: enable pylint checks, John Snow, 2020/09/22
- [PATCH 19/25] qapi/schema.py: Convert several methods to classmethods, John Snow, 2020/09/22
- [PATCH 15/25] qapi/schema.py: add type hint annotations, John Snow, 2020/09/22