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

Fix section name #105

Merged
merged 3 commits into from
Aug 8, 2024
Merged

Fix section name #105

merged 3 commits into from
Aug 8, 2024

Conversation

Sairam90
Copy link
Contributor

@Sairam90 Sairam90 commented Aug 8, 2024

Proposed fix for #104

@@ -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):
Copy link
Owner

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

Copy link
Contributor Author

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!

Copy link
Owner

@blackary blackary left a comment

Choose a reason for hiding this comment

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

👍

@blackary
Copy link
Owner

blackary commented Aug 8, 2024

Thanks!

@blackary blackary merged commit 2c1d6e4 into blackary:main Aug 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants