| 4a82e468 | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: type 'info' as Optional[QAPISourceInfo]
For everything typed so far, type this parameter as Optional[QAPISourceInfo].
In the most generic case, QAPISchemaEntity's info field may be None to re
qapi: type 'info' as Optional[QAPISourceInfo]
For everything typed so far, type this parameter as Optional[QAPISourceInfo].
In the most generic case, QAPISchemaEntity's info field may be None to represent types that come from built-in definitions. Although some Entity types may not currently have any built-in definitions, it is not easily possible to constrain the type except on an ad-hoc basis using assertions.
It's easier and simpler, then, to just say it's always an Optional type.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-16-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| cc0747f6 | 01-Feb-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi/gen: Drop support for QAPIGen without a file name
The previous commit removed the only user of QAPIGen(None). Tighten the type hint.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signe
qapi/gen: Drop support for QAPIGen without a file name
The previous commit removed the only user of QAPIGen(None). Tighten the type hint.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-15-jsnow@redhat.com>
show more ...
|
| c6cd7e41 | 01-Feb-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi/commands: Simplify command registry generation
QAPISchemaGenCommandVisitor.visit_command() needs to generate the marshalling function into the current module, and also generate its registration
qapi/commands: Simplify command registry generation
QAPISchemaGenCommandVisitor.visit_command() needs to generate the marshalling function into the current module, and also generate its registration into the ./init system module. The latter is done somewhat awkwardly: .__init__() creates a QAPIGenCCode that will not be written out, each .visit_command() adds its registration to it, and .visit_end() copies its contents into the ./init module it creates.
Instead provide the means to temporarily switch to another module. Create the ./init module in .visit_begin(), and generate its initial part. Add registrations to it in .visit_command(). Finish it in .visit_end().
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-14-jsnow@redhat.com>
show more ...
|
| d921d27c | 01-Feb-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi/gen: Support switching to another module temporarily
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-13-jsno
qapi/gen: Support switching to another module temporarily
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-13-jsnow@redhat.com> [Commit message tweaked]
show more ...
|
| fd9b1603 | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi/gen: write _genc/_genh access shims
Many places assume they can access these fields without checking them first to ensure they are defined. Eliminating the _genc and _genh fields and replacing
qapi/gen: write _genc/_genh access shims
Many places assume they can access these fields without checking them first to ensure they are defined. Eliminating the _genc and _genh fields and replacing them with functional properties that check for correct state can ease the typing overhead by eliminating the Optional[T] return type.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-12-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 39b2d838 | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: centralize the built-in module name definition
Use a constant to make it obvious we're referring to a very specific thing.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193
qapi: centralize the built-in module name definition
Use a constant to make it obvious we're referring to a very specific thing.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-11-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 4ab0ff6d | 01-Feb-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi/gen: Combine ._add_[user|system]_module
With callers to _add_system_module now explicitly using the './' prefix to indicate a system module, there is no longer any reason to have separate inter
qapi/gen: Combine ._add_[user|system]_module
With callers to _add_system_module now explicitly using the './' prefix to indicate a system module, there is no longer any reason to have separate interfaces for adding system vs user modules; use a unified interface that differentiates based on the name.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-10-jsnow@redhat.com>
show more ...
|
| 12893a8e | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: use explicitly internal module names
QAPISchemaModularCVisitor._add_system_module() prefixes './' to its name argument to make it a module name. Pass the module name instead. This will allow
qapi: use explicitly internal module names
QAPISchemaModularCVisitor._add_system_module() prefixes './' to its name argument to make it a module name. Pass the module name instead. This will allow us to coalesce the methods to add modules later on.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-8-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message reworded] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| f3a70592 | 01-Feb-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi/gen: Replace ._begin_system_module()
QAPISchemaModularCVisitor._begin_system_module() is actually just for the builtin module. Rename it to ._begin_builtin_module() and drop its useless @name
qapi/gen: Replace ._begin_system_module()
QAPISchemaModularCVisitor._begin_system_module() is actually just for the builtin module. Rename it to ._begin_builtin_module() and drop its useless @name parameter.
Clarify conditionals in visit_module to make this clear.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-7-jsnow@redhat.com>
show more ...
|
| 98967c24 | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: centralize is_[user|system|builtin]_module methods
Define what a module is and define what kind of a module it is once and for all, in one place.
Signed-off-by: John Snow <jsnow@redhat.com> M
qapi: centralize is_[user|system|builtin]_module methods
Define what a module is and define what kind of a module it is once and for all, in one place.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| a253b3eb | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi/gen: inline _wrap_ifcond into end_if()
We assert _start_if is not None in end_if, but that's opaque to mypy. By inlining _wrap_ifcond, that constraint becomes provable to mypy.
Signed-off-by:
qapi/gen: inline _wrap_ifcond into end_if()
We assert _start_if is not None in end_if, but that's opaque to mypy. By inlining _wrap_ifcond, that constraint becomes provable to mypy.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-5-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| ad121808 | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi/main: handle theoretical None-return from re.match()
Mypy cannot understand that this match can never be None, so help it along.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <202102
qapi/main: handle theoretical None-return from re.match()
Mypy cannot understand that this match can never be None, so help it along.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 3cc01c54 | 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi/events: fix visit_event typing
Actually, the arg_type can indeed be Optional.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-3-jsnow@redhat.com> Reviewed-by: M
qapi/events: fix visit_event typing
Actually, the arg_type can indeed be Optional.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-3-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| b4c0aa59 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/visit.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <e
qapi/visit.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Tested-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-37-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 2cc1eefb | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/visit.py: remove unused parameters from gen_visit_object
And this fixes the pylint report for this file, so make sure we check this in the future, too.
Signed-off-by: John Snow <jsnow@redhat.c
qapi/visit.py: remove unused parameters from gen_visit_object
And this fixes the pylint report for this file, so make sure we check this in the future, too.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Tested-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201009161558.107041-36-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 554df4f3 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/visit.py: assert tag_member contains a QAPISchemaEnumType
This is true by design, but not presently able to be expressed in the type system. An assertion helps mypy understand our constraints.
qapi/visit.py: assert tag_member contains a QAPISchemaEnumType
This is true by design, but not presently able to be expressed in the type system. An assertion helps mypy understand our constraints.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-35-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| dec44d3d | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/types.py: remove one-letter variables
"John, if pylint told you to jump off a bridge, would you?" Hey, if it looked like fun, I might.
Now that this file is clean, enable pylint checks on this
qapi/types.py: remove one-letter variables
"John, if pylint told you to jump off a bridge, would you?" Hey, if it looked like fun, I might.
Now that this file is clean, enable pylint checks on this file.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-34-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| cd073c8f | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/types.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <e
qapi/types.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-33-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 9abddb5b | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/gen.py: delint with pylint
'fp' and 'fd' are self-evident in context, add them to the list of OK names.
_top and _bottom also need to stay standard methods because some users override the meth
qapi/gen.py: delint with pylint
'fp' and 'fd' are self-evident in context, add them to the list of OK names.
_top and _bottom also need to stay standard methods because some users override the method and need to use `self`. Tell pylint to shush.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-32-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| cc6263c4 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/gen.py: update write() to be more idiomatic
Make the file handling here just a tiny bit more idiomatic. (I realize this is heavily subjective.)
Use exist_ok=True for os.makedirs and remove the
qapi/gen.py: update write() to be more idiomatic
Make the file handling here just a tiny bit more idiomatic. (I realize this is heavily subjective.)
Use exist_ok=True for os.makedirs and remove the exception, use fdopen() to wrap the file descriptor in a File-like object, and use a context manager for managing the file pointer.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20201009161558.107041-31-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 0cbd5b05 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/gen.py: Remove unused parameter
_module_dirname doesn't use the 'what' argument, so remove it.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Re
qapi/gen.py: Remove unused parameter
_module_dirname doesn't use the 'what' argument, so remove it.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-30-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 17d40c39 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/gen.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <eha
qapi/gen.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-28-jsnow@redhat.com> Message-Id: <20201009161558.107041-29-jsnow@redhat.com> [mypy.ini update squashed in] Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 3ae1c848 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/gen: Make _is_user_module() return bool
_is_user_module() returns thruth values. The next commit wants it to return bool. Make it so.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by:
qapi/gen: Make _is_user_module() return bool
_is_user_module() returns thruth values. The next commit wants it to return bool. Make it so.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201009161558.107041-27-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message rewritten] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|