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

refactor for toml no null #108

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
10 changes: 10 additions & 0 deletions example_app/.streamlit/pages_sections.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ path = "example_five.py"
name = "Example Five"
icon = "🧰"
url_path = "a_very_long_page_title"

[[pages]]
name = "Section with no icon"
is_section = true

[[pages]]
path = "example_five.py"
name = "Another example five!"
icon = "😵‍💫"
url_path = "example_five_title2"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "st-pages"
version = "1.0.1"
version = "1.0.2"
license = "MIT"
description = "An experimental version of Streamlit Multi-Page Apps"
authors = ["Zachary Blackwood <zachary@streamlit.io>"]
Expand Down
2 changes: 1 addition & 1 deletion src/st_pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _get_pages_from_config(path: str = ".streamlit/pages.toml") -> list[Page] |
for page in raw_pages:
if page.get("is_section"):
page["path"] = ""
pages.append(Section(page["name"], page["icon"])) # type: ignore
pages.append(Section(page["name"], page.get("icon", None))) # type: ignore
else:
pages.append(Page(**page)) # type: ignore
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about handling "icon" here the same way you've handled it in the "if section" block above? That seems like it would nicely handle a lot of the other checks, and could simply default to null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I will work on it tom and get back !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made the changes to set icon to None when initializing here but I think the string null check has to be done separately when setting the page title and section names.

Let me know if that looks good!


Expand Down
Loading