Skip to content

Fix missing import streamlit as st in subsection files for empty folders#177

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/handle-empty-folders
Draft

Fix missing import streamlit as st in subsection files for empty folders#177
Copilot wants to merge 2 commits into
mainfrom
copilot/handle-empty-folders

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 9, 2026

When a subsection folder contains no recognized files, _generate_subsection produced a Python file missing import streamlit as st, causing runtime failures — the subsection header and footer always emit st.markdown() calls regardless of component count.

Changes

  • streamlit_reportview.py — After _combine_components, unconditionally inject the three base imports (import streamlit as st, from pathlib import Path, section_dir = ...) into subsection_imports if not already present. Previously these only arrived via _generate_component_imports, which is never called when the component list is empty.

  • tests/test_empty_folder.py — Three new tests: empty subsection contains all base imports; non-empty subsection is unaffected.

# Before fix — empty subsection generated file missing streamlit:
# (no imports)
# st.markdown(...)  ← NameError: name 'st' is not defined

# After fix — base imports always present:
import streamlit as st
from pathlib import Path
section_dir = Path(__file__).resolve().parent.parent

st.markdown(...)  # works correctly

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix missing streamlit import for empty folders Fix missing import streamlit as st in subsection files for empty folders Apr 9, 2026
Copilot AI requested a review from enryH April 9, 2026 20:38
Copilot finished work on behalf of enryH April 9, 2026 20:38
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.

Handle empty folders

2 participants