Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork95
CLI Serialization Fixes#649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
kschwab commentedJul 2, 2025
- Adds serialization of sub commands.
- Fixes serialization of kebab case of flags.
Thanks@kschwab Is it a fix for an issue? |
@hramezani yes, it is an issue I found locally. I can open a formal ticket if you would like.
frompydantic_settingsimportBaseSettings,CliAppclassCfg(BaseSettings,cli_kebab_case=True):foo_kebab:int=123args=CliApp.serialize(Cfg())print(args)#> ['--foo_kebab', '123']CliApp.run(Cfg,cli_args=args)"""usage: example.py [-h] [--foo-kebab int]example.py: error: unrecognized arguments: --foo_kebab 123""" With this fix, it will correctly apply the kebab case to serialization: frompydantic_settingsimportBaseSettings,CliAppclassCfg(BaseSettings,cli_kebab_case=True):foo_kebab:int=123print(CliApp.serialize(Cfg()))#> ['--foo-kebab', '123']print(CliApp.run(Cfg,cli_args=args))#> foo_kebab=123 I also missed serialization of subcommands, which addressed as well in this PR. See addedtest. |
I also just noticed that |
fa35ea9
toe985e22
CompareOk@hramezani, this is ready for review again. When I looked closer, there were a handful of bugs I found with the original serialization. The change set looks larger then it is. Ireverted the original serialization implementation, and consolidated it into two standalone functions. The bugs I found and fixed were:
All the newly added tests currently fail on main. |