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
left a comment
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.
|
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
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.