Accept multibase string literals in CSR enum value parsing#231
Merged
james-ball-qualcomm merged 5 commits intoadd_behavior_to_warl_enumfrom Mar 24, 2026
Merged
Accept multibase string literals in CSR enum value parsing#231james-ball-qualcomm merged 5 commits intoadd_behavior_to_warl_enumfrom
james-ball-qualcomm merged 5 commits intoadd_behavior_to_warl_enumfrom
Conversation
…rn parsing Co-authored-by: james-ball-qualcomm <140646808+james-ball-qualcomm@users.noreply.github.com> Agent-Logs-Url: https://github.com/riscv/docs-resources/sessions/11ad9d00-d632-4b46-9c65-ee154ee0338e
Signed-off-by: James Ball <jameball@qti.qualcomm.com>
Co-authored-by: james-ball-qualcomm <140646808+james-ball-qualcomm@users.noreply.github.com> Agent-Logs-Url: https://github.com/riscv/docs-resources/sessions/11ad9d00-d632-4b46-9c65-ee154ee0338e
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on changing 'type' to 'enum' object in PR #230
Accept multibase string literals in CSR enum value parsing
Mar 24, 2026
james-ball-qualcomm
approved these changes
Mar 24, 2026
3ca5f6b
into
add_behavior_to_warl_enum
2 checks passed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates CSR enum parsing in tools/create_params.py to correctly accept schema-permitted multibase string literals (e.g., "0x1", "0b10") in enum.legal, avoiding failures that depended on YAML quoting behavior.
Changes:
- Allow
enum.legalentries to be eitherintorstr, converting via the existingparse_multibase_inthelper. - Normalize
enum.legalvalues to integers during parsing (instead of passing raw values through). - Adjust validation paths to support multibase inputs (with one remaining error-message inconsistency noted below).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+654
to
658
| if not isinstance(value, (int, str)) or isinstance(value, bool): | ||
| fatal( | ||
| f"CSR {representative_name} in {def_filename} has non-integer " | ||
| f"value in enum.legal: {value!r}" | ||
| f"CSR {representative_name} in {def_filename} has invalid value in enum.legal: " | ||
| f"{value!r}; expected integer, hex string, or binary string" | ||
| ) |
There was a problem hiding this comment.
The enum.legal type-check now allows strings, but the fatal message still says “non-integer value”. This is misleading (and also inaccurate for other invalid types like dict/list). Please update the message to reflect the accepted inputs (int or multibase string) or rely on parse_multibase_int for the error so the wording stays consistent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CSR
enumparsing fatalied on quoted hex/binary literals (e.g."0x1","0b10") inenum.legalandenum.illegal-write-return, despite the schema permittingmultiBaseValueinputs. Behavior depended on whether the author quoted the value in YAML.Changes
enum.legalparsing: Broadened type check fromint-only to(int, str), delegating to the existingparse_multibase_inthelper for string resolution.enum.illegal-write-returnparsing: Same fix applied — accepts quoted hex/binary strings viaparse_multibase_int.integer, hex string, or binary string).Example — now valid YAML
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.