Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mayagbarnes
Copy link
Collaborator

@mayagbarnes mayagbarnes commented May 6, 2025

Describe your changes

This PR remove the two st.set_page_config restrictions:

  • It can only be called as the first st command (with some exceptions)
  • It can only be called once per script run

The properties are additive (if the first call sets a page_title and the second call sets a page_icon, the page now has both the provided title & icon).
This also applies for menu_items.

GitHub Issue Link (if applicable)

Closes #4483
Closes #2216
Closes #9797
Closes #9038

Testing Plan

  • Python Unit Tests: Added/Updated ✅
  • E2E Tests: Added/Updated ✅
  • Manual Testing: ✅

@mayagbarnes mayagbarnes added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels May 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11286/streamlit-1.45.0-py3-none-any.whl
🕹️ Preview app pr-11286.streamlit.app (☁️ Deploy here if not accessible)

@snyk-io
Copy link
Contributor

snyk-io bot commented May 7, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

"🔥™🎉🚀🌌💣✨🌙🎆🎇💥🤩🤙🌛🤘⬆💡🤪🥂⚡💨🌠🎊🍿😛🔮🤟🌃🍃🍾💫▪🌴🎈🎬🌀🎄😝☔⛽🍂💃😎🍸🎨🥳☀😍🅱🌞😻🌟😜💦💅🦄😋😉👻🍁🤤👯🌻‼🌈👌🎃💛😚🔫🙌👽🍬🌅☁🍷👭☕🌚💁👅🥰🍜😌🎥🕺❕🧡☄💕🍻✅🌸🚬🤓🍹®☺💪😙☘🤠✊🤗🍵🤞😂💯😏📻🎂💗💜🌊❣🌝😘💆🤑🌿🦋😈⛄🚿😊🌹🥴😽💋😭🖤🙆👐⚪💟☃🙈🍭💻🥀🚗🤧🍝💎💓🤝💄💖🔞⁉⏰🕊🎧☠♥🌳🏾🙉⭐💊🍳🌎🙊💸❤🔪😆🌾✈📚💀🏠✌🏃🌵🚨💂🤫🤭😗😄🍒👏🙃🖖💞😅🎅🍄🆓👉💩🔊🤷⌚👸😇🚮💏👳🏽💘💿💉👠🎼🎶🎤👗❄🔐🎵🤒🍰👓🏄🌲🎮🙂📈🚙📍😵🗣❗🌺🙄👄🚘🥺🌍🏡♦💍🌱👑👙☑👾🍩🥶📣🏼🤣☯👵🍫➡🎀😃✋🍞🙇😹🙏👼🐝⚫🎁🍪🔨🌼👆👀😳🌏📖👃🎸👧💇🔒💙😞⛅🏻🍴😼🗿🍗♠🦁✔🤖☮🐢🐎💤😀🍺😁😴📺☹😲👍🎭💚🍆🍋🔵🏁🔴🔔🧐👰☎🏆🤡🐠📲🙋📌🐬✍🔑📱💰🐱💧🎓🍕👟🐣👫🍑😸🍦👁🆗🎯📢🚶🦅🐧💢🏀🚫💑🐟🌽🏊🍟💝💲🐍🍥🐸☝♣👊⚓❌🐯🏈📰🌧👿🐳💷🐺📞🆒🍀🤐🚲🍔👹🙍🌷🙎🐥💵🔝📸⚠❓🎩✂🍼😑⬇⚾🍎💔🐔⚽💭🏌🐷🍍✖🍇📝🍊🐙👋🤔🥊🗽🐑🐘🐰💐🐴♀🐦🍓✏👂🏴👇🆘😡🏉👩💌😺✝🐼🐒🐶👺🖕👬🍉🐻🐾⬅⏬▶👮🍌♂🔸👶🐮👪⛳🐐🎾🐕👴🐨🐊🔹©🎣👦👣👨👈💬⭕📹📷"
)

# Also pick out some vanity emojis.
Copy link
Collaborator Author

@mayagbarnes mayagbarnes May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with Johannes to remove these

if ABOUT_KEY in lowercase_menu_items:
if lowercase_menu_items[ABOUT_KEY] is not None:
menu_items_proto.about_section_md = dedent(lowercase_menu_items[ABOUT_KEY])
else:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to handle case where "About" markdown intially set and then updated to None, for consistent behavior with other menu_items fields.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be good to add that as a comment in the code as well

@mayagbarnes mayagbarnes changed the title [WIP] Remove set_page_config restrictions Remove set_page_config restrictions May 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2025

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0200%

  • Current PR: 85.8900% (41818 lines, 5900 missed)
  • Latest develop: 85.9100% (41806 lines, 5889 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@mayagbarnes mayagbarnes marked this pull request as ready for review May 9, 2025 00:21
@mayagbarnes mayagbarnes requested a review from a team as a code owner May 9, 2025 00:21
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

string report_a_bug_url = 3;
bool hide_report_a_bug = 4;
string about_section_md = 5;
bool clear_about_md = 6;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe add a small comment in the proto what this flag does.

if ABOUT_KEY in lowercase_menu_items:
if lowercase_menu_items[ABOUT_KEY] is not None:
menu_items_proto.about_section_md = dedent(lowercase_menu_items[ABOUT_KEY])
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be good to add that as a comment in the code as well

@mayagbarnes mayagbarnes merged commit 18b10a2 into develop May 11, 2025
38 checks passed
@mayagbarnes mayagbarnes deleted the page-config branch May 11, 2025 07:03
mayagbarnes added a commit that referenced this pull request Jun 17, 2025
To better enable additive calls to `st.set_page_config` now that
restrictions have been removed
(#11286), make params
`layout` & `initial_sidebar_state` default to `None` if not set so they
inherit the behavior of the previous call.

If there is no previous call (1st `st.set_page_config` call), these will
be set by the FE to the defaults - values `"centered"` & `"auto"`
respectively.
sfc-gh-mbarnes pushed a commit that referenced this pull request Jun 17, 2025
To better enable additive calls to `st.set_page_config` now that
restrictions have been removed
(#11286), make params
`layout` & `initial_sidebar_state` default to `None` if not set so they
inherit the behavior of the previous call.

If there is no previous call (1st `st.set_page_config` call), these will
be set by the FE to the defaults - values `"centered"` & `"auto"`
respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

4 participants