| 538cd410 | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: Modify check_keys to accept any Collection
This is a minor adjustment that lets parameters @required and @optional take tuple arguments, in particular (). Later patches will make use
qapi/expr.py: Modify check_keys to accept any Collection
This is a minor adjustment that lets parameters @required and @optional take tuple arguments, in particular (). Later patches will make use of that.
(Iterable would also have worked, but Iterable also includes things like generator expressions which are consumed upon iteration, which would require a rewrite to make sure that each input was only traversed once. Collection implies the "can re-iterate" property.)
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210421182032.3521476-10-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 7a783ce5 | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: Add casts in a few select cases
Casts are instructions to the type checker only, they aren't "safe" and should probably be avoided in general. In this case, when we perform type checki
qapi/expr.py: Add casts in a few select cases
Casts are instructions to the type checker only, they aren't "safe" and should probably be avoided in general. In this case, when we perform type checking on a nested structure, the type of each field does not "stick".
(See PEP 647 for an example of "type narrowing" that does "stick". It is available in Python 3.10, so we can't use it yet.)
We don't need to assert that something is a str if we've already checked or asserted that it is -- use a cast instead for these cases.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210421182032.3521476-9-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 4918bb7d | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: Check type of union and alternate 'data' member
Prior to this commit, specifying a non-object value here causes the QAPI parser to crash in expr.py with a stack trace with (likely) an
qapi/expr.py: Check type of union and alternate 'data' member
Prior to this commit, specifying a non-object value here causes the QAPI parser to crash in expr.py with a stack trace with (likely) an AttributeError when we attempt to call that value's items() method.
This member needs to be an object (Dict), and not anything else. Add a check for this with a nicer error message, and formalize that check with new test cases that exercise that error.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210421182032.3521476-8-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 926bb8ad | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: move string check upwards in check_type
For readability purposes only, shimmy the early return upwards to the top of the function, so cases proceed in order from least to most complex.
qapi/expr.py: move string check upwards in check_type
For readability purposes only, shimmy the early return upwards to the top of the function, so cases proceed in order from least to most complex.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20210421182032.3521476-7-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| b66c62a2 | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: Add assertion for union type 'check_dict'
mypy isn't fond of allowing you to check for bool membership in a collection of str elements. Guard this lookup for precisely when we were giv
qapi/expr.py: Add assertion for union type 'check_dict'
mypy isn't fond of allowing you to check for bool membership in a collection of str elements. Guard this lookup for precisely when we were given a name.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20210421182032.3521476-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 59b5556c | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: constrain incoming expression types
mypy does not know the types of values stored in Dicts that masquerade as objects. Help the type checker out by constraining the type.
Signed-off-b
qapi/expr.py: constrain incoming expression types
mypy does not know the types of values stored in Dicts that masquerade as objects. Help the type checker out by constraining the type.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210421182032.3521476-5-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 0f231dcf | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: Check for dict instead of OrderedDict
OrderedDict is a subtype of dict, so we can check for a more general form. These functions do not themselves depend on it being any particular typ
qapi/expr.py: Check for dict instead of OrderedDict
OrderedDict is a subtype of dict, so we can check for a more general form. These functions do not themselves depend on it being any particular type.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20210421182032.3521476-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| b7341b89 | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr.py: Remove 'info' argument from nested check_if_str
The function can just use the argument from the scope above. Otherwise, we get shadowed argument errors because the parameter name clash
qapi/expr.py: Remove 'info' argument from nested check_if_str
The function can just use the argument from the scope above. Otherwise, we get shadowed argument errors because the parameter name clashes with the name of a variable already in-scope.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20210421182032.3521476-3-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| d0a263cd | 21-Apr-2021 |
John Snow <jsnow@redhat.com> |
qapi/expr: Comment cleanup
The linter yaps after 0825f62c842. Fix this trivial issue to restore the linter baseline.
(Yes, ideally -- and soon -- the linter will be part of CI so we don't clutter u
qapi/expr: Comment cleanup
The linter yaps after 0825f62c842. Fix this trivial issue to restore the linter baseline.
(Yes, ideally -- and soon -- the linter will be part of CI so we don't clutter up the log with fixups. For now, though, the baseline is useful for testing intermediate commits as types are added to the QAPI library.)
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210421182032.3521476-2-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| d83b4764 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce union and alternate branch naming rules
Union branch names should use '-', not '_'. Enforce this. The only offenders are in tests/. Fix them.
Signed-off-by: Markus Armbruster <armb
qapi: Enforce union and alternate branch naming rules
Union branch names should use '-', not '_'. Enforce this. The only offenders are in tests/. Fix them.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-29-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message typo fixed]
show more ...
|
| 407efbf9 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce enum member naming rules
Enum members should use '-', not '_'. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma member-name-exceptions.
Signe
qapi: Enforce enum member naming rules
Enum members should use '-', not '_'. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma member-name-exceptions.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-28-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 5aceeac0 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce struct member naming rules
Struct members, including command arguments, event data, and union inline base members, should use '-', not '_'. Enforce this. Fix the fixable offenders (a
qapi: Enforce struct member naming rules
Struct members, including command arguments, event data, and union inline base members, should use '-', not '_'. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma member-name-exceptions.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-27-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 05ebf841 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce command naming rules
Command names should be lower-case. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma command-name-exceptions.
Signed-off
qapi: Enforce command naming rules
Command names should be lower-case. Enforce this. Fix the fixable offenders (all in tests/), and add the remainder to pragma command-name-exceptions.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-25-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| e744708a | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce feature naming rules
Feature names should use '-', not '_'. Enforce this.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-24-armbru@redhat.co
qapi: Enforce feature naming rules
Feature names should use '-', not '_'. Enforce this.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-24-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 9af4b6b9 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Prepare for rejecting underscore in command and member names
Command names and member names within a type should be all lower case with words separated by a hyphen. We also accept underscore.
qapi: Prepare for rejecting underscore in command and member names
Command names and member names within a type should be all lower case with words separated by a hyphen. We also accept underscore. Rework check_name_lower() to optionally reject underscores, but don't use that option, yet.
Update expected test output for the changed error message.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-23-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| b86df374 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Rename pragma *-whitelist to *-exceptions
Rename pragma returns-whitelist to command-returns-exceptions, and name-case-whitelist to member-name-case-exceptions.
Signed-off-by: Markus Armbrust
qapi: Rename pragma *-whitelist to *-exceptions
Rename pragma returns-whitelist to command-returns-exceptions, and name-case-whitelist to member-name-case-exceptions.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-20-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 4a67bd31 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Factor out QAPISchemaParser._check_pragma_list_of_str()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-17-armbru@redhat.com> Reviewed-by: Eric Blake <
qapi: Factor out QAPISchemaParser._check_pragma_list_of_str()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-17-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 3e6c8a63 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce type naming rules
Type names should be CamelCase. Enforce this. The only offenders are in tests/. Fix them. Add test type-case to cover the new error.
Signed-off-by: Markus Armbru
qapi: Enforce type naming rules
Type names should be CamelCase. Enforce this. The only offenders are in tests/. Fix them. Add test type-case to cover the new error.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-15-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Regexp simplified, new test made more robust]
show more ...
|
| d4f4cae8 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Enforce event naming rules
Event names should be ALL_CAPS with words separated by underscore. Enforce this. The only offenders are in tests/. Fix them. Existing test event-case covers the n
qapi: Enforce event naming rules
Event names should be ALL_CAPS with words separated by underscore. Enforce this. The only offenders are in tests/. Fix them. Existing test event-case covers the new error.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-14-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 00ffe242 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Consistently permit any case in downstream prefixes
We require lowercase __RFQDN_ downstream prefixes only where we require the prefixed name to be lowercase. Don't; permit any case in __RFQD
qapi: Consistently permit any case in downstream prefixes
We require lowercase __RFQDN_ downstream prefixes only where we require the prefixed name to be lowercase. Don't; permit any case in __RFQDN_ prefixes anywhere.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-13-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| d224e0c0 | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Move uppercase rejection to check_name_lower()
check_name_lower() is the only user of check_name_str() using permit_upper=False. Move the associated code from check_name_str() to check_name_l
qapi: Move uppercase rejection to check_name_lower()
check_name_lower() is the only user of check_name_str() using permit_upper=False. Move the associated code from check_name_str() to check_name_lower(), and drop the parameter.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-12-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| eaab06fa | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Rework name checking in preparation of stricter checking
Naming rules differ for the various kinds of names. To prepare enforcing them, define functions to check them: check_name_upper(), che
qapi: Rework name checking in preparation of stricter checking
Naming rules differ for the various kinds of names. To prepare enforcing them, define functions to check them: check_name_upper(), check_name_lower(), and check_name_camel(). For now, these merely wrap around check_name_str(), but that will change shortly. Replace the other uses of check_name_str() by appropriate uses of the wrappers. No change in behavior just yet.
check_name_str() now returns the name without downstream and x- prefix, for use by the wrappers in later patches. Requires tweaking regexp @valid_name. It accepts the same strings as before.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-11-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message improved]
show more ...
|
| 0825f62c | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Lift enum-specific code out of check_name_str()
check_name_str() masks leading digits when passed enum_member=True. Only check_enum() does. Lift the masking into check_enum().
Signed-off-by:
qapi: Lift enum-specific code out of check_name_str()
check_name_str() masks leading digits when passed enum_member=True. Only check_enum() does. Lift the masking into check_enum().
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-10-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
| 5fbc78dd | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Permit flat union members for any tag value
Flat union branch names match the tag enum's member names. Omitted branches default to "no members for this tag value".
Branch names starting with
qapi: Permit flat union members for any tag value
Flat union branch names match the tag enum's member names. Omitted branches default to "no members for this tag value".
Branch names starting with a digit get rejected like "'data' member '0' has an invalid name". However, omitting the branch works.
This is because flat union tag values get checked twice: as enum member name, and as union branch name. The former accepts leading digits, the latter doesn't.
Branches whose names start with a digit therefore cannot have members. Feels wrong. Get rid of the restriction by skipping the latter check.
This can expose c_name() to input it can't handle: a name starting with a digit. Improve it to return a valid C identifier for any input.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-9-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message rewritten]
show more ...
|
| dbfe3c7c | 23-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix to reject optional members with reserved names
check_type() fails to reject optional members with reserved names, because it neglects to strip off the leading '*'. Fix that.
The strippin
qapi: Fix to reject optional members with reserved names
check_type() fails to reject optional members with reserved names, because it neglects to strip off the leading '*'. Fix that.
The stripping in check_name_str() is now useless. Drop.
Also drop the "no leading '*'" assertion, because valid_name.match() ensures it can't fail.
Fixes: 9fb081e0b98409556d023c7193eeb68947cd1211 Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-8-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
show more ...
|