-
-
Notifications
You must be signed in to change notification settings - Fork 74
AirModel with .form() #727
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
base: main
Are you sure you want to change the base?
Conversation
Introduces the model_form() utility to generate AirForm subclasses from Pydantic models, and adds AirModel.form() for convenient form creation. Updates demo and tests to use the new helpers, supporting field inclusion and custom widgets.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Daniel Roy Greenfeld <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's so impressive about this PR is how it barely touches existing code yet is transformative. This will vastly reduce the volume of code required to work in forms.
src/air/forms.py
Outdated
| ) # ty: ignore[no-matching-overload] | ||
|
|
||
|
|
||
| def model_form( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this is its own function. This makes adding this functionality much easier to test.
|
WTF, all the commits came over to my name. I need to restore attribution to @audreyfeldroy. Also, there's an extra instantiation in there that could be removed. Changing this to draft while I figure out the attribution and instatiation. |
I've extended Pydantic's BaseModel to create AirModel and give it a .form method. That way we can generate the AirForm from the AirModel.
Pull request type
Please check the type of change your PR introduces:
Pull request tasks
The following have been completed for this task:
examplesfolderChecklist
just testandjust qa, ensuring my code changes passes all existing testsDemo or screenshot
examples/demo_form_errors.py