Skip to content

Commit 515886c

Browse files
enryHsayalaruano
andauthored
Ruff checks (#117)
* 🎨 remove f-strings, imports or vars if not needed * 🎨 lint code base with ruff --------- Co-authored-by: Sebastián Ayala Ruano <[email protected]>
1 parent c0c7a22 commit 515886c

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

.github/workflows/cdci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ jobs:
2727
python-version: ${{ matrix.python-version }}
2828
cache: "pip" # caching pip dependencies
2929
cache-dependency-path: "**/pyproject.toml"
30-
- name: Install dependencies
30+
- name: lint package code with ruff
3131
run: |
3232
python -m pip install --upgrade pip
33+
pip install ruff
34+
ruff check src
35+
- name: Install dependencies for testing
36+
run: |
3337
pip install pytest
3438
pip install -e .
3539
- name: Run tests

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 & 6 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)}")
@@ -602,11 +602,11 @@ def _generate_plot_content(self, plot) -> List[str]:
602602
html_plot_file = (
603603
Path(self.static_dir) / f"{plot.title.replace(' ', '_')}.html"
604604
)
605-
pyvis_graph = plot.create_and_save_pyvis_network(
605+
_ = plot.create_and_save_pyvis_network(
606606
networkx_graph, html_plot_file
607607
)
608608

609-
# Add number of nodes and edges to the plor conetnt
609+
# Add number of nodes and edges to the plot content
610610
num_nodes = networkx_graph.number_of_nodes()
611611
num_edges = networkx_graph.number_of_edges()
612612

0 commit comments

Comments
 (0)