diff --git a/.github/workflows/cdci.yml b/.github/workflows/cdci.yml index aa458b3..f86bb11 100644 --- a/.github/workflows/cdci.yml +++ b/.github/workflows/cdci.yml @@ -27,9 +27,13 @@ jobs: python-version: ${{ matrix.python-version }} cache: "pip" # caching pip dependencies cache-dependency-path: "**/pyproject.toml" - - name: Install dependencies + - name: lint package code with ruff run: | python -m pip install --upgrade pip + pip install ruff + ruff check src + - name: Install dependencies for testing + run: | pip install pytest pip install -e . - name: Run tests diff --git a/src/vuegen/quarto_reportview.py b/src/vuegen/quarto_reportview.py index af18eff..cd3881b 100644 --- a/src/vuegen/quarto_reportview.py +++ b/src/vuegen/quarto_reportview.py @@ -578,7 +578,7 @@ def _generate_plot_content(self, plot) -> List[str]: ) plot_content.append(self._generate_image_content(static_plot_path)) else: - plot_content.append(f"""fig_plotly.show()\n```\n""") + plot_content.append("""fig_plotly.show()\n```\n""") elif plot.plot_type == r.PlotType.ALTAIR: plot_content.append(self._generate_plot_code(plot)) if self.is_report_static: @@ -587,7 +587,7 @@ def _generate_plot_content(self, plot) -> List[str]: ) plot_content.append(self._generate_image_content(static_plot_path)) else: - plot_content.append(f"""fig_altair\n```\n""") + plot_content.append("""fig_altair\n```\n""") elif plot.plot_type == r.PlotType.INTERACTIVE_NETWORK: networkx_graph = plot.read_network() if isinstance(networkx_graph, tuple): @@ -595,7 +595,7 @@ def _generate_plot_content(self, plot) -> List[str]: networkx_graph, html_plot_file = networkx_graph elif isinstance(networkx_graph, nx.Graph) and not self.is_report_static: # Get the pyvis object and create html - pyvis_graph = plot.create_and_save_pyvis_network( + _ = plot.create_and_save_pyvis_network( networkx_graph, html_plot_file ) @@ -805,7 +805,7 @@ def _generate_markdown_content(self, markdown) -> List[str]: ) # Code to display md content - markdown_content.append(f"""display.Markdown(markdown_content)\n```\n""") + markdown_content.append("""display.Markdown(markdown_content)\n```\n""") except Exception as e: self.report.logger.error( @@ -926,7 +926,7 @@ def _show_dataframe(self, dataframe) -> List[str]: else: # Append code to display the DataFrame interactively dataframe_content.append( - f"""show(df, classes="display nowrap compact", lengthMenu=[3, 5, 10])\n```\n""" + """show(df, classes="display nowrap compact", lengthMenu=[3, 5, 10])\n```\n""" ) return dataframe_content diff --git a/src/vuegen/report.py b/src/vuegen/report.py index c3f6625..55aab67 100644 --- a/src/vuegen/report.py +++ b/src/vuegen/report.py @@ -1,4 +1,3 @@ -import json import logging import os from abc import ABC, abstractmethod diff --git a/src/vuegen/streamlit_reportview.py b/src/vuegen/streamlit_reportview.py index 91169b9..3809c96 100644 --- a/src/vuegen/streamlit_reportview.py +++ b/src/vuegen/streamlit_reportview.py @@ -296,7 +296,7 @@ def run_report(self, output_dir: str = SECTIONS_DIR) -> None: f"All the scripts to build the Streamlit app are available at {output_dir}" ) self.report.logger.info( - f"To run the Streamlit app, use the following command:" + "To run the Streamlit app, use the following command:" ) self.report.logger.info( f"streamlit run {Path(output_dir) / self.REPORT_MANAG_SCRIPT}" @@ -381,7 +381,7 @@ def _generate_home_section( # Create the home page content home_content = [] - home_content.append(f"import streamlit as st") + home_content.append("import streamlit as st") if subsection_imports: home_content.extend(subsection_imports) if self.report.description: @@ -409,9 +409,9 @@ def _generate_home_section( # Add the home page to the report manager content report_manag_content.append( - f"homepage = st.Page('Home/Homepage.py', title='Homepage')" # ! here Posix Path is hardcoded + "homepage = st.Page('Home/Homepage.py', title='Homepage')" # ! here Posix Path is hardcoded ) - report_manag_content.append(f"sections_pages['Home'] = [homepage]\n") + report_manag_content.append("sections_pages['Home'] = [homepage]\n") self.report.logger.info("Home page added to the report manager content.") except Exception as e: self.report.logger.error(f"Error generating the home section: {str(e)}") @@ -602,11 +602,11 @@ def _generate_plot_content(self, plot) -> List[str]: html_plot_file = ( Path(self.static_dir) / f"{plot.title.replace(' ', '_')}.html" ) - pyvis_graph = plot.create_and_save_pyvis_network( + _ = plot.create_and_save_pyvis_network( networkx_graph, html_plot_file ) - # Add number of nodes and edges to the plor conetnt + # Add number of nodes and edges to the plot content num_nodes = networkx_graph.number_of_nodes() num_edges = networkx_graph.number_of_edges()