Skip to content

Commit 118ec8c

Browse files
committed
🎨 align import handling in streamlit and quarto reports
1 parent aa31b81 commit 118ec8c

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/vuegen/quarto_reportview.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,8 @@ def generate_report(self, output_dir: Path = BASE_DIR) -> None:
183183
f"No subsections found in section: '{section.title}'. To show content in the report, add subsections to the section."
184184
)
185185

186-
# Flatten the subsection_imports into a single list
187-
flattened_report_imports = [
188-
imp for sublist in report_imports for imp in sublist
189-
]
190-
191186
# Remove duplicated imports
192-
report_unique_imports = set(flattened_report_imports)
187+
report_unique_imports = set(report_imports)
193188

194189
# ! set leads to random import order
195190
# ! separate and sort import statements, separate from setup code
@@ -446,7 +441,7 @@ def _combine_components(self, components: list[dict]) -> tuple[list, list]:
446441
# Write imports if not already done
447442
component_imports = self._generate_component_imports(component)
448443
self.report.logger.debug("component_imports: %s", component_imports)
449-
all_imports.append(component_imports) # ! different than for streamlit
444+
all_imports.extend(component_imports)
450445

451446
# Handle different types of components
452447
fct = self.components_fct_map.get(component.component_type, None)
@@ -467,6 +462,8 @@ def _combine_components(self, components: list[dict]) -> tuple[list, list]:
467462
else:
468463
content = fct(component)
469464
all_contents.extend(content)
465+
# remove duplicates
466+
all_imports = list(set(all_imports))
470467
return all_contents, all_imports
471468

472469
def _generate_subsection(

src/vuegen/streamlit_reportview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def _combine_components(self, components: list[dict]) -> tuple[list, list, bool]
481481
has_chatbot = True
482482
content = fct(component)
483483
all_contents.extend(content)
484-
# remove duplicates and isort
484+
# remove duplicates
485485
all_imports = list(set(all_imports))
486486
return all_contents, all_imports, has_chatbot
487487

0 commit comments

Comments
 (0)