qemu/scripts/qapi
John Snow 9beda22dcb qapi/schema: Don't initialize "members" with None
Declare, but don't initialize the "members" field with type
List[QAPISchemaObjectTypeMember].

This simplifies the typing from what would otherwise be
Optional[List[T]] to merely List[T]. This removes the need to add
assertions to several callsites that this value is not None - which it
never will be after the delayed initialization in check() anyway.

The type declaration without initialization trick will cause accidental
uses of this field prior to full initialization to raise an
AttributeError.

(Note that it is valid to have an empty members list, see the internal
q_empty object as an example. For this reason, we cannot use the empty
list as a replacement test for full initialization and instead rely on
the _checked/_check_complete fields.)

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240315152301.3621858-17-armbru@redhat.com>
2024-04-24 10:03:54 +02:00
..
.flake8 qapi: Update flake8 config 2023-02-23 12:49:39 +01:00
.isort.cfg
__init__.py
commands.py qapi: Require boxed for conditional command and event arguments 2023-04-24 15:21:39 +02:00
common.py qapi: Avoid generating C identifier 'linux' 2022-07-13 12:19:18 +03:00
error.py qapi/error: Add type hints 2021-04-30 12:59:54 +02:00
events.py qapi: Start to elide redundant has_FOO in generated C 2022-12-13 18:31:37 +01:00
expr.py qapi: Fix to reject 'data': 'mumble' in struct 2023-04-24 15:21:39 +02:00
gen.py qapi: re-establish linting baseline 2023-10-19 07:02:29 +02:00
introspect.py qapi: Assert built-in types exist 2024-04-24 10:03:54 +02:00
main.py qapi: Fix error message format regression 2023-04-24 15:09:10 +02:00
mypy.ini Python: Drop support for Python 3.7 2023-09-07 13:32:37 +02:00
parser.py qapi/parser: shush up pylint 2024-04-24 10:03:54 +02:00
pylintrc qapi/schema: add pylint suppressions 2024-04-24 10:03:54 +02:00
schema.py qapi/schema: Don't initialize "members" with None 2024-04-24 10:03:54 +02:00
source.py qapi: Require member documentation (with loophole) 2024-02-12 10:04:31 +01:00
types.py qapi: Start to elide redundant has_FOO in generated C 2022-12-13 18:31:37 +01:00
visit.py qapi: Fix code generated for optional conditional struct member 2023-04-24 15:21:39 +02:00