-
Notifications
You must be signed in to change notification settings - Fork 77
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 section name #105
Fix section name #105
Conversation
src/st_pages/__init__.py
Outdated
@@ -75,7 +75,10 @@ def _get_nav_from_toml( | |||
|
|||
for page in pages: | |||
if page.is_section: | |||
current_section = f"{translate_icon(page.icon)} {page.name}" | |||
if translate_icon(page.icon): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind making a couple of small tweaks?
I would add them to your PR myself, but I don't have permission to make changes, but this diff will make the if slightly more explicit, and also fixes a "incompatible type" issue:
diff --git a/src/st_pages/__init__.py b/src/st_pages/__init__.py
index f15b2d1..795019b 100644
--- a/src/st_pages/__init__.py
+++ b/src/st_pages/__init__.py
@@ -3,6 +3,7 @@ from __future__ import annotations
import json
from dataclasses import dataclass
from pathlib import Path
+from typing import cast
import streamlit as st
import toml
@@ -75,10 +76,10 @@ def _get_nav_from_toml(
for page in pages:
if page.is_section:
- if translate_icon(page.icon):
+ if page.icon is not None:
current_section = f"{translate_icon(page.icon)} {page.name}"
else:
- current_section = page.name
+ current_section = cast(str, page.name)
if page.name in st.session_state[HIDE_PAGES_KEY]:
sections_to_drop.append(current_section)
continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made the changes..Wasn't sure how to avoid the mypy test failure ,Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks! |
Proposed fix for #104