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

Fix Union Discriminator functioanlity with Pydantic 1.10+ #19

Merged
merged 2 commits into from Mar 22, 2023

Conversation

HIL340
Copy link
Contributor

@HIL340 HIL340 commented Dec 7, 2022

What kind of change does this PR introduce?

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

Description:

Pydantic's 1.10 release introduced a change to its union discriminator property from "anyOf" to "oneOf" (see pydantic/pydantic#4335).

This property is used by streamlit-pydantic to support the optional rendering of discriminated unions in forms and this is no longer working with pydantic 1.10+

This PR adds support for the pydantic 1.10 "oneOf" property name and maintains backwards compatibility with"anyOf" (and therefore with pydantic < 1.10)

Also included are some minor formatting updates to the Union playground example pages by making use of streamlit tabs for the different model/instance init styles.

Checklist:

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

@HIL340
Copy link
Contributor Author

HIL340 commented Dec 7, 2022

I've included a simple fix for the CI in #18. I won't replicate it here as well.

@github-actions
Copy link

github-actions bot commented Mar 8, 2023

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 github-actions bot added the Stale label Mar 8, 2023
@LukasMasuch LukasMasuch removed the Stale label Mar 8, 2023
@LukasMasuch LukasMasuch merged commit a1163fe into LukasMasuch:main Mar 22, 2023
@HIL340 HIL340 deleted the pydantic_1_10 branch March 22, 2023 16:46
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

Successfully merging this pull request may close these issues.

None yet

2 participants