Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting store_true=True #67

Open
TheCodingLand opened this issue Sep 5, 2024 · 0 comments
Open

Supporting store_true=True #67

TheCodingLand opened this issue Sep 5, 2024 · 0 comments

Comments

@TheCodingLand
Copy link

Hello,

I have an app that is now widely deployed and using the previous version of pydantic-cli.

In the versions before the rewrite for pydantic v2, It was possible to have flags that would automatically be set to True, if they appeared in the commande line instead of relying on validation.

I was thinking of maybe a solution like adding extra kwargs to fields:
in _add_pydantic_field_to_parser(

shape_kw["action"] = "store_true" if  field_info.json_schema_extra.get('store_true', False) else "store"

# adds the option to do:
ignore_rules: bool = Field(False, description="Ignore rules", cli=('-i', '--ignore-rules'), store_true=True)

I'm not sure if this approach could cause problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant