-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use FieldInfo repr. This non-trivially changes how the output is displayed. #70
Conversation
This creates some other issues. Any other metadata (e.g., extras) is pushed to the Field and also displayed. from pydantic import Field
from pydantic_cli import run_and_exit, Cmd
class Options(Cmd):
alpha: int = Field(..., cli=('-a', '--alpha'), other=["other metadata"])
def run(self) -> None:
print(f"Mock example running with {self}")
if __name__ == "__main__":
run_and_exit(Options, description=__doc__, version="0.1.0") Yields:
At a minimum, It's not clear if the metadata should also be displayed. There arguments for and against displaying it here. https://docs.pydantic.dev/latest/api/fields/ The |
I think with
with
No need to display FieldInfo in the terminal |
I experiment with that but it looked wonky. Specifically for cases where there's a custom description for a field.
I'm going to use "Field" and manually create the display. This is perhaps a slight improvement.
|
Use Pydantic repr on FieldInfo. I believe this is a reasonable tradeoff for robustness.