Skip to content

Default float fields not updated when model instance argument changed #70

@benoitsdm

Description

@benoitsdm

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Thanks for the great library, really powerful !

I have noticed a bug that you can reproduce with the minimalist example.

Reproducible Code Example

import streamlit as st
import streamlit_pydantic as sp
from pydantic import BaseModel

class Model(BaseModel):
    i: int
    s: str

a= Model(i=1, s="1")
b= Model(i=2, s="2")

init = st.selectbox(label="instance", options=[a, b])

data = sp.pydantic_form(key="f", model=init)

if data:
    st.json(data)

Steps To Reproduce

When you change the init model from the select box, the string default is successfully updated but not the int.

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

Additional Information

Not sure how the session state this handled under the hood, do you have any quick work around ? Or if you have any idea where the bug can come from, please points me the function I can have a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions