streamlit-pydantic icon indicating copy to clipboard operation
streamlit-pydantic copied to clipboard

Add full support for readOnly, max_items, min_items and other schema properties within rendered collections

Open HIL340 opened this issue 3 years ago • 3 comments

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [ ] New Feature
  • [x] Feature Improvement
  • [x] Refactoring
  • [ ] Documentation
  • [ ] Other, please describe:

Description:

Hello again 😄

From a user/dev perspective the changes introduced by this PR are:

  1. Support the readOnly pydantic field property in all pydantic widgets by making use of streamlits disabled widget property (fully introduced in streamlit 1.5.0 and pinned to this version in setup.py)
  2. Enhance the new list add/remove/clear buttons to respect max_items and min_items pydantic field properties that might be present in the model.
  3. Add support for all existing widget types (eg. date, time, boolean etc..) to be rendered in lists and dicts with full validation and formatting options. This is a result of some refactoring to improve code re-use. eg. There is now only one function that rendered a number field, regardless of whether that field is a standalone property or contained within in a list, dict or complex object.

A new showcase example complex_disabled_showcase.py has been added to test/demonstrate all of the major widgets in thier disabled form. complex_instance_model.py has also been updated to demonstrate some of the now supported collection properties and data types.

Checklist:

  • [x] I have read the CONTRIBUTING document.
  • [x] My changes don't require a change to the documentation, or if they do, I've added all required information.

HIL340 avatar Jul 20 '22 14:07 HIL340

Thanks again for this contribution :) I will have some time for review beginning of next week.

lukasmasuch avatar Jul 22 '22 14:07 lukasmasuch

I see your now running a build pipeline 👍 and its failing with some mypy errors.

As most of the errors were introduced by this and my previous PR I've just pushed some very minor fixes that resolve all but one of the errors.

The last remaining error is in the form handling code which I haven't touched so I'll let you decide what the best course of action is there.

HIL340 avatar Jul 25 '22 02:07 HIL340

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days

github-actions[bot] avatar Oct 24 '22 02:10 github-actions[bot]

I'm so sorry for the extremely long delay :( I finally got back here to merge and release a new version 🥳

lukasmasuch avatar Nov 11 '22 17:11 lukasmasuch

Not a problem! This PR ended up being a bit larger and more complex then I would have liked so I appreciate you making the time to review.

With this one merged in I'll have a few smaller feature PR's coming but I promise they will be a lot more straight forward to review 😄

HIL340 avatar Nov 14 '22 08:11 HIL340

@HIL340 Awesome :) I got it to a state that it is ready to release, but there is still a problem with the release process which I need to fix 😬

lukasmasuch avatar Nov 14 '22 10:11 lukasmasuch