Repository navigation
Conversation
…r Are Keywords _safe_segment returned names such as "24hr" or "class" unchanged, so the router generator emitted `async def 24hr(` and unimportable module names. Prefix them with an underscore (Fixes openbq-org#7799).
dlee-bq
requested changes
Oct 19, 2026
dlee-bq
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this, @drakeo338.
It fixes #7799. One change before merge: for Python keywords, please append the underscore (class → class_) rather than prefixing it. That matches how the generator already handles keywords in field names (pydantic_gen.safe_field_name / query_field_name give from_), and it keeps generated commands from looking private on the obb surface (obb.x.ticker._class).
Keep the _ prefix for names that start with a digit (_24hr), as you have it.
Author
|
Done in 45dd415: keywords now get a trailing underscore (class_), digit-leading names keep the _ prefix (_24hr), and the tests cover both |
openbb-cli: Prefix Codegen Names That Start With a Digit or Are Keywordsopenbb-cli: Make Codegen Names That Start With a Digit or Are Keywords Valid
This branch has not been deployed
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.
Pull Request OpenBB
Description
Fixes #7799.
_safe_segmentin the CLI router generator returned names like24hrorclassunchanged, so the generated router containedasync def 24hr(and unimportable module names. Names that start with a digit now get a leading underscore (_24hr), as the Fetcher, POST and test generators already do, and Python keywords get a trailing one (class_), aspydantic_gendoes for field names.How has this been tested?
Two new tests in
cli/tests/test_codegen_router_gen.pyfail on the unfixed source and pass with the fix; the file runs 21 passed. Other checkboxes are left unticked because I did not run them.Checklist
I used an AI coding assistant (Claude Code) for this change and reviewed and tested it myself.