[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 14/19] qapi/schema: fix typing for QAPISchemaVariants.tag_
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v2 14/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member |
Date: |
Wed, 17 Jan 2024 09:22:49 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
John Snow <jsnow@redhat.com> writes:
> There are two related changes here:
>
> (1) We need to perform type narrowing for resolving the type of
> tag_member during check(), and
>
> (2) tag_member is a delayed initialization field, but we can hide it
> behind a property that raises an Exception if it's called too
> early. This simplifies 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 <jsnow@redhat.com>
I explored another solution, and posted it in reply to v2. If we decide
not to like it better, I guess we'll go with this one.
- Re: [PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type, (continued)
- [PATCH v2 14/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member, John Snow, 2024/01/12
- Re: [PATCH v2 14/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member,
Markus Armbruster <=
- [PATCH v2 15/19] qapi/schema: assert inner type of QAPISchemaVariants in check_clash(), John Snow, 2024/01/12
- [PATCH v2 12/19] qapi/schema: assert info is present when necessary, John Snow, 2024/01/12
- [PATCH v2 18/19] qapi/schema: turn on mypy strictness, John Snow, 2024/01/12
- [PATCH v2 19/19] qapi/schema: remove unnecessary asserts, John Snow, 2024/01/12
- [PATCH v2 10/19] qapi: use schema.resolve_type instead of schema.lookup_type, John Snow, 2024/01/12
- [PATCH v2 07/19] qapi/schema: adjust type narrowing for mypy's benefit, John Snow, 2024/01/12
- [PATCH v2 16/19] qapi/parser: demote QAPIExpression to Dict[str, Any], John Snow, 2024/01/12
- [PATCH v2 09/19] qapi/schema: allow resolve_type to be used for built-in types, John Snow, 2024/01/12