Skip to content

Commit e0e3754

Browse files
committed
🐛 fix import in home section ( no duplication and sorted)
1 parent f7f670c commit e0e3754

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/vuegen/streamlit_reportview.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99

1010
from . import report as r
1111
from . import table_utils
12-
from .utils import create_folder, generate_footer, get_relative_file_path, is_url
12+
from .utils import (
13+
create_folder,
14+
generate_footer,
15+
get_relative_file_path,
16+
is_url,
17+
sort_imports,
18+
)
1319
from .utils.variables import make_valid_identifier
1420

1521

@@ -381,9 +387,12 @@ def _generate_home_section(
381387

382388
# Create the home page content
383389
home_content = []
384-
home_content.append("import streamlit as st")
385-
if subsection_imports:
386-
home_content.extend(subsection_imports)
390+
subsection_imports.append("import streamlit as st")
391+
392+
subsection_imports = set(subsection_imports)
393+
subsection_imports, _ = sort_imports(subsection_imports)
394+
395+
home_content.extend(subsection_imports)
387396
if self.report.description:
388397
home_content.append(
389398
self._format_text(text=self.report.description, type="paragraph")

tests/report_examples/Basic_example_vuegen_demo_notebook/streamlit_report/sections/Home/Homepage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import streamlit as st
2-
import streamlit as st
31
import requests
2+
import streamlit as st
43
st.markdown('''<p style='text-align: center; color: #000000;'>A general description of the report.
54
</p>''', unsafe_allow_html=True)
65
st.markdown('''<h4 style='text-align: center; color: #2b8cbe;'>Description</h4>''', unsafe_allow_html=True)

0 commit comments

Comments
 (0)