[PATCH 22/27] docs/qapi-domain: add warnings for malformed field lists

2024-04-18 Thread John Snow
r checking in action. The next commit drops the erroneous fields. Signed-off-by: John Snow --- docs/conf.py | 12 docs/qapi/index.rst| 27 + docs/sphinx/qapi-domain.py | 59 ++ 3 files changed, 98 insertions(+) diff

[PATCH 09/27] docs/qapi-domain: add "Arguments:" field lists

2024-04-18 Thread John Snow
t what you want. Signed-off-by: John Snow --- docs/qapi/index.rst| 15 +++ docs/sphinx/qapi-domain.py | 14 -- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/qapi/index.rst b/docs/qapi/index.rst index 33b9349a3ee..197587bbc81 100644 --- a

[PATCH 26/27] docs/qapi-domain: RFC patch - Add one last sample command

2024-04-18 Thread John Snow
Just to have a bit more to look at in the generated doc, here's a fairly complex command with a lot of bells and whistles. Signed-off-by: John Snow --- docs/qapi/index.rst | 67 + 1 file changed, 67 insertions(+) diff --git a/docs/qapi/index.rst b

[PATCH 03/27] docs/qapi-module: add QAPI domain object registry

2024-04-18 Thread John Snow
is adapted directly from sphinx.domains.python; it is unclear to me if there ever would be a collision on merge, hence the assertion. I haven't been able to trigger it or find better code to use as a template, so probably I'll just leave the assertion in there. Signed-off-by: John Snow --- docs

[PATCH 00/27] Add qapi-domain Sphinx extension

2024-04-18 Thread John Snow
Hope you like it! --js Harmonie Snow (1): docs/qapi-domain: add CSS styling John Snow (26): docs/sphinx: create QAPI domain extension stub docs/qapi-domain: add qapi:module directive docs/qapi-module: add QAPI domain object registry docs/qapi-domain: add QAPI index docs/qapi-domain: add re

[PATCH 05/27] docs/qapi-domain: add resolve_any_xref()

2024-04-18 Thread John Snow
in this series.) Once again, this code is based very heavily on sphinx.domains.python. Signed-off-by: John Snow --- docs/qapi/index.rst| 7 +++ docs/sphinx/qapi-domain.py | 95 +- 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/docs/qapi

[PATCH 12/27] docs/qapi-domain: add "Returns:" field lists

2024-04-18 Thread John Snow
both the imperative and indicative forms (:return: and :returns:) to allow doc writers to use whichever mood "feels right" in the source document. The rendered output will always use the "Returns:" label, however. I'm sure you'll let me know how you feel about that. O:-) Signed-off-b

Re: [PATCH 3/3] qapi: Fix bogus documentation of query-migrationthreads

2024-03-22 Thread John Snow
> > The command name violates QAPI naming rules: it should be > query-migration-threads. Too late to fix. > > Reported-by: John Snow > Fixes: 671326201dac (migration: Introduce interface query-migrationthreads) > Signed-off-by: Markus Armbruster > Reviewed-by: John Snow -

Re: [PATCH 01/12] qapi: Drop stray Arguments: line from qmp_capabilities docs

2024-03-22 Thread John Snow
On Fri, Mar 22, 2024, 10:09 AM Markus Armbruster wrote: > Reported-by: John Snow > Fixes: 119ebac1feb2 (qapi-schema: use generated marshaller for > 'qmp_capabilities') > Signed-off-by: Markus Armbruster > Reviewed-by: John Snow --- > qapi/control.json | 2 -- > 1 file

Re: [PATCH v5 24/25] qapi: Tighten check whether implicit object type already exists

2024-03-19 Thread John Snow
On Tue, Mar 19, 2024, 12:02 PM Markus Armbruster wrote: > John Snow writes: > > > On Fri, Mar 15, 2024, 11:23 AM Markus Armbruster > wrote: > > > >> Entities with names starting with q_obj_ are implicit object types. > >> Therefore, QAPISchema._make_

Re: [PATCH v5 25/25] qapi: Dumb down QAPISchema.lookup_entity()

2024-03-19 Thread John Snow
urn typ > +typ = self.lookup_entity(name) > +if isinstance(typ, QAPISchemaType): > +return typ > + return None > > def resolve_type( > self, > -- > 2.44.0 > Sure, dealer's choice. with your commit message fixup: Reviewed-by: John Snow >

Re: [PATCH v5 24/25] qapi: Tighten check whether implicit object type already exists

2024-03-19 Thread John Snow
Seems obviously fine, though I don't suppose this narrowing will be "remembered" by the type system. Do we care? Reviewed-by: John Snow >

Re: [PATCH v5 12/25] qapi: Assert built-in types exist

2024-03-19 Thread John Snow
pe to work queue if new > if typ not in self._used_types: > self._used_types.append(typ) > -- > 2.44.0 > Yeah, if you like this more, go ahead. I know it works because I did it this way at one point! Matter of taste and preference etc. Reviewed-by: John Snow >

Re: [PATCH v4 21/23] qapi/schema: add type hints

2024-03-15 Thread John Snow
On Fri, Mar 15, 2024, 10:03 AM Markus Armbruster wrote: > John Snow writes: > > > This patch only adds type hints, which aren't utilized at runtime and > > don't change the behavior of this module in any way. > > > > In a scant few locations, type hints are removed

Re: [PATCH v4 00/23] qapi: statically type schema.py

2024-03-14 Thread John Snow
On Thu, Mar 14, 2024, 10:43 AM Markus Armbruster wrote: > John Snow writes: > > > This is *v4*, for some definitions of "version" and "four". > > Series > Reviewed-by: Markus Armbruster > > I'll replace PATCH 12, not because it's wrong, just bec

Re: [PATCH v4 05/23] qapi: create QAPISchemaDefinition

2024-03-14 Thread John Snow
On Thu, Mar 14, 2024, 10:04 AM Markus Armbruster wrote: > John Snow writes: > > > On Thu, Mar 14, 2024, 5:12 AM Markus Armbruster > wrote: > > > >> John Snow writes: > >> > >> > Include entities don't have names, but we generally expec

Re: [PATCH v4 16/23] qapi/schema: Don't initialize "members" with `None`

2024-03-14 Thread John Snow
On Thu, Mar 14, 2024, 9:58 AM Markus Armbruster wrote: > John Snow writes: > > > On Thu, Mar 14, 2024, 9:01 AM Markus Armbruster > wrote: > > > >> John Snow writes: > >> > >> > Declare, but don't initialize the "members

Re: [PATCH v4 16/23] qapi/schema: Don't initialize "members" with `None`

2024-03-14 Thread John Snow
On Thu, Mar 14, 2024, 9:01 AM Markus Armbruster wrote: > John Snow writes: > > > Declare, but don't initialize the "members" field with type > > List[QAPISchemaObjectTypeMember]. > > > > This simplifies the typing from what would otherwise b

Re: [PATCH v4 05/23] qapi: create QAPISchemaDefinition

2024-03-14 Thread John Snow
On Thu, Mar 14, 2024, 5:12 AM Markus Armbruster wrote: > John Snow writes: > > > Include entities don't have names, but we generally expect "entities" to > > have names. Reclassify all entities with names as *definitions*, leaving > > the nameless include enti

Re: [PATCH v3 14/20] qapi/schema: Don't initialize "members" with `None`

2024-03-13 Thread John Snow
On Wed, Mar 13, 2024, 2:57 AM Markus Armbruster wrote: > John Snow writes: > > > On Tue, Feb 20, 2024 at 10:03 AM Markus Armbruster > wrote: > >> > >> John Snow writes: > >> > >> > Declare, but don't initialize the "memb

[PATCH v4 05/23] qapi: create QAPISchemaDefinition

2024-03-12 Thread John Snow
ers expect for properties of an "entity". Suggested-by: Markus Armbruster Signed-off-by: John Snow --- scripts/qapi/schema.py | 144 +++-- 1 file changed, 82 insertions(+), 62 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.

[PATCH v4 09/23] qapi/schema: adjust type narrowing for mypy's benefit

2024-03-12 Thread John Snow
"Optional[QAPISchemaObjectType]") [assignment] qapi/schema.py:893: error: Incompatible types in assignment (expression has type "QAPISchemaType", variable has type "Optional[QAPISchemaObjectType]") [assignment] A simple change to use a temporary variable helps the med

[PATCH v4 21/23] qapi/schema: add type hints

2024-03-12 Thread John Snow
need string quotes are changed. Signed-off-by: John Snow --- scripts/qapi/schema.py | 568 - 1 file changed, 396 insertions(+), 172 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 3b8c2ebbb5f..d2faaea6eac 100644 --- a/scripts

[PATCH v4 12/23] qapi: use schema.resolve_type instead of schema.lookup_type

2024-03-12 Thread John Snow
SchemaType = ret which can be replaced with the simpler: typ = resolve_type("foo") Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 ++-- scripts/qapi/schema.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/introspect.py b/script

[PATCH v4 15/23] qapi/schema: add _check_complete flag

2024-03-12 Thread John Snow
l to check()) in order to simplify the static typing of that field; avoiding the need of assertions littered at many callsites to eliminate the possibility of the None value. Signed-off-by: John Snow --- scripts/qapi/schema.py | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sc

[PATCH v4 03/23] qapi: sort pylint suppressions

2024-03-12 Thread John Snow
Suggested-by: Markus Armbruster Signed-off-by: John Snow --- scripts/qapi/pylintrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index 90546df5345..1342412c3cf 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi

[PATCH v4 07/23] qapi/schema: declare type for QAPISchemaArrayType.element_type

2024-03-12 Thread John Snow
-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 8440a7243d8..c549a4e3bd0 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -381,7 +381,7 @@ def __init__(self, name

[PATCH v4 22/23] qapi/schema: turn on mypy strictness

2024-03-12 Thread John Snow
This patch can be rolled in with the previous one once the series is ready for merge, but for work-in-progress' sake, it's separate here. Signed-off-by: John Snow --- scripts/qapi/mypy.ini | 5 - 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini

[PATCH v4 14/23] qapi/schema: assert info is present when necessary

2024-03-12 Thread John Snow
the hump, to enable adding type hints in a forthcoming commit. Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 22e065fc13d..d514b3c28f6 100644 --- a/scripts/qapi/schema.py +++ b/scripts

[PATCH v4 13/23] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type

2024-03-12 Thread John Snow
Optional[str]. mypy does not know that 'info', when it is a QAPISourceInfo object, cannot ever be false.) Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 58ec3a7c41c

[PATCH v4 18/23] qapi/schema: assert inner type of QAPISchemaVariants in check_clash()

2024-03-12 Thread John Snow
s enforced at runtime in QAPISchemaVariants.check(). This relationship is not embedded in the type system though, so QAPISchemaVariants.check_clash() needs to re-assert this property in order to call QAPISchemaVariant.type.check_clash(). Signed-off-by: John Snow --- scripts/qapi/schema.py | 5 +++

[PATCH v4 02/23] qapi/parser: shush up pylint

2024-03-12 Thread John Snow
Shhh! Signed-off-by: John Snow --- scripts/qapi/parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index fed88e9074d..ec4ebef4e33 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -607,6 +607,7 @@ class QAPIDoc

[PATCH v4 23/23] qapi/schema: remove unnecessary asserts

2024-03-12 Thread John Snow
With strict typing enabled, these runtime statements aren't necessary anymore; we can prove them statically. Signed-off-by: John Snow --- scripts/qapi/schema.py | 25 - 1 file changed, 25 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index

[PATCH v4 10/23] qapi/schema: add type narrowing to lookup_type()

2024-03-12 Thread John Snow
This function is a bit hard to type as-is; mypy needs some assertions to assist with the type narrowing. Signed-off-by: John Snow --- scripts/qapi/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index eeecdda1b58

[PATCH v4 08/23] qapi/schema: make c_type() and json_type() abstract methods

2024-03-12 Thread John Snow
These methods should always return a str, it's only the default abstract implementation that doesn't. They can be marked "abstract", which requires subclasses to override the method with the proper return type. Signed-off-by: John Snow --- scripts/qapi/schema.py | 5 - 1 file

[PATCH v4 19/23] qapi/parser: demote QAPIExpression to Dict[str, Any]

2024-03-12 Thread John Snow
strictness improvements later. Signed-off-by: John Snow --- scripts/qapi/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index ec4ebef4e33..2f3c704fa24 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -

[PATCH v4 16/23] qapi/schema: Don't initialize "members" with `None`

2024-03-12 Thread John Snow
pty 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 --- scripts/qapi/schema.py | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git

[PATCH v4 17/23] qapi/schema: fix typing for QAPISchemaVariants.tag_member

2024-03-12 Thread John Snow
the typing in quite a few places and avoids needing to assert that the "tag_member is not None" at a dozen callsites, which can be confusing and suggest the wrong thing to a drive-by contributor. Signed-off-by: John Snow --- scripts/qapi/schema.py | 22 +++-

[PATCH v4 00/23] qapi: statically type schema.py

2024-03-12 Thread John Snow
api/parser: demote QAPIExpression to Dict[str, Any]' 017/19:[0042] [FC] 'qapi/schema: add type hints' Mostly contextual changes. 018/19:[] [--] 'qapi/schema: turn on mypy strictness' 019/19:[0006] [FC] 'qapi/schema: remove unnecessary asserts' Zapped a few more. John Snow (23): qapi/

[PATCH v4 20/23] qapi/parser.py: assert member.info is present in connect_member

2024-03-12 Thread John Snow
Signed-off-by: John Snow --- scripts/qapi/parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 2f3c704fa24..7b13a583ac1 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -707,6 +707,7 @@ def append_line(self, line

[PATCH v4 11/23] qapi/schema: assert resolve_type has 'info' and 'what' args on error

2024-03-12 Thread John Snow
tually use a None value in practice, currently. Signed-off-by: John Snow --- scripts/qapi/schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index b157a3b2bd8..f5c7789d98f 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -99

[PATCH v4 01/23] qapi/parser: fix typo - self.returns.info => self.errors.info

2024-03-12 Thread John Snow
Small copy-pasto. The correct info field to use in this conditional block is self.errors.info. Fixes: 3a025d3d1ffa Signed-off-by: John Snow --- scripts/qapi/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index

[PATCH v4 06/23] qapi/schema: declare type for QAPISchemaObjectTypeMember.type

2024-03-12 Thread John Snow
/schema.py:657: error: "None" has no attribute "alternate_qtype" [attr-defined] qapi/schema.py:662: error: "None" has no attribute "describe" [attr-defined] Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-

[PATCH v4 04/23] qapi/schema: add pylint suppressions

2024-03-12 Thread John Snow
With this patch, pylint is happy with the file, so enable it in the configuration. Signed-off-by: John Snow Reviewed-by: Markus Armbruster --- scripts/qapi/pylintrc | 5 - scripts/qapi/schema.py | 5 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/qapi

Re: [PATCH v3 14/20] qapi/schema: Don't initialize "members" with `None`

2024-03-12 Thread John Snow
On Tue, Feb 20, 2024 at 10:03 AM Markus Armbruster wrote: > > John Snow writes: > > > Declare, but don't initialize the "members" field with type > > List[QAPISchemaObjectTypeMember]. > > > > This simplifies the typing from what would otherwis

Re: [PATCH v3 14/20] qapi/schema: Don't initialize "members" with `None`

2024-03-12 Thread John Snow
On Tue, Feb 20, 2024 at 10:03 AM Markus Armbruster wrote: > > John Snow writes: > > > Declare, but don't initialize the "members" field with type > > List[QAPISchemaObjectTypeMember]. > > > > This simplifies the typing from what would otherwis

Re: [PATCH v3 13/20] qapi/schema: split "checked" field into "checking" and "checked"

2024-03-12 Thread John Snow
On Tue, Feb 20, 2024 at 8:29 AM Markus Armbruster wrote: > > John Snow writes: > > > Instead of using the None value for the members field, use a dedicated > > "checking" value to detect recursive misconfigurations. > > > > This is intended to ass

Re: [PATCH v3 10/20] qapi: use schema.resolve_type instead of schema.lookup_type

2024-03-11 Thread John Snow
On Tue, Feb 20, 2024 at 10:18 AM Markus Armbruster wrote: > > John Snow writes: > > > the function lookup_type() is capable of returning None, but some > > callers aren't prepared for that and assume it will always succeed. For > > static type analysis purposes, thi

Re: [PATCH v3 09/20] qapi/schema: assert resolve_type has 'info' and 'what' args on error

2024-03-11 Thread John Snow
On Tue, Feb 20, 2024 at 5:48 AM Markus Armbruster wrote: > > John Snow writes: > > > resolve_type() is generally used to resolve configuration-provided type > > names into type objects, and generally requires valid 'info' and 'what' > > parame

Re: [PATCH v3 08/20] qapi/schema: add type narrowing to lookup_type()

2024-03-11 Thread John Snow
On Mon, Mar 11, 2024 at 2:14 PM John Snow wrote: > > On Tue, Feb 20, 2024 at 5:39 AM Markus Armbruster wrote: > > > > John Snow writes: > > > > > This function is a bit hard to type as-is; mypy needs some assertions to > > > assist with the type narro

Re: [PATCH v3 08/20] qapi/schema: add type narrowing to lookup_type()

2024-03-11 Thread John Snow
On Tue, Feb 20, 2024 at 5:39 AM Markus Armbruster wrote: > > John Snow writes: > > > This function is a bit hard to type as-is; mypy needs some assertions to > > assist with the type narrowing. > > > > Signed-off-by: John Snow > > --- > > scripts/q

[PATCH v3 07/20] qapi/schema: adjust type narrowing for mypy's benefit

2024-02-01 Thread John Snow
"Optional[QAPISchemaObjectType]") [assignment] qapi/schema.py:893: error: Incompatible types in assignment (expression has type "QAPISchemaType", variable has type "Optional[QAPISchemaObjectType]") [assignment] A simple change to use a temporary variable helps the med

[PATCH v3 14/20] qapi/schema: Don't initialize "members" with `None`

2024-02-01 Thread John Snow
pty 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/_checking fields.) Signed-off-by: John Snow --- scripts/qapi/schema.py | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sc

[PATCH v3 06/20] qapi/schema: make c_type() and json_type() abstract methods

2024-02-01 Thread John Snow
These methods should always return a str, it's only the default abstract implementation that doesn't. They can be marked "abstract", which requires subclasses to override the method with the proper return type. Signed-off-by: John Snow --- scripts/qapi/schema.py | 5 - 1 file

[PATCH v3 12/20] qapi/schema: assert info is present when necessary

2024-02-01 Thread John Snow
the hump, to enable adding type hints in a forthcoming commit. Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index ae350f64a8f..d4d3c3bbcee 100644 --- a/scripts/qapi/schema.py +++ b/scripts

[PATCH v3 02/20] qapi/schema: add pylint suppressions

2024-02-01 Thread John Snow
With this patch, pylint is happy with the file, so enable it in the configuration. Signed-off-by: John Snow Reviewed-by: Markus Armbruster --- scripts/qapi/pylintrc | 5 - scripts/qapi/schema.py | 5 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/qapi

[PATCH v3 09/20] qapi/schema: assert resolve_type has 'info' and 'what' args on error

2024-02-01 Thread John Snow
None value in practice, currently. Signed-off-by: John Snow --- scripts/qapi/schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index e617abb03af..573be7275a6 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1004,6 +100

[PATCH v3 19/20] qapi/schema: turn on mypy strictness

2024-02-01 Thread John Snow
This patch can be rolled in with the previous one once the series is ready for merge, but for work-in-progress' sake, it's separate here. Signed-off-by: John Snow --- scripts/qapi/mypy.ini | 5 - 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini

[PATCH v3 04/20] qapi/schema: declare type for QAPISchemaObjectTypeMember.type

2024-02-01 Thread John Snow
/schema.py:657: error: "None" has no attribute "alternate_qtype" [attr-defined] qapi/schema.py:662: error: "None" has no attribute "describe" [attr-defined] Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-

[PATCH v3 15/20] qapi/schema: fix typing for QAPISchemaVariants.tag_member

2024-02-01 Thread John Snow
the typing in quite a few places and avoids needing to assert that the "tag_member is not None" at a dozen callsites, which can be confusing and suggest the wrong thing to a drive-by contributor. Signed-off-by: John Snow --- scripts/qapi/schema.py | 22 +++-

[PATCH v3 13/20] qapi/schema: split "checked" field into "checking" and "checked"

2024-02-01 Thread John Snow
after the final call to check()) in order to simplify static typing of that field, by avoiding needing assertions littered at many callsites. Signed-off-by: John Snow --- scripts/qapi/schema.py | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/sche

[PATCH v3 01/20] qapi: sort pylint suppressions

2024-02-01 Thread John Snow
Suggested-by: Markus Armbruster Signed-off-by: John Snow --- scripts/qapi/pylintrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index 90546df5345..1342412c3cf 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi

[PATCH v3 18/20] qapi/schema: add type hints

2024-02-01 Thread John Snow
need string quotes are changed. Signed-off-by: John Snow --- scripts/qapi/schema.py | 572 - 1 file changed, 398 insertions(+), 174 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 4d153b216c0..319c8475d21 100644 --- a/scripts

[PATCH v3 05/20] qapi/schema: declare type for QAPISchemaArrayType.element_type

2024-02-01 Thread John Snow
-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 74a32656249..ac34e2781de 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -389,7 +389,7 @@ def __init__(self, name

[PATCH v3 20/20] qapi/schema: remove unnecessary asserts

2024-02-01 Thread John Snow
With strict typing enabled, these runtime statements aren't necessary anymore; we can prove them statically. Signed-off-by: John Snow --- scripts/qapi/schema.py | 25 - 1 file changed, 25 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index

[PATCH v3 03/20] qapi: create QAPISchemaDefinition

2024-02-01 Thread John Snow
ers expect for properties of an "entity". Suggested-by: Markus Armbruster Signed-off-by: John Snow --- scripts/qapi/schema.py | 152 - 1 file changed, 88 insertions(+), 64 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.

[PATCH v3 11/20] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type

2024-02-01 Thread John Snow
Optional[str]. mypy does not know that 'info', when it is a QAPISourceInfo object, cannot ever be false.) Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 074897ee4fb

[PATCH v3 10/20] qapi: use schema.resolve_type instead of schema.lookup_type

2024-02-01 Thread John Snow
SchemaType = ret which can be replaced with the simpler: typ = resolve_type("foo") Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4 ++-- scripts/qapi/schema.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/introspect.py b/script

[PATCH v3 08/20] qapi/schema: add type narrowing to lookup_type()

2024-02-01 Thread John Snow
This function is a bit hard to type as-is; mypy needs some assertions to assist with the type narrowing. Signed-off-by: John Snow --- scripts/qapi/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 043ee7556e6

[PATCH v3 16/20] qapi/schema: assert inner type of QAPISchemaVariants in check_clash()

2024-02-01 Thread John Snow
s enforced at runtime in QAPISchemaVariants.check(). This relationship is not embedded in the type system though, so QAPISchemaVariants.check_clash() needs to re-assert this property in order to call QAPISchemaVariant.type.check_clash(). Signed-off-by: John Snow --- scripts/qapi/schema.py | 5 +++

[PATCH v3 00/20] qapi: statically type schema.py

2024-02-01 Thread John Snow
019/19:[0006] [FC] 'qapi/schema: remove unnecessary asserts' Zapped a few more. John Snow (20): qapi: sort pylint suppressions qapi/schema: add pylint suppressions qapi: create QAPISchemaDefinition qapi/schema: declare type for QAPISchemaObjectTypeMember.type qapi/schema: declare type for

[PATCH v3 17/20] qapi/parser: demote QAPIExpression to Dict[str, Any]

2024-02-01 Thread John Snow
strictness improvements later. Signed-off-by: John Snow --- scripts/qapi/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 48cd55a38cc..422de616a35 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -

Re: [PATCH 4/7] docs/interop/bitmaps: Clean up a reference to qemu-qmp-ref

2024-02-01 Thread John Snow
On Thu, Feb 1, 2024 at 4:45 PM John Snow wrote: > > On Sat, Jan 20, 2024 at 4:53 AM Markus Armbruster wrote: > > > > docs/interop/bitmaps.rst uses references like > > > > `qemu-qmp-ref `_ > > `query-block `_ > > > > to refer to and into

Re: [PATCH 4/7] docs/interop/bitmaps: Clean up a reference to qemu-qmp-ref

2024-02-01 Thread John Snow
On Sat, Jan 20, 2024 at 4:53 AM Markus Armbruster wrote: > > docs/interop/bitmaps.rst uses references like > > `qemu-qmp-ref `_ > `query-block `_ > > to refer to and into docs/interop/qemu-qmp-ref.rst. > > Clean up the former: use :doc:`qemu-qmp-ref`. > > I don't know how to clean up the

Re: [PATCH 13/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member

2024-02-01 Thread John Snow
On Wed, Jan 17, 2024 at 5:53 AM Markus Armbruster wrote: > > Still more... > Would you hate me if I suggested that we punt this to after type checking is applied? i.e. let's do the stupid @property thing for now, and we'll rebase this proposal and put it in right afterwards. (Admittedly, it's

Re: [RFC PATCH] tests/vm/netbsd: Remove missing py311-expat package

2024-02-01 Thread John Snow
On Wed, Jan 17, 2024 at 9:03 AM Philippe Mathieu-Daudé wrote: > > On 17/1/24 13:10, Thomas Huth wrote: > > On 17/01/2024 12.24, Philippe Mathieu-Daudé wrote: > >> Per commits a9dbde71da ("mkvenv: add better error message for > >> broken or missing ensurepip") and 1dee66c693 ("tests/vm: add > >>

Re: [PATCH v2 13/19] qapi/schema: split "checked" field into "checking" and "checked"

2024-02-01 Thread John Snow
On Thu, Feb 1, 2024 at 2:41 PM John Snow wrote: > > On Tue, Jan 16, 2024 at 9:58 AM Markus Armbruster wrote: > > > > John Snow writes: > > > > > differentiate between "actively in the process of checking" and > > > "checking has

Re: [PATCH v2 13/19] qapi/schema: split "checked" field into "checking" and "checked"

2024-02-01 Thread John Snow
On Tue, Jan 16, 2024 at 9:58 AM Markus Armbruster wrote: > > John Snow writes: > > > differentiate between "actively in the process of checking" and > > "checking has completed". This allows us to clean up the types of some > > internal fields suc

Re: [PATCH v2 09/19] qapi/schema: allow resolve_type to be used for built-in types

2024-01-31 Thread John Snow
On Mon, Jan 22, 2024 at 8:12 AM Markus Armbruster wrote: > > John Snow writes: > > > On Tue, Jan 16, 2024 at 6:09 AM Markus Armbruster wrote: > >> > >> John Snow writes: > >> > >> > allow resolve_type to be used for both built-in an

Re: [PATCH v2 09/19] qapi/schema: allow resolve_type to be used for built-in types

2024-01-31 Thread John Snow
On Mon, Jan 22, 2024 at 8:12 AM Markus Armbruster wrote: > > John Snow writes: > > > On Tue, Jan 16, 2024 at 6:09 AM Markus Armbruster wrote: > >> > >> John Snow writes: > >> > >> > allow resolve_type to be used for both built-in an

Re: [PATCH v2 2/4] scripts/replay-dump.py: Update to current rr record format

2024-01-30 Thread John Snow
On Thu, Jan 25, 2024 at 11:09 AM Nicholas Piggin wrote: > > The v12 format support for replay-dump has a few issues still. This > fixes async decoding; adds event, shutdown, and end decoding; fixes > audio in / out events, fixes checkpoint checking of following async > events. > > Signed-off-by:

Re: [PATCH v2 11/19] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type

2024-01-17 Thread John Snow
On Tue, Jan 16, 2024 at 7:17 AM Markus Armbruster wrote: > > John Snow writes: > > > Adjust the expression at the callsite to eliminate weak type > > introspection that believes this value can resolve to QAPISourceInfo; it > > cannot. > > What do you mean by

Re: [PATCH v2 09/19] qapi/schema: allow resolve_type to be used for built-in types

2024-01-17 Thread John Snow
On Tue, Jan 16, 2024 at 6:09 AM Markus Armbruster wrote: > > John Snow writes: > > > allow resolve_type to be used for both built-in and user-specified > > type definitions. In the event that the type cannot be resolved, assert > > that 'info' and 'what' were both

Re: [PATCH v2 06/19] qapi/schema: make c_type() and json_type() abstract methods

2024-01-17 Thread John Snow
On Mon, Jan 15, 2024 at 9:03 AM Markus Armbruster wrote: > > John Snow writes: > > > These methods should always return a str, it's only the default abstract > > implementation that doesn't. They can be marked "abstract", which > > requires subclasses t

Re: [PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type

2024-01-17 Thread John Snow
On Mon, Jan 15, 2024 at 8:59 AM Markus Armbruster wrote: > > John Snow writes: > > > This field should always be present and defined after check() is > > called. Declare the property but allow its initialization to be delayed > > until check() so that it can be typed w

Re: [PATCH v2 04/19] qapi/schema: declare type for QAPISchemaObjectTypeMember.type

2024-01-16 Thread John Snow
On Mon, Jan 15, 2024 at 8:53 AM Markus Armbruster wrote: > > John Snow writes: > > > declare, but don't initialize the type of "type" to be QAPISchemaType - > > Declare > > > and allow the value to be initialized during check(). This crea

Re: [PATCH v2 03/19] qapi: create QAPISchemaDefinition

2024-01-16 Thread John Snow
On Tue, Jan 16, 2024 at 2:22 AM Markus Armbruster wrote: > > John Snow writes: > > > On Mon, Jan 15, 2024 at 8:16 AM Markus Armbruster wrote: > >> > >> John Snow writes: > >> > >> > Include entities don't have names, but we generally

Re: [PATCH v2 03/19] qapi: create QAPISchemaDefinition

2024-01-15 Thread John Snow
On Mon, Jan 15, 2024 at 8:16 AM Markus Armbruster wrote: > > John Snow writes: > > > Include entities don't have names, but we generally expect "entities" to > > have names. Reclassify all entities with names as *definitions*, leaving > > the nameless

Re: [PATCH v2 01/19] qapi: sort pylint suppressions

2024-01-15 Thread John Snow
On Mon, Jan 15, 2024 at 7:18 AM Markus Armbruster wrote: > > John Snow writes: > > > Suggested-by: Markus Armbruster > > Signed-off-by: John Snow > > --- > > scripts/qapi/pylintrc | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) >

[PATCH v2 04/19] qapi/schema: declare type for QAPISchemaObjectTypeMember.type

2024-01-12 Thread John Snow
this field is accessed before it is initialized in check(), you'll be treated to an AttributeError exception. Fixes stuff like this: qapi/schema.py:657: error: "None" has no attribute "alternate_qtype" [attr-defined] qapi/schema.py:662: error: "None" has no attribute "

[PATCH v2 16/19] qapi/parser: demote QAPIExpression to Dict[str, Any]

2024-01-12 Thread John Snow
strictness improvements later. Signed-off-by: John Snow --- scripts/qapi/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index bf31018aef0..b7f08cf36f2 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -

[PATCH v2 12/19] qapi/schema: assert info is present when necessary

2024-01-12 Thread John Snow
ional". Signed-off-by: John Snow Reviewed-by: Philippe Mathieu-Daudé --- scripts/qapi/schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 43af756ed47..eefa58a798b 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py

[PATCH v2 19/19] qapi/schema: remove unnecessary asserts

2024-01-12 Thread John Snow
With strict typing enabled, these runtime statements aren't necessary anymore; we can prove them statically. Signed-off-by: John Snow --- scripts/qapi/schema.py | 27 --- 1 file changed, 27 deletions(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index

[PATCH v2 00/19] qapi: statically type schema.py

2024-01-12 Thread John Snow
rn on mypy strictness' 019/19:[0006] [FC] 'qapi/schema: remove unnecessary asserts' Zapped a few more. John Snow (19): qapi: sort pylint suppressions qapi/schema: add pylint suppressions qapi: create QAPISchemaDefinition qapi/schema: declare type for QAPISchemaObjectTyp

[PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type

2024-01-12 Thread John Snow
at multiple callsites; the overwhelming majority of uses assume a fully-initialized object. Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 48a51dcd188..e45d9545eda 100644

[PATCH v2 14/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member

2024-01-12 Thread John Snow
the typing in quite a few places and avoids needing to assert that the "tag_member is not None" at a dozen callsites, which can be confusing and suggest the wrong thing to a drive-by contributor. Signed-off-by: John Snow --- scripts/qapi/schema.py | 22 +++-

[PATCH v2 10/19] qapi: use schema.resolve_type instead of schema.lookup_type

2024-01-12 Thread John Snow
lookup_type() is capable of returning None, but some callers aren't prepared for that and assume it will always succeed. Use the must-not-fail variant resolve_type() instead, which guarantees that the return type will not be None. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 4

[PATCH v2 09/19] qapi/schema: allow resolve_type to be used for built-in types

2024-01-12 Thread John Snow
Signed-off-by: John Snow --- scripts/qapi/schema.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 66a78f28fd4..a77b51d1b96 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -1001,9 +1001,10 @@ def lookup

[PATCH v2 18/19] qapi/schema: turn on mypy strictness

2024-01-12 Thread John Snow
This patch can be rolled in with the previous one once the series is ready for merge, but for work-in-progress' sake, it's separate here. Signed-off-by: John Snow --- scripts/qapi/mypy.ini | 5 - 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini

[PATCH v2 11/19] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type

2024-01-12 Thread John Snow
Adjust the expression at the callsite to eliminate weak type introspection that believes this value can resolve to QAPISourceInfo; it cannot. Signed-off-by: John Snow --- scripts/qapi/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/schema.py b/scripts

<    1   2   3   4   5   6   7   8   9   10   >