Skip to content

Commit 2ed834e

Browse files
committed
🎨 remove f-strings, imports or vars if not needed
1 parent 16dac66 commit 2ed834e

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/vuegen/quarto_reportview.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def _generate_plot_content(self, plot) -> List[str]:
578578
)
579579
plot_content.append(self._generate_image_content(static_plot_path))
580580
else:
581-
plot_content.append(f"""fig_plotly.show()\n```\n""")
581+
plot_content.append("""fig_plotly.show()\n```\n""")
582582
elif plot.plot_type == r.PlotType.ALTAIR:
583583
plot_content.append(self._generate_plot_code(plot))
584584
if self.is_report_static:
@@ -587,15 +587,15 @@ def _generate_plot_content(self, plot) -> List[str]:
587587
)
588588
plot_content.append(self._generate_image_content(static_plot_path))
589589
else:
590-
plot_content.append(f"""fig_altair\n```\n""")
590+
plot_content.append("""fig_altair\n```\n""")
591591
elif plot.plot_type == r.PlotType.INTERACTIVE_NETWORK:
592592
networkx_graph = plot.read_network()
593593
if isinstance(networkx_graph, tuple):
594594
# If network_data is a tuple, separate the network and html file path
595595
networkx_graph, html_plot_file = networkx_graph
596596
elif isinstance(networkx_graph, nx.Graph) and not self.is_report_static:
597597
# Get the pyvis object and create html
598-
pyvis_graph = plot.create_and_save_pyvis_network(
598+
_ = plot.create_and_save_pyvis_network(
599599
networkx_graph, html_plot_file
600600
)
601601

@@ -805,7 +805,7 @@ def _generate_markdown_content(self, markdown) -> List[str]:
805805
)
806806

807807
# Code to display md content
808-
markdown_content.append(f"""display.Markdown(markdown_content)\n```\n""")
808+
markdown_content.append("""display.Markdown(markdown_content)\n```\n""")
809809

810810
except Exception as e:
811811
self.report.logger.error(
@@ -926,7 +926,7 @@ def _show_dataframe(self, dataframe) -> List[str]:
926926
else:
927927
# Append code to display the DataFrame interactively
928928
dataframe_content.append(
929-
f"""show(df, classes="display nowrap compact", lengthMenu=[3, 5, 10])\n```\n"""
929+
"""show(df, classes="display nowrap compact", lengthMenu=[3, 5, 10])\n```\n"""
930930
)
931931

932932
return dataframe_content

src/vuegen/report.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import logging
32
import os
43
from abc import ABC, abstractmethod

src/vuegen/streamlit_reportview.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def run_report(self, output_dir: str = SECTIONS_DIR) -> None:
296296
f"All the scripts to build the Streamlit app are available at {output_dir}"
297297
)
298298
self.report.logger.info(
299-
f"To run the Streamlit app, use the following command:"
299+
"To run the Streamlit app, use the following command:"
300300
)
301301
self.report.logger.info(
302302
f"streamlit run {Path(output_dir) / self.REPORT_MANAG_SCRIPT}"
@@ -381,7 +381,7 @@ def _generate_home_section(
381381

382382
# Create the home page content
383383
home_content = []
384-
home_content.append(f"import streamlit as st")
384+
home_content.append("import streamlit as st")
385385
if subsection_imports:
386386
home_content.extend(subsection_imports)
387387
if self.report.description:
@@ -409,9 +409,9 @@ def _generate_home_section(
409409

410410
# Add the home page to the report manager content
411411
report_manag_content.append(
412-
f"homepage = st.Page('Home/Homepage.py', title='Homepage')" # ! here Posix Path is hardcoded
412+
"homepage = st.Page('Home/Homepage.py', title='Homepage')" # ! here Posix Path is hardcoded
413413
)
414-
report_manag_content.append(f"sections_pages['Home'] = [homepage]\n")
414+
report_manag_content.append("sections_pages['Home'] = [homepage]\n")
415415
self.report.logger.info("Home page added to the report manager content.")
416416
except Exception as e:
417417
self.report.logger.error(f"Error generating the home section: {str(e)}")
@@ -430,7 +430,6 @@ def _generate_sections(self, output_dir: str) -> None:
430430

431431
try:
432432
for section in self.report.sections[1:]:
433-
section_name_var = section.title.replace(" ", "_")
434433
self.report.logger.debug(
435434
f"Processing section '{section.id}': '{section.title}' - {len(section.subsections)} subsection(s)"
436435
)
@@ -604,11 +603,11 @@ def _generate_plot_content(self, plot) -> List[str]:
604603
html_plot_file = (
605604
Path(self.static_dir) / f"{plot.title.replace(' ', '_')}.html"
606605
)
607-
pyvis_graph = plot.create_and_save_pyvis_network(
606+
_ = plot.create_and_save_pyvis_network(
608607
networkx_graph, html_plot_file
609608
)
610609

611-
# Add number of nodes and edges to the plor conetnt
610+
# Add number of nodes and edges to the plot content
612611
num_nodes = networkx_graph.number_of_nodes()
613612
num_edges = networkx_graph.number_of_edges()
614613

0 commit comments

Comments
 (0)