Skip to content

Warning 'The widget with key "..." was created with a default value but also had its value set via the Session State API' should not be issued #15544

@clo-vis

Description

@clo-vis

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

According this comment, it is fine to supply a default value to a widget and also have it set via the Session State API.

streamlit issues a warning, however, if you do that.

Reproducible Code Example

import streamlit as st
st.session_state["key"] = 1
st.slider("slider", min_value = 0, max_value = 10, value=9, key="key")

Steps To Reproduce

No response

Expected Behavior

No warnings.

Current Behavior

Warning:

The widget with key "key" was created with a default value but also had its value set via the Session State API.

Is this a regression?

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

Debug info

  • Streamlit version: 1.58.0

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:widgetsRelated to widget elementstype:enhancementRequests for feature enhancements or new features

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions